Page 261 - Ai_V1.0_Class9
P. 261
3. CodeCombat is a free coding educational game available on the internet. ……….……
4. Integers are used for mathematical calculations. ……….……
5. Python is easy to learn as a high-level programming language. ……….……
6. It is optional to specify colon(:) after writing a condition with the if statement. ……….……
7. Step value can be -ve or +ve in for loop. ……….……
8. Each value/element is separated by a comma in a list. ……….……
9. There are different ways of visiting each element of a list. ……….……
10. The append() can be used to append any value at any location in a list. ……….……
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="*")
Introduction to Python 259

