1. Which statement will check if a is equal to b ?
a. If a=b:
b. If a ==b:
c. If a===c:
d. If a==b
Ans : If a==b:
2. If a python program, a control structure :
a. Defines program specific data structures
b. Directs the order of execution of the statements in the program
c. Dictates what happens before the program starts and after it terminates
d. Manages the input and output of control characters
Ans : Directs the order of execution of the statements in the program
3. What signifies the end of a statement block or suite in python ?
a. A line that is indented less than the previous line
b. A comment
c. }
d. end
Ans : A line that is indented less than the previous line
4. What keyword would you use to add an alternative condition to an if statement ?
a. Else if
b. Elseif
c. Elif
d. None of the above
Ans : Elif
5. Which of the following is True regarding loops in Python ?
a. Loops should be ended with keyword "end"
b. No loop can be used to iterate through the elements of strings.
c. Keyword "break" can be used to bring control out of the current loop.
d. Keyword ''continue" is used to continue with the remaining statements inside the loop.
Ans : Keyword "break" can be used to bring control out of the current loop.
6. Which one of the following is a valid Python if statement :
a. If a>=2 :
b. If (a>=2)
c. If (a=> 22)
d. If a>= 22
Ans : If a>=2 :
7. Can we write if / else into one line in Python ?
a. Yes
b. No
c. If / else not used in python
d. None of the above
Ans : Yes
8. Does python have switch case statement ?
a. True
b. False
c. Python has switch statement but we can not use it.
d. None of the above
Ans : False
9. Which of the following is not used as loop in Python ?
a. For loop
b. While loop
c. Do- while loop
d. None of the above
Ans : Do-while loop
10. What will be the output of the following Python code ?
x = ['ab' , 'cd' ]
for i in x :
i.upper()
print(x)
a. ['ab' , 'cd' ]
b. ['AB' , 'CD']
c. [None, None]
d. None of the mentioned
Ans : ['ab' , 'cd' ]
11. What will be the output of the following Python code ?
i = 1
while True :
if i%2 == 0 :
break
print(i)
i +=2
a. 1
b. 1 2
c. 1 2 3 4 5 6.......
d. 1 3 5 7 9 11 ........
Ans : 1 3 5 7 9 11 .......
12. What will be the output of the following Python code ?
True = False
while True :
print( True )
break
a. True
b. False
c. None
d. None of the mentioned
Ans : None of the mentioned
13. What will be the output of the following Python code ?
i = 1
while True :
if i%3 ==0 :
break
print ( i )
i += 1
a. 1 2
b. 1 2 3
c. Error
d. None of the mentioned
Ans : Error
14. What will be the output of the following Python code ?
i = 1
while False :
if i%2 == 0 :
break
print ( i )
i += 2
a. 1
b. 1 3 5 7 ......
c. 1 2 3 4 ......
d. None of the mentioned
Ans : None of the mentioned
15. What will be the output of the following Python code ?
x = [ 'ab' , 'cd' ]
for i in x :
x.append (i. upper())
print( x )
a. ['AB' , 'CD']
b. ['ab' , 'cd' , 'AB' ,'CD' ]
c. ['ab' , 'cd' ]
d. None of the mentioned
Ans : None of the mentioned
0 Comments