Chapter 1
Chapter 1
1
21. Which of the following is not a decision making statement
i. if..else statement ii. for statement iii. if-elif statement iv. if statement
22. …………loop is the best choice when the number of iterationsare known.
i. while ii. do-while iii. for iv. None of these
23. How many times will the following code be executed.a=5while a>0: print(a) print(“Bye”)
i. 5 times ii. Once iii. Infinite iv. None of these
24. What abandons the current iteration of the loop
i. continue ii. stop iii. infinite iv. Break
25. Find the output of the following python program for i in range(1,15,4): print(i, end=’,’)
i. 1,20,3 ii. 2,3,4 iii. 1,5,10,14 iv. 1,5,9,13
26. …………loop is the best when the number of iterations are notknown.
i. while ii. do-while iii. for iv. None of these
27. In the nested loop ……………..loop must be terminated before the outer loop.
i. Outer ii. enclosing iii. inner iv. None of these
28. …………..statement is an empty statement in python.
i. pass ii. break iii. continue iv. If
29. How many times will the following code be executedfor i in range(1,15,5): print(i,end=’,’)
i. 3 ii. 4 iii. 1 iv. Infinite
30. Symbol used to end the if statement:
i. Semicolon(;) ii. Hyphen(-) iii. Underscore( _ ) iv. colon(:)
PART – B
ERROR FINDING QUESTIONS
Q1. Find error in the following code(if any) and correct code by rewriting code and
underline the correction;‐
x= int(“Enter value of x:”) for in
range [0,10]:
if x=y print( x + y)
else: print( x‐y)
Q2. Rewrite the following program after finding and correcting syntactical errors and
underlining it.
a, b = 0
if (a = b)
a +b =c print( z)
Q3. Rewrite the following code in python after removing all syntax error(s). Underline each
correction done in the code.
250 = Number
WHILE Number<=1000:
if Number=>750 print
(Number)
Number=Number+100
else
print( Number*2)
Number=Number+50
2
Q4. Rewrite the following code in python after removing all syntax error(s). Underline each
correction done in the code.
25=Val
for I in the range(0,Val) if I
%2==0:
print( I+1)
Else:
print (I-1)
Q5. Rewrite the following code in python after removing all syntax error(s). Underline each
correction done in the code.
STRING=""WELCOME NOTE""
for S in range[0,8]:
print (STRING(S))
Q6. Rewrite the following code in python after removing all syntax error(s). Underline each
correction done in the code.
a=int{input("ENTER FIRST NUMBER")}
b=int(input("ENTER SECOND NUMBER"))
c=int(input("ENTER THIRD NUMBER"))
if a>b and a>c
print("A IS GREATER")
if b>a and b>c:
Print(" B IS GREATER")
if c>a and c>b:
print(C IS GREATER)
Q7. Rewrite the following code in python after removing all syntax error(s). Underline each
correction done in the code.
i==1
a=int(input("ENTER FIRST NUMBER"))
FOR i in range[1, 11];
print(a,"*=", i ,"=",a * i)
Q8. Rewrite the following code in python after removing all syntax error(s). Underline each
correction done in the code.
a=”1”
while a>=10:
print("Value of a=",a) a=+1
Q9. Rewrite the following code in python after removing all syntax error(s). Underline each
correction done in the code.
Num=int(rawinput("Number:")) sum=0
for i in range(10,Num,3)
Sum+=1 if i
%2=0:
print(i*2) Else:
print(i*3 print Sum)
3
Q10. Rewrite the following code in python after removing all syntax error(s). Underline each
correction done in the code.
weather='raining' if
weather='sunny':
print("wear sunblock") elif
weather='snow':
print("going skiing")
else:
print(weather)
Q11. Write the modules that will be required to be imported to execute the following code in
Python.
def main( ):
for i in range (len(string)) ):
if string [i] = = ‘’ “
print
else:
c=string[i].upper()
print( “string is:”,c)
print (“String length=”,len(math.floor()))
Q12. Observe the following Python code very carefully and rewrite it after removing all
syntactical errors with each correction underlined.
DEF execmain():
x = input("Enter a number:") if
(abs(x)=x):
print ("You entered a positive number") else:
x=*‐1
print "Number made positive:"x execmain()
Q13. Rewrite the following code in python after removing all syntax error(s). Underline each
correction done in the code.
30=To
for K in range(0,To)
IF k%4==0:
print (K*4)
else
print (K+3)
4
OUTPUT FINDING QUESTIONS