For Loop
For Loop
6. Which of the following symbols is used in Python to mean "Not equal to"?
a) ==
b) !=
c) <>
d) ><
7. Which of the following symbols is used in Python to mean "Greater than or equal to"?
a) <=
b) >>
c) >=
d) =>
8. In a Python program, what would be the iteration variable (looping variable) in the FOR LOOP
code?
n=6
value=0
for n1 in range(1,50,3):
n=n+value
value=value+5
print(n)
a) n1
b) n
c) value
d) i
9. a=5
b=10
for c in range(5,100,5):
num=a+b
print(num)
a) 60
b) 100
c) 10
d) 20
10. In a Python program, what would be the increment value for the looping variable in the FOR
LOOP code?
n=7
n1=50
for a in range(15):
print(a)
a) 15
b) 7
c) 10
d) 1
11. In a Python program, what would be the increment value for the looping variable in the FOR
LOOP code?
f=100
t=0
s=5
for a in range(f,t,-s):
print(a)
a) 100
b) 1
c) 5
d) -5
12. In a Python program, how many outputs will occur for the snippet of code?
g=15
for a in range(0,g,3):
print(a)
a) 15
b) 3
c) 6
d) 5
t=0
for i in range(0,3):
for j in range(3,5):
t+=i-j
print(t)
a) 18
b) 25
c) 10
d) 15
14. t=0
for i in range(0,5):
t=i______
print(t)
Ans=6.0
a) (* 3 / 2)
b) (+ 1)
c) (/ 0.5)
d) (+ 3* (1/ 2))
print(str(i) * i)
a) 1 2 3 4 5
b)
12
123
1234
12345
c)
22
333
4444
55555
d)
1
if i%3==0:
i=0
else:
i=1
print(i)
a) 1, 0, 1, 1, 0, 1, 1, 1, 1, 1
b) 0, 1, 1, 0, 1, 1, 0, 1, 1, 0
c) 0, 1, 1, 0, 1
d) 0, 1, 1, 0, 1, 1, 0, 1, 1, 0