Page 333 - AI Ver 1.0 Class 9
P. 333
D. Find the errors in the given code and rewrite the correct code:
1. x,y=10 2. y=int(input("Enter Y:")
a=input("enter number’) if y<10
print("number entered is,a) print('smaller")
a+5,b=10,20 else:
a=a+10 print(y)
print(a)
3. M=int(input("Enter M')) 4. str="book"
while M<10 i=0
if M=5: While i=<1:
print("Middle Value") print(str, sepa="%")
else: 1+=i
print(M)
M=+1
E. Rewrite the following logic:
1. Using while loop 2. Using for loop
for C in range(1,5,2): sum=0
print (C) i=20
print("Python") while i>10:
sum+=i
i-=2
print(sum)
F. Find the output of the given code:
1. A=10 2. I = 10; J = 50
for i in range(2, A, 2): if (I > 10 and J < 100):
print(A,i,sep='2',end='*') print(I, J)
else:
print(J)
3. for i in range(5):
if i%2==0:
print(i, end="*")
SECTION B (Subjective Type Questions)
A. Short answer type questions:
1. Name the two coding programs available in CodeCombat.
2. Why are flowcharts more preferred than algorithms?
3. Can we write more than one algorithm for the same problem? Explain.
4. What is the meaning of selection flow in control structures?
Introduction to Python 331

