0% found this document useful (0 votes)
40 views4 pages

Class 11 Computer Science Python Exam Guide

Uploaded by

akshat1949
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views4 pages

Class 11 Computer Science Python Exam Guide

Uploaded by

akshat1949
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Class 11 – Computer Science Question Paper with

Answer Key
Maximum Marks: 70 Time: 3 Hours

QUESTION PAPER

SECTION – A (1 mark each)


Q1. Write True or False: Python is a case-sensitive language.
2. The extension of a Python file is: (a) .p (b) .py (c) .pt (d) .pyt
3. Which of the following is a mutable data type in Python? (a) Tuple (b) String (c) List (d)
Integer
4. Which of the following is NOT a keyword in Python? (a) for (b) while (c) switch (d) if
5. Which operator is used for floor division in Python? (a) / (b) // (c) % (d) **
6. In Python, len('Hello') will return: (a) 4 (b) 5 (c) 6 (d) Error
7. Which function is used to convert a string into a list of words? (a) split() (b) join() (c)
append() (d) extend()
8. The output of 2**3 in Python is: (a) 6 (b) 8 (c) 9 (d) 16
9. Which of the following is a membership operator? (a) in (b) is (c) not (d) ==
10. What will be the result of 10 % 3? (a) 3 (b) 1 (c) 0 (d) 10
11. A Python tuple is: (a) Mutable (b) Immutable (c) Changeable (d) Error
12. Which of the following functions finds maximum value from a list? (a) max() (b) sum()
(c) min() (d) len()
13. Which function is used to find the data type of a variable? (a) type() (b) str() (c) id() (d)
isinstance()
14. Which of these is not a logical operator? (a) and (b) or (c) not (d) add
15. Which statement is used to exit from a loop in Python? (a) continue (b) stop (c) break
(d) exit
16. The index of the first element of a list in Python is: (a) 0 (b) 1 (c) -1 (d) None
17. Which of the following is used for comments in Python? (a) // (b) # (c) /* */ (d) !
18. Which built-in function is used to calculate length of a list? (a) size() (b) count() (c) len()
(d) length()
19. What will be the output of print('hello'.upper())? (a) HELLO (b) Hello (c) hello (d) Error

SECTION – B (2 Marks each)


Q20. Assertion–Reason: Assertion (A): Python supports both procedural and
object-oriented programming. Reason (R): Python does not allow defining user-defined
functions.
Q21. Assertion–Reason: Assertion (A): Lists in Python are ordered and mutable. Reason
(R): Once a list is created, it cannot be modified.
Q22. Find the error in the following code:

list1 = [10, 20, 30]


print(list1[3])
Q23. Write any two built-in functions of lists with examples.
Q24. Predict the output:

list1 = [1,2,3,4,5]
print(list1[1:4])
print(len(list1))

SECTION – C (3 Marks each)


Q25. Differentiate between compiler and interpreter.
Q26. Differentiate between list and tuple with suitable examples.
Q27. Explain mutable and immutable datatypes in Python with two examples.
Q28. Define a function. State two advantages of using functions.
Q29. Write a program to search an element in a list.
Q30. Write a program to count occurrences of a number in a list.
Q31. Write a program to find sum, average, minimum and maximum of list elements.

SECTION – D (5 Marks each)


Q32. (2+2) (a) Write a program to swap two numbers using a temporary variable. (b) Write
a short note on dynamic typing in Python.
Q33. (2+2) (a) Write programs for: (i) factorial of a number (ii) Fibonacci sequence till n
terms. (b) Explain the flow of execution in Python programs.
Q34. (2+2) (a) Explain two list functions with examples. (b) Differentiate between append()
and extend().
Q35. (2+2) (a) Write a Python program to find maximum number in a list. (b) Differentiate
between remove() and pop() with examples.
Q36. (2+3) (a) Explain nested lists with an example. (b) Write a program to count
occurrences of an element and replace it with another.
Q37. (2+3) (a) Explain shallow copy and deep copy of lists with examples. (b) Write a
program to calculate sum, average, minimum, maximum of a list.

ANSWER KEY / MARKING SCHEME

SECTION – A
Q1. True
Q2. b) .py
Q3. c) List
Q4. c) switch
Q5. b) //
Q6. b) 5
Q7. a) split()
Q8. b) 8
Q9. a) in
Q10. b) 1
Q11. b) Immutable
Q12. a) max()
Q13. a) type()
Q14. d) add
Q15. c) break
Q16. a) 0
Q17. b) #
Q18. c) len()
Q19. a) HELLO

