Flow of Control Quiz 5

Share with others

Welcome to your Flow of Control Quiz 5

Q41. Write 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

Q42. How many times the following loop will execute?

s1="flow of control in python"
for i in s1[1:5]:
print()

Q43. Write 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)

Q44. How many times "Hello" will print:

s=0
L = [2, 4, 6, 8, 10]
for i in range(len(L)-1):
     print("Hello")
print("Hello")

Q45. How many times "Hello" will print:

s=0
L = [2, 4, 6, 8, 10]
for i in range(len(L)):
    if L[i]//2==1:
        print("Hello")

Q46. Write the output of the following:

L = ["A","B","C","D","E"]
for i in range(len(L)-2):
    L.pop()
print(L)

Q47. Write 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')

Q48. 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)

Q49. Write the output of the following:

T=["flow","of","Control"]
T1=range(len(T))
for i in T1:
    print(T[i].upper(), end="-")

Q50. Write the output of the following:

d = [1, 2, 3]
for k in d:
   print(k, end = "+")
else:
   print("final")


Share with others

Leave a Reply

error: Content is protected !!