MCQ of python class 12

Q1. What is the output of the following code :
print(9//2)
A. 4
B. 4.5
c. 1
d. 4.0

Show Answer

Option A Description: Since // symbol is also known as integer divider thus it will remove the fractional part from the output

Q2. Given a string s = “Welcome”, which of the following code is incorrect?
A. print(s[0])
B. print(s.lower())
C. s[1]=’r’
D. print(s.strip())

Show Answer

Option C Explaination : String is immutable thus can not change its value during run time

Q3. Which shortcut command is used to start a new script window in Python IDLE
A. Ctrl+O
B. Ctrl+ N
C. Ctrl+X
D. ctrl+K

Show Answer

Option B Explanation : Noen

Q4. Which shortcut command is used to run pyton script in Python IDLE
A. F3
B. F5
C. F1
D. F6

Show Answer

Option B. Explanation: None

Q5. What data type is the object below ? L = [1, 23, ‘hello’, 1]
A. List
B. Dictionary
C. Tuple
D. Array

Show Answer

Option A. Explanation: None

Q6. Which of the following function convert a string to a float in python?
A. str(x)
B. float(x)
C. int(x,base)
d. long(x,base)

Show Answer

Option B. Explanation : None

Q7. What is the output of the following program :
def myfunc(a):
a = a + 2
a = a * 2
return a

print myfunc(2)
A. 2
B. 16
C. 8
D. Indentation error

Show Answer

Option D Explanation : None

Q8. What is the output of the expression : 3*1**3
A. 3
B. 27
C. 9
D. 1

Show Answer

Option A. Explanation: ** has greater preference than *

Q9. What is the output of the following program :
i = 0
while i < 3: print(i, end=" ") i += 1 else: print(0) A. 0 1 2 3 B. 0 1 2 0 C. 0 1 2 D. Error [show_answer] Option B Explanation : 0 print when condition results in false. [/show_answer] Q10. What is the output of the following program : i = 0 while i < 5: print(i) i += 1 if i == 3: break else: print(0) A. 0 1 2 B. 0 1 2 3 C. None of the above D. Error [show_answer] Option A Explanation : Loop terminated when the value of i is 3 [/show_answer]

Related Posts

If you like CBSEToaday and would like to contribute, you can also write an article using submit article or mail your article to contribute@cbsetoday.com See your article appearing on the cbsetoday.com main page and help other students/teachers.