SECTION – B
Q20. (c) A is True but R is False.
Q21. (c) A is True but R is False.
Q22. Error: Index out of range (list has indices 0,1,2 only).
Q23. Examples: len(list), max(list), min(list), sum(list).
Q24. Output:
[2, 3, 4]
5

SECTION – C
Q25. Compiler translates entire program at once; Interpreter executes line by line.
Q26. List = mutable, Tuple = immutable. Example: list1=[1,2]; tuple1=(1,2).
Q27. Mutable: list, dict; Immutable: string, tuple.
Q28. Function = block of reusable code. Advantages: reusability, readability.
Q29. Example:
x=int(input('Enter:'))
if x in list1: print('Found') else: print('Not found')
Q30. Example:
list1=[1,2,2,3]
print([Link](2))
Q31. Example:
list1=[10,20,30]
print(sum(list1), sum(list1)/len(list1), min(list1), max(list1))

SECTION – D
Q32. (a) Swap using temp variable.
x,y=10,20; temp=x; x=y; y=temp
(b) Dynamic typing = variable type decided at runtime.
Q33. (a) Factorial & Fibonacci code.
(b) Flow: sequential unless changed by condition/loop/function.
Q34. (a) [Link](x), [Link]([..]).
(b) append() adds single element, extend() adds multiple.
Q35. (a) max(list) or loop.
(b) remove(val) deletes by value; pop(i) deletes by index.
Q36. (a) Nested list = list within list. Example: [[1,2],[3,4]].
(b) Replace occurrences using loop/replace.
Q37. (a) Shallow copy = references inner lists; deep copy = independent copy.
(b) sum, avg, min, max using functions.

Common questions

Powered by AI

The split() function in Python divides a string into a list of substrings based on a specified delimiter (default is space). It's commonly used in data processing for parsing text data into manageable parts, such as splitting lines of text from a file into words for analysis or extraction of specific fields from formatted strings .

Shallow copying should be used when you want a new list whose elements are references to the objects in the original list, but with the ability to modify the structure independently. Deep copying is necessary when you need a completely independent copy of the original list, with all inner objects recursively copied. A pitfall of shallow copying is unintentional mutable state sharing between copies, leading to side effects when inner objects are modified .

Python is considered a dynamically typed language because the type of a variable is determined at runtime, not in advance. This allows for greater flexibility and simplicity in code writing, as variables can change type and are not bound to a strict type declaration . However, it can lead to runtime errors if type mismatches are not correctly managed, reducing some compile-time error checking .

A compiler translates the entire program at once into machine code before execution, which can be executed multiple times without recompilation. In contrast, an interpreter translates and executes the program line by line, needing to reprocess the source code each time .

A Python list is mutable, allowing modifications such as adding or removing elements, making it useful for collections that may change in size. A tuple, however, is immutable, providing a fixed-size, unordered collection ideal for data that should not change, meant for faster access and better memory optimization .

The immutability of strings in Python means they cannot be changed after creation, allowing for optimized memory usage since unchanged strings can be shared across different parts of a program. This immutability also enhances performance in terms of speed by leveraging string interning and caching, avoids unintended side effects from modifying strings, and supports efficient hashing operations critical for usage as dictionary keys .

The flow of execution in a Python program is generally sequential, executing statements from top to bottom unless directed otherwise by control statements like loops and conditionals or modified by function calls. Understanding this flow is crucial for debugging because it allows programmers to predict which parts of code execute and in what order, helping in identifying where issues may arise if the expected behavior isn't met .

The append() method adds a single element at the end of a list, while extend() adds each element from an iterable to the list. Append should be used when adding individual items, such as numbers or strings, whereas extend is more suitable when concatenating another collection, like adding all items from another list . Example: appending a single integer, extend for merging lists.

Mutable data types, like lists and dictionaries, can be changed after their creation (e.g., elements can be added or modified). Immutable data types, like strings and tuples, cannot be altered after they are set, meaning that any 'change' creates a new object . Mutable example: a list can have elements appended, whereas an immutable tuple cannot be changed once initialized .

Functions in Python create modular code blocks that help in reusability and enhance readability by reducing redundancy. Reusing functions across different parts of a program or in different projects increases efficiency and consistency, making code easier to maintain and understand. This leads to higher quality code by ensuring single-point control over functionality changes .

You might also like