Class 12 Worksheet
Chapter: Rev tour 1 and Rev tour 2
1. What is the primary characteristic of an object in an object-oriented language like Python?
a) It is a fixed value that cannot be changed.
b) It is a named label for a memory location.
c) It is an entity that has both properties and behavior.
d) It is a reserved word with a special meaning.
2. The smallest individual unit in a Python program is known as a Token. Which of the following is
NOT considered a Token?
a) Identifier b) Keyword c) Expression d) Literal
3. What is a non-graphic character?
a) A character that can be typed directly from the keyboard.
b) A character that cannot be typed directly from the keyboard.
c) A character that represents a digit.
d) A character that represents a letter.
4. Which of the following is an example of a floating-point literal in scientific notation?
a) `123` b) `'Hello'` c) `True` d) `152E+8`
5. What does the `None` literal represent in Python?
a) A value of zero. b) An empty string. c) The absence of a value. d) A Boolean value.
6. Which of the following is an example of a unary operator?
a) `a + b` b) `a - b` c) `-a` d) `a / b`
7. What is the purpose of punctuators?
a) To define new functions. b) To trigger computations.
c) To represent fixed data values. d) To organize programming sentence structure.
8. Which operator is used for string replication?
a) `+` b) `-` c) `*` d) `/`
9. What is the definition of a token?
a) A set of valid characters. b) The smallest individual unit in a program.
c) A group of statements. d) A reserved word.
10. What are identifiers used for?
a) Representing fixed data values. b) Giving names to different parts of the program.
c) Defining keywords. d) Creating non-graphic characters.
11. What is a string literal?
a) A sequence of characters. b) A fixed numerical value.
c) A variable. d) A keyword.
12. How are multiline strings created using triple quotes?
a) By enclosing text in single quotes (`' '`).
b) By enclosing text in double quotes (`" "`).
c) By enclosing text in three single quotes (`''' '''`) or three double quotes (`""" """`).
d) By adding a backslash at the end of each line.
13. What is a `Boolean` literal?
a) A numerical value. b) A value that can be `True` or `False`.
c) A sequence of characters. d) An absence of a value.
14. What are variables and objects to which a computation is applied called?
a) Operators b) Operands c) Punctuators d) Tokens
15. What is the definition of a keyword?
a) A name given to a variable.
b) A word having special meaning reserved by the programming language.
c) A data item with a fixed value.
d) A symbol used for organizing code.
16. What is a statement in Python?
a) A legal combination of symbols that represents a value.
b) A programming instruction that does something.
c) Additional readable information in the source code.
d) A group of statements.
17. What is the primary purpose of a function?
a) To store a fixed value. b) To get input from the user.
c) To group statements that can be reused by name. d) To declare a variable.
18. What is a group of statements which are part of another statement or function called?
a) A suite b) A keyword c) A token d) An expression
19. What does it mean for Python to have "dynamic typing"?
a) Variables cannot change their data type.
b) Variables must be declared with a specific data type.
c) A variable can be made to point to an object of a different type.
d) Data types are not used in Python.
20. Which built-in function is used to get interactive input from a user?
a) `print()` b) `input()` c) `get_input()` d) `read()`
21. What is the purpose of the `str()` function?
a) To convert a value to an integer. b) To convert a value to a string.
c) To check if a value is a string. d) To convert a string to a float.
22. What are the two forms in which floating-point numbers can be written?
a) Integer form and complex form. b) Fractional form and scientific notation.
c) Octal form and hexadecimal form. d) String form and Boolean form.
23. What is the precision of floating-point numbers in Python?
a) 5 digits b) 10 digits c) 15 digits d) 20 digits
24. A complex number in Python is in the form of...
a) `a + bi` b) `a + b` c) `a * b` d) `a / b`
25. What is the difference between an integer and a floating-point number?
a) An integer is a whole number, while a float has a fractional part.
b) An integer can be written in scientific notation, a float cannot.
c) An integer is mutable, a float is immutable.
d) There is no difference.
26. Which of the following is an immutable data type?
a) `list` b) `dict` c) `set` d) `tuple`
27. Which of the following is a mutable data type?
a) `int` b) `str` c) `list` d) `tuple`
28. An expression in Python is a combination of what two things?
a) Operators and atoms. b) Keywords and identifiers.
c) Statements and functions. d) Blocks and comments.
29. An expression having literals and/or variables and relational operators is a...
a) Logical expression. b) Arithmetic expression.
c) Relational expression. d) String expression.
30. What is an implicit type conversion?
a) A conversion performed by the programmer.
b) A conversion performed by the compiler without programmer intervention.
c) A conversion of an integer to a string.
d) A conversion of a string to an integer.
31. How are Python strings stored in memory?
a) In non-contiguous memory locations. b) In sequential memory locations.
c) In random memory locations. d) In a single memory block.
32. How can individual characters in a string be accessed?
a) By using a specific memory address. b) By using their forward and backward index.
c) By using a special function. d) By converting the string to a list.
33. What is a "string slice"?
a) A fixed-length string. b) A part of a string containing contiguous characters.
c) The first character of a string. d) The last character of a string.
34. Which operator is used to join two lists?
a) `+` b) `-` c) `*` d) `/`
35. What is a "nested list"?
a) A list that contains only numbers. b) A list that contains only strings.
c) A list where one or more members are other lists. d) A list with no elements.
36. What does the property of "mutability" for a list mean?
a) The list's elements cannot be changed.
b) The list can only contain numbers.
c) New values can be stored at the same memory address.
d) The list's size is fixed.
37. Which function returns a copy of the string with its first character capitalized?
a) `string.lower()` b) `string.upper()`
c) `string.capitalize()` d) `string.islower()`
38. Which function returns `True` if all characters in the string are numeric?
a) `string.isalnum()` b) `string.isalpha()`
c) `string.isdigit()` d) `string.isspace()`
39. What does the `ord()` function return?
a) The character corresponding to a passed ASCII value.
b) The ASCII value of a passed character.
c) The number of characters in a string.
d) The first character of a string.
40. What is the syntax for the `append()` function in lists?
a) `list.append(item)` b) `append(list, item)`
c) `list.add(item)` d) `list.insert(item)`
41. Which list method removes the first occurrence of a given item?
a) `pop()` b) `remove()` c) `clear()` d) `delete()`
42. What is "traversing" a tuple?
a) Changing an element in the tuple. b) Accessing and processing each element in the tuple.
c) Adding an element to the tuple. d) Deleting an element from the tuple.
43. How are tuples represented?
a) With square brackets `[ ]`. b) With parentheses `( )`.
c) With curly braces `{ }`. d) With angle brackets `< >`.
44. Which dictionary method returns all the keys in the dictionary?
a) `values()` b) `items()` c) `keys()` d) `get()`
45. Which dictionary method returns all the key-value pairs?
a) `values()` b) `items()` c) `keys()` d) `get()`
46. What must the keys of a dictionary be?
a) Mutable b) Unique c) Integers d) Strings
47. What are the two membership operators in strings?
a) `+` and `*` b) `is` and `is not` c) `in` and `not in` d) `==` and `!=`
48. What is "indexing"?
a) The process of changing a character in a string.
b) The process of giving a location number to each individual character in a string.
c) The process of converting a string to a list.
d) The process of joining two strings.
49. What is the difference between a list and a tuple in terms of mutability?
a) Lists are immutable, tuples are mutable. b) Lists are mutable, tuples are immutable.
c) Both lists and tuples are mutable. d) Both lists and tuples are immutable.
50. What is the purpose of the `get()` method in a dictionary?
a) To retrieve a key from the dictionary. b) To remove an item with a given key.
c) To get the value associated with a given key. d) To add a new key-value pair.
51. What are statements that allow a set of instructions to be performed repeatedly called?
a) Selection statements b) Iteration statements
c) Simple statements d) Empty statements
52. What is an algorithm?
a) A program written in Python. b) A graphical representation of a program.
c) A step-by-step procedure to solve a problem. d) A syntax for a function.
53. What is a flowchart?
a) A textual description of a program. b) A graphical representation of the steps of an algorithm.
c) A list of variables. d) A type of loop.
54. What is the purpose of `if` statements?
a) To perform a computation. b) To implement selection constructs.
c) To repeat a set of statements. d) To create a new variable.
55. When is the `else` clause of a loop executed?
a) When the loop terminates normally. b) When a `break` statement is encountered.
c) When an error occurs. d) The `else` clause is never executed with a loop.
56. What does an "entry-controlled loop" mean?
a) The loop has a control over entry in the form of a test condition.
b) The loop has a control over its exit.
c) The loop executes at least once.
d) The loop can never be an infinite loop.
57. What are the `in` and `not in` operators also called?
a) Arithmetic operators. b) Relational operators.
c) Logical operators. d) Membership operators.
58. What is an "infinite loop"?
a) A loop that executes a fixed number of times.
b) A loop that never ends.
c) A loop that is controlled by a test condition.
d) A loop that can only be exited with a `break` statement.
59. What is "nesting"?
a) A single program construct. b) A program construct within another of the same type.
c) A group of statements. d) The process of writing code that is not indented.
60. How is a block of consecutive statements having the same indentation level identified in Python?
a) By using curly braces `{}`. b) By using parentheses `()`.
c) By the indentation level. d) By a special keyword.
61. What does the `in` operator test for?
a) If two values are equal. b) If a given value is contained in a sequence.
c) If a value is a number. d) If a value is a string.
62. What does the `break` statement do?
a) Skips over a part of the code. b) Terminates a loop immediately.
c) Jumps to the beginning of the loop. d) Continues to the next iteration of the loop.
63. What does the `continue` statement do?
a) Terminates a loop immediately. b) Continues to the next iteration of the loop.
c) Jumps out of the current function. d) Skips the entire loop.
64. What is the "exit condition" of a loop?
a) The condition on which the execution or exit of the loop depends.
b) The first statement inside the loop.
c) The last statement inside the loop.
d) The number of times the loop will run.
65. What is the purpose of the `range()` function?
a) To find the maximum value in a sequence. b) To generate a sequence of list type.
c) To create a new dictionary. d) To check if a number is within a range.
66. What is a "simple statement"?
a) A compound statement.
b) A single executable statement.
c) A statement with no indentation.
d) A statement that contains a loop.
67. What is an "empty statement"?
a) A statement that appears in the code but does nothing.
b) A statement with no keywords.
c) A statement that is a comment.
d) A statement that causes an error.
68. What are "jump statements"?
a) Statements that change the normal flow of control.
b) Statements that are used to create loops.
c) Statements that are used to define functions.
d) Statements that are used to declare variables.
69. What does the `is` identity operator check for?
a) If two operands have the same value.
b) If two operands are pointing to the same object.
c) If two operands have the same data type.
d) If two operands are not equal.
70. What is "type casting"?
a) An implicit conversion.
b) An automatic conversion by the compiler.
c) An explicit conversion of an operand to a specific type.
d) The process of assigning a variable to a value.
71. What does `string.islower()` return `True` for?
a) If all characters are uppercase.
b) If all cased characters are lowercase.
c) If the string contains no letters.
d) If the string is empty.
72. What is the main difference between `string.lower()` and `string.isupper()`?
a) `lower()` modifies the original string, while `isupper()` returns a new string.
b) `lower()` returns a lowercase copy, while `isupper()` checks if the string is all uppercase.
c) They both return a lowercase string.
d) They both check if the string is all lowercase.
73. What is the purpose of the `len()` function?
a) To find the largest value in a sequence.
b) To count the number of characters in a string.
c) To check if a sequence is empty.
d) To find the length of a variable name.
74. What does the `pop()` method do to a list?
a) Adds an element to the end.
b) Removes an element at a given index.
c) Sorts the list.
d) Reverses the list.
75. What is the main difference between a list and a dictionary?
a) Lists are ordered and use indexed values; dictionaries are unordered and use key-value pairs.
b) Lists are mutable, dictionaries are immutable.
c) Lists can hold different data types, dictionaries can only hold one.
d) There is no difference.
76. How would you access the value `30` from the list `my_list = [10, 20, 30, 40]`?
a) `my_list[0]` b) `my_list[2]` c) `my_list(30)` d) `my_list.get(30)`
77. What is the value of `q` in the following code: `p = (1, 2, 3)` and `q = p + (4,)`?
a) `(1, 2, 3, 4)` b) `[1, 2, 3, 4]` c) `(1, 2, 3)` d) `(4,)`
78. What is a "code-block" or "suite"?
a) A single line of code.
b) An individual token.
c) A group of statements which are part of another statement.
d) A single variable declaration.
79. What does `a is not b` return?
a) `True` if `a` and `b` have the same value.
b) `True` if `a` and `b` are pointing to different objects.
c) `False` if `a` and `b` have the same value.
d) `False` if `a` and `b` are pointing to different objects.
80. What is an expression that has a combination of operators and atoms?
a) A statement b) A variable c) A function d) An expression
81. How can you terminate a `while` loop that never ends?
a) By using a `continue` statement.
b) By using a `break` statement inside a conditional check.
c) By changing the loop's condition to `True`.
d) An infinite loop can never be terminated.
82. What is the primary difference between a flowchart and an algorithm?
a) A flowchart is a step-by-step procedure, while an algorithm is a graphical representation.
b) A flowchart is a graphical representation, while an algorithm is a step-by-step procedure.
c) There is no difference.
d) Flowcharts are only for simple problems; algorithms are for complex ones.
83. What are the two types of sorting techniques mentioned in the text?
a) Quick sort and Merge sort. b) Bubble sort and Insertion sort.
c) Selection sort and Heap sort. d) Radix sort and Bucket sort.
84. What happens when a `print()` function is called without any value or expression?
a) It prints an error. b) It prints the value `None`.
c) It prints a blank line. d) It prints the word "None".
85. In 2-way indexing, what are the forward indexes numbered as?
a) `1, 2, 3...` b) `-1, -2, -3...` c) `0, 1, 2,...length-1` d) `1, 2, 3,...length`
86. What is the process of accessing and processing each element in a tuple called?
a) Indexing b) Slicing c) Traversing d) Sorting
87. Which method removes all the items from a list?
a) `remove()` b) `pop()` c) `clear()` d) `delete()`
88. What is a key characteristic of the `range()` function's output?
a) It returns a single number. b) It generates a sequence of list type.
c) It returns a random sequence. d) It returns a tuple.
89. When does the `else` clause of an `if-elif` statement execute?
a) When the `if` condition is `True`. b) When the `elif` condition is `True`.
c) When the `if` and all `elif` conditions are `False`. d) The `else` clause always executes.
90. What is `p=(1,2,3,4,5)` an example of?
a) A list b) A dictionary c) A tuple d) A set
91. What is the purpose of the `values()` method in a dictionary?
a) To get a list of all keys. b) To get a list of all values.
c) To get a list of all key-value pairs. d) To get the value for a specific key.
92. What are `True` and `False` considered?
a) Integers b) Strings c) Booleans d) Complex numbers
93. What is a "bare bones" Python program?
a) A program with no variables.
b) A program with no comments.
c) A program that has the minimum required components to run.
d) A program written in a single line.
94. What does the expression `x is not y` check for?
a) If `x` and `y` have the same value. b) If `x` and `y` are the same object.
c) If `x` and `y` are different objects. d) If `x` and `y` are integers.
95. What is `152E+8` an example of?
a) A complex number. b) An integer.
c) A floating-point number. d) A Boolean literal.
96. What is the purpose of the `isspace()` function?
a) To check if a string contains any whitespace characters.
b) To check if a string is empty.
c) To check if a string has at least one character.
d) To check if the characters in the string are all spaces.
97. What is `a is b` an example of?
a) An assignment operator.
b) A relational operator.
c) An identity operator.
d) A logical operator.
98. Which statement can terminate a loop immediately, passing control to the statement following
the loop?
a) `continue`
b) `break`
c) `pass`
d) `return`
99. What does it mean for a data type to be "immutable"?
a) Its value can be changed in place.
b) Its value can never be changed in place.
c) It can only store numerical values.
d) It is a type of list.
100. What does the `keys()` method of a dictionary return?
a) A sequence of values.
b) A sequence of tuples.
c) A sequence of keys.
d) A sequence of key-value pairs.
Predict the Output
Question 1
Python
x = 10
y=3
print(x / y)
print(x // y)
Predicted Output:
Question 2
Python
s1 = "Python"
s2 = "Fundamentals"
s3 = s1 + " " + s2
print(s3)
print(s1 * 3)
Predicted Output:
Question 3
Python
a=5
b = 10
print(a > b)
print(a <= b)
print(a != b)
Predicted Output:
Question 4
Python
x = 10
if x > 15:
print("A")
elif x > 5:
print("B")
else:
print("C")
Predicted Output:
Question 5
Python
count = 0
while count < 4:
print(count)
count += 1
else:
print("Loop finished")
Predicted Output:
Question 6
Python
for i in range(5):
if i == 3:
break
print(i)
Predicted Output:
Question 7
Python
for char in "Hello":
if char == 'l':
continue
print(char, end='')
Predicted Output:
Question 8
Python
my_list = [1, 2, 3, 4]
my_list.append(5)
print(my_list[0])
print(my_list[-1])
print(my_list)
Predicted Output:
Question 9
Python
my_tuple = (10, 20, 30)
print(my_tuple[1])
# The next line is commented out. What would it do if it wasn't?
# my_tuple[1] = 25
Predicted Output:
Question 10
Python
my_dict = {"a": 1, "b": 2}
print(my_dict["a"])
my_dict["c"] = 3
print(my_dict)
print(my_dict.get("d", "Not found"))
Predicted Output:
Question 11
Python
p = "apple"
q = "banana"
print(p is q)
q=p
print(p is q)
Predicted Output:
Question 12
Python
my_string = "Hello"
print('e' in my_string)
print('x' not in my_string)
Predicted Output:
Question 13
Python
print(ord('A'))
print(chr(65))
Predicted Output:
Question 14
Python
x=5
y = "10"
z = x + int(y)
print(z)
Predicted Output:
Question 15
Python
x=1
y=2
if x == 1 and y == 2:
print("Both conditions are true")
else:
print("At least one condition is false")
Predicted Output:
Question 16
Python
s = "PyThon"
print(s.upper())
print(s.lower())
print(s.capitalize())
Predicted Output:
Question 17
Python
a = [10, 20, 30]
b=a
b.append(40)
print(a)
Predicted Output:
Question 18
Python
my_list = [5, 1, 9, 3]
my_list.sort()
print(my_list)
my_list.reverse()
print(my_list)
Predicted Output:
Question 19
Python
x = 10
if x > 5:
pass
else:
print("This won't be executed")
print("End of program")
Predicted Output:
Question 20
Python
my_dict = {"a": 1, "b": 2, "c": 3}
print(my_dict.keys())
print(my_dict.values())
print(my_dict.items())
Predicted Output:
Find the Error
Question 1
Python
# Intended to print "Hello, world!"
print 'Hello, world!'
Error Description:
Corrected Code:
Question 2
Python
# Intended to calculate the area of a circle
radius = 5
pi = 3.14
area = pi * radius ^ 2
print(area)
Error Description:
Corrected Code:
Question 3
Python
# Intended to check if a number is positive
num = -10
if num > 0
print("Positive")
Error Description:
Corrected Code:
Question 4
Python
# Intended to store a list of numbers
my_list = [1, 2, 3]
my_list.add(4)
print(my_list)
Error Description:
Corrected Code:
Question 5
Python
# Intended to create a dictionary
my_dict = {"name": "Alice", "age": 25}
print(my_dict["Name"])
Error Description:
Corrected Code:
Question 6
Python
# Intended to loop through a range of numbers
for i in range(10):
print(i)
Error Description:
Corrected Code:
Question 7
Python
# Intended to perform a conditional check
x = 10
if x = 10:
print("X is ten")
Error Description:
Corrected Code:
Question 8
Python
# Intended to define a function and call it
def greet(name)
print("Hello, " + name)
greet("Bob")
Error Description:
Corrected Code:
Question 9
Python
# Intended to get input from the user and multiply it by 2
user_age = input("Enter your age: ")
print(user_age * 2)
Error Description:
Corrected Code:
Question 10
Python
# Intended to create a tuple and change a value
my_tuple = (1, 2, 3)
my_tuple[1] = 5
print(my_tuple)
Error Description:
Corrected Code:
Question 11
Python
# Intended to use a list method to remove an item
my_list = ["apple", "banana", "cherry"]
my_list.remove("orange")
print(my_list)
Error Description:
Corrected Code:
Question 12
Python
# Intended to use a variable before it is defined
print(x)
x = 10
Error Description:
Corrected Code:
Question 13
Python
# Intended to concatenate a number and a string
age = 30
message = "I am " + age + " years old."
print(message)
Error Description:
Corrected Code:
Question 14
Python
# Intended to check if a key exists in a dictionary
my_dict = {"a": 1, "b": 2}
if "c" in my_dict.values():
print("Key 'c' exists")
Error Description:
Corrected Code:
Question 15
Python
# Intended to use a logical operator
x=5
y = 10
if x > 0 and y > 0
print("Both are positive")
Error Description:
Corrected Code: