Om Namo Narayani economics
Sri Narayani Vidyashram Sr. Sec. School (CBSE)
Sripuram, Vellore
SQL
GRADE - XII
[Link] Question
1 Consider the given expression:
print(19<11 and 29>19 or not 75>30)
Which of the following will be the correct output of the given expression?
a) True b) False c) Null d) No output
Ans:
b) False
2 Write the output of the following Python code :
for k in range(7,40,6):
print ( k + '-' )
Ans:
Error as unsupported operand type(s) for +: 'int' and ‘str'
3 What will be the output of the following Python statement:
print(10-3**2**2+144/12)
Ans:
-59.0
4 Explain the difference between explicit and implicit type conversion in Python with a
suitable example.
Ans:
A. Implicit Conversion: Python automatically converts one data type to another.
Example:
x = 10
y = 3.5
Om Namo Narayani economics
Sri Narayani Vidyashram Sr. Sec. School (CBSE)
Sripuram, Vellore
SQL
result = x + y # x is implicitly converted to float
Explicit Conversion: The user manually converts one data type to another using
functions like int(), float().
Example:
x = "10"
y = int(x) # Explicit conversion from string to integer
5 Explain the difference between break and continue statements in Python with a
suitable example.
Ans:
Break exits the loop entirely, while continue skips the current iteration and
moves to the next one.
Example of break:
Output:
1
Example of continue:
for i in range(5):
if i == 2:
continue # Skips printing 2
print(i)
Om Namo Narayani economics
Sri Narayani Vidyashram Sr. Sec. School (CBSE)
Sripuram, Vellore
SQL
Output:
1
3
4
5
(1 mark for correct difference)
(1/2 mark for each correct example)
6 The code provided below is intended to remove the first and last characters of a
given string and return the resulting string. However, there are syntax and logical
errors in the code.
Rewrite it after removing all the errors. Also, underline all the corrections made.
Ans:
7 State True or False:
The Python interpreter handles logical errors during code execution.
Ans:
False
Om Namo Narayani economics
Sri Narayani Vidyashram Sr. Sec. School (CBSE)
Sripuram, Vellore
SQL
8 Which of the following expressions evaluates to False?
(A) not(True) and False
(B) True or False
(C) not(False and True)
(D) True and not(False)
Ans:
(A) not (True) and False
9 State True or False:
“In a Python program, if a break statement is given in a nested loop, it
terminates the execution of all loops in one go.”
Ans:
False
10 How is a mutable object different from an immutable object in Python?
Identify one mutable object and one immutable object from the following:
(1,2), [1,2], {1:1,2:2}, ‘123’
Ans:
A mutable object can be updated whereas an immutable object cannot be
updated.
Mutable object: [1,2] or {1:1,2:2} (Any one)
Immutable object: (1,2) or ‘123’ (Any one)
(1 mark for correct difference)
(½ x 2 = 1 Mark for selecting correct objects)
11 Give two examples of each of the following:
(I) Arithmetic operators (II) Relational operators
Ans:
(I) Arithmetic operators: +,-
Om Namo Narayani economics
Sri Narayani Vidyashram Sr. Sec. School (CBSE)
Sripuram, Vellore
SQL
(II) Relational operators: >, >=
(½ x 4 = 2 Marks for each correct operator)
12 What will be the output of the following statement:
print(3-2**2**3+99/11)
a. 244
b. 244.0
c. -244.0
d. Error
Ans:
Option c
-244.0
13 The code given below accepts a number as an argument and returns the
reverse number. Observe the following code carefully and rewrite it after
removing all syntax and logical errors. Underline all the corrections made.
Ans:
Om Namo Narayani economics
Sri Narayani Vidyashram Sr. Sec. School (CBSE)
Sripuram, Vellore
SQL
14 State True or False –
“Variable declaration is implicit in Python.”
Ans. TRUE
15 Which of the following is an invalid datatype in Python?
(a) Set (b) None (c)Integer (d)Real
Ans: (d) Real
16 Consider the given expression:
not True and False or True
Which of the following will be correct output if the given expression is
evaluated?
(a)
True
(b)
False
(c)
NONE
(d)
NULL
Ans: (a) True
17 What will the following expression be evaluated to in Python?
Om Namo Narayani economics
Sri Narayani Vidyashram Sr. Sec. School (CBSE)
Sripuram, Vellore
SQL
print(15.0 / 4 + (8 + 3.0))
(a) 14.75 (b)14.0 (c) 15 (d) 15.5
Ans: (a) 14.75
18 Rao has written a code to input a number and check whether it is prime or
not. His code is having errors. Rewrite the correct code and underline the
corrections made.
Ans:
19 State True or False:
“A Python List must always contain all its elements of same data type.”
Ans
False
20 What will be the output of the following statement?
Om Namo Narayani economics
Sri Narayani Vidyashram Sr. Sec. School (CBSE)
Sripuram, Vellore
SQL
print(14%3**2*4)
(A) 16
(B) 64
(C) 20
(D) 256
Ans (C) 20
21 Which of the following is the correct identifier?
(A) global
(B) Break
(C) def
(D) with
1
Ans (B) Break
22 Identify the invalid Python statement out of the following options:
(A) print("A",10,end="*")
(B) print("A",sep="*",10)
(C) print("A",10,sep="*")
(D) print("A"*10)
1
Ans (B) print("A",sep="*",10)
23 Which of the following operator evaluates to True if the variable on either
side
of the operator points towards the same memory location and False
otherwise?
(A) is
(B) is not
(C) and
(D) or
Om Namo Narayani economics
Sri Narayani Vidyashram Sr. Sec. School (CBSE)
Sripuram, Vellore
SQL
Ans (A) is
24 Write one example of each of the following in Python :
(i) Syntax Error
(ii) Implicit Type conversion
(i) Syntax Error
print(2 ; 5)
(ii) Implicit Type conversion
x=10
y=20.5
print(x+y)
Note:
● The above examples are just suggestive. Accept all correct examples
25 The code given below accepts N as an integer argument and returns the
sum of
all integers from 1 to N. Observe the following code carefully and rewrite it
after
removing all syntax and logical errors. Underline all the corrections made.
Ans:
Om Namo Narayani economics
Sri Narayani Vidyashram Sr. Sec. School (CBSE)
Sripuram, Vellore
SQL
Or
26 State True or False :
While defining a function in Python, the positional parameters in the function
header must
always be written after the default parameters.
Ans False
27 What will be the output of the following statement :
1
print (16*5/4*2/5–8)
(a) – 3.33
(b) 6.0
(c) 0.0
(d) –13.33
Ans (c) 0.0
28 Identify the statement from the following which will raise an error :
(a) print("A"*3)
Om Namo Narayani economics
Sri Narayani Vidyashram Sr. Sec. School (CBSE)
Sripuram, Vellore
SQL
(b) print(5*3)
(c) print("15" + 3)
(d) print("15" + "13")
Ans:
(c) print("15" + 3)
29 The code given below accepts five numbers and displays whether they are even or
odd:
Observe the following code carefully and rewrite it after removing all syntax and
logical
errors :
Underline all the corrections made.
Ans:
30 State True or False.
“Identifiers are names used to identify a variable, function in a program”.
Ans True
31 Which of the following is a valid keyword in Python ?
(a) false (b) return
(c) non_local (d) none
Om Namo Narayani economics
Sri Narayani Vidyashram Sr. Sec. School (CBSE)
Sripuram, Vellore
SQL
Ans (b) return
32 Consider the given expression :
5<10 and 12>7 or not 7>4
Which of the following will be the correct output, if the given expression is
evaluated ?
(a) True
(b) False
(c) NONE
(d) NULL
1
Ans (a) True