Review each question and reveal answers to strengthen your understanding
1Which of the following is not a conditional statement in Python?
✅ Correct Answer: 4
2Which of the following symbol is used to end an ‘if’ statement in Python?
✅ Correct Answer: 2
3Write the output of the following :
x = 10
if x > 7 and x <= 10:
print("Pass", end="")
print("Fail")
✅ Correct Answer: 4
4Which of the following value of ‘x’ makes the condition False in the given code?
✅ Correct Answer: 3
5Write the output of the following :
if 'i' == "i" :
print(True)
else:
print("False")
✅ Correct Answer: 1
6Write the output of the following:
if (3+8//2 != 7):
print("H")
else:
print("B")
✅ Correct Answer: 2
7Write the output of the following:
a=5
b=6
c=7
d=8
if a > b:
if c > a:
if d < c:
print("Hello")
else:
print("B")
else:
print("A")
print("What")
✅ Correct Answer: 1
8Write the output of the following:
a=15
b=6
c=7
d=8
if a > b:
if c > a:
if d < c:
print("Hello")
else:
print("B")
else:
print("A")
✅ Correct Answer: 1
9Repetition of a set of statements in a program is made possible using _____
✅ Correct Answer: 3
10The statements in a loop are executed repeatedly as long as particular condition ___
✅ Correct Answer: 1
11Condition in loops is checked based on the value of a variable called the ___
✅ Correct Answer: 2
12When the condition in loops becomes false, the loop _________
✅ Correct Answer: 1
13If the condition given in the loop never return False then the loop ______
✅ Correct Answer: 1
14Write the output of the following code :
for i in range(5):
print(i)
✅ Correct Answer: 1
15Write the output of the following code :
for i in (1,2,3):
print(i)
✅ Correct Answer: 1
16Write the output of the following code :
for i in (2,3,4):
print("i")
✅ Correct Answer: 3
17Write the output of the following code :
for i in range(10,2,-2):
print(i, "Hello")
✅ Correct Answer: 1
18Write the output of the following code :
str = "Python Output based Questions"
word=str.split()
for i in word:
print(i)
✅ Correct Answer: 1
19 Write the output of the following code :
for i in range(7,10):
print("Flow of control in Python")
print("Flow of control in Python")
✅ Correct Answer: 1
20Write the output of the following code :
for i in range(7,-2,-9):
for j in range(i):
print(j)
✅ Correct Answer: 1
21Write the output of the following code :
i="9"
for k in i:
print(k)
✅ Correct Answer: 2
22Write the output of the following code :
for i in range(1, 8):
print(i)
i+=2
✅ Correct Answer: 1
23 Write the output of the following code :
for i in range(4, 7):
i=i+3
print("Hello")
✅ Correct Answer: 1
24Write the output of the following code :
for i in range(4,7):
i=i+3
print("Hello", i)
✅ Correct Answer: 2
25Write the output of the following code :
i=4
while(i<10):
i=i+3
print(i)
✅ Correct Answer: 1
26Write the output of the following code :
for i in range(20):
if i//4==0:
print(i)
✅ Correct Answer: 1
27Write the output of the following code :
x=1234
while x%10:
x=x//10
print(x)
✅ Correct Answer: 2
28Write the output of the following code :
for i in 1,2,3:
print(i*i)
✅ Correct Answer: 1
29Write the output of the following code :
for i in 2,4,6:
print("H"*i)
✅ Correct Answer: 2
30Write the output of the following code :
p=10
q=20
p=p*q//4
q=p+q**3
print(p,q)
✅ Correct Answer: 1
31Write the output of the following code :
x=2
y=6
x=x+y/2 + y//4
print(x)
✅ Correct Answer: 2
32Write the output of the following :
a = 7
for i in 7:
print(a)
✅ Correct Answer: 1
33Write the output of the following code :
a = "AMIT"
for i in range(len(a)):
print(a)
✅ Correct Answer: 3
34A
M
I
T
✅ Correct Answer: 1
35 Write the output of the following code :
print(range (5, 0, -2))
✅ Correct Answer: 1
36Write the output of the following code :
for i in range(0,2,-1):
print("Hello")
✅ Correct Answer: 3
37Write the output of the following code :
s1="csiplearninghub.com"
s2=""
s3=""
for x in s1:
if(x=="s" or x=="n" or x=="p"):
s2+=x
print(s2,end=" ")
print(s3)
✅ Correct Answer: 1
38Write the output of the following code :
s1="csiplearninghub.com"
c=0
for x in s1:
if(x!="l"):
c=c+1
print(c)
✅ Correct Answer: 4
39Write the output of the following code :
j=12
c=9
while(j):
if(j>5):
c=c+j-2
j=j-1
else:
break
print(j, c)
✅ Correct Answer: 2
40Write the output of the following code :
L = [13 , 12 , 21 , 16 , 35 , 7, 4]
sum = 5
sum1 = 3
for i in L:
if (i % 4 == 0):
sum = sum + i
continue
if (i % 7 == 0):
sum1 = sum1 + i
print(sum , end=" ")
print(sum1)
✅ Correct Answer: 1
41Write the output of the following code :
print('cs' + 'ip' if '234'.isdigit( ) else 'IT' + '-402')
✅ Correct Answer: 3
42Write the output of the following:
a=10
while a>5:
if a%7==0:
print(a**2,end='@')
else:
print(a-1,end='@')
a=a-3
✅ Correct Answer: 2
43How many times the following loop will execute?
s1="flow of control in python"
for i in s1[1:5]:
print()
✅ Correct Answer: 2
44Write the output of the following:
s=0
L = [2, 4, 6, 8, 10]
for i in range(1,len(L),1):
s = s + L[i]
print(s)
✅ Correct Answer: 1
45How many times “Bye†will print:
s=0
L = [2, 4, 6, 8, 10]
for i in range(len(L)):
if L[i]//2==1:
print("Bye")
✅ Correct Answer: 4
46How many times “Bye†will print:
s=0
L = [2, 4, 6, 8, 10]
for i in range(len(L)):
if L[i]//2==1:
print("Bye")
✅ Correct Answer: 3
47Write the output of the following:
def ch(st):
str =""
for i in range(1,4):
if i%2==0:
str=str+st[i]
elif st[i].lower():
str = str + st[i-1]
else:
str=str+st[i]
print('-'. join (str))
ch('flow')
✅ Correct Answer: 1
48 Write the output of the following:
st1="Flow91"
st2="gun"
I=0
while I<len(st1):
if st1[I]>="a" and st1[I]<="z":
st2=st2+st1[I+1]
elif st1[I]>="0" and st1[I]<="9":
st2=st2+st1[I-1]
else:
st2=st2+"?"
I=I+1
print(st2)
✅ Correct Answer: 2
49Write the output of the following:
T=["flow","of","Control"]
T1=range(len(T))
for i in T1:
print(T[i].upper(), end="-")
✅ Correct Answer: 1
50 FLOWOFCONTROL
✅ Correct Answer: 3
51 Syntax of ‘for’ loop is given below:
for < _________ > in <sequence/ items in range>:
✅ Correct Answer: 1
52 Which of the following statement is not correct about ‘for’ loop?
✅ Correct Answer: 4
53________ function is used in for loops for generating a sequence of numbers.
✅ Correct Answer: 3
54 Which of the following parameter of range( ) function is optional?
✅ Correct Answer: 3
55______ statement terminates the current loop and resumes execution of the statement following that loop.
✅ Correct Answer: 2
56____________ statement skips the execution of remaining statements inside the body of the loop for the current iteration and jumps to the beginning of the loop for the next iteration
✅ Correct Answer: 1
57A loop inside another loop is called ______
✅ Correct Answer: 2
58If the condition of the while loop is initially false, then the loop will execute ___
✅ Correct Answer: 4
59Write the output of the following :
for x in range(1,4):
for y in range(2,5):
if x * y > 10:
break
print (x * y, end=" ")
✅ Correct Answer: 2
60Write the output of the following:
var = 7
while var > 0:
print ('Current variable value: ', var)
var = var -1
if var == 3:
break
else:
if var == 6:
var = var -1
continue
print ("Good bye!")
✅ Correct Answer: 1
61Execution of which statement is not dependent on the condition?
if i <=4 :
print("Hello") #Statement 1
print("How") #Statement 2
else:
print("are") #Statement 3
print("You") #Statement 4
✅ Correct Answer: 4
62Which of the following statement will return error?
✅ Correct Answer: 3
63How many times the following loop will execute?
a = [10, 11, 12, 13, 45]
for a[3] in a:
print("Flow")
✅ Correct Answer: 1
64Write the output of the following:
for l in range(3):
if l == 2:
continue
else:
print("i",end = " ")
else:
print("Here")
✅ Correct Answer: 2
65Which of the following is an empty statement in python?
✅ Correct Answer: 1
66 Which of the following is jump statement in python?
✅ Correct Answer: 4
67Which symbol is used to end loop and conditional statements?
✅ Correct Answer: 3
68Write the output of the following:
St="Amit"
for i in St:
St.swapcase()
print(St)
✅ Correct Answer: 1
69What will be the value of ‘m’ and ‘n’ after execution of following code:
m = 3;
for n in range(2, 7, 2):
n *= m
n = n-1
✅ Correct Answer: 2
70What will be the value of ‘n’ and ‘n1’ after execution of following code:
n1=10
for n in range(10, 12):
n1=n ** 2
n1=n1-10
✅ Correct Answer: 2
71What will be the value of ‘n’ and ‘n1’ after execution of following code:
n1=10
for n in range(10, 12):
n1=n ** 2
n1=n1-10
✅ Correct Answer: 2
72Write the output of the following:
k = 5
sk = 0;
while k <= 12:
sk = sk + k
k = k + 4
print(sk, k)