Ip Worsheet 1
Ip Worsheet 1
Section A
1. Rewrite the following Python code after removing all syntax errors. Underline each
correction done in the code.
Num = int (“Enter any Number: “)
Sum = 0
for I in range (10, Num, 3)
Sum+=i
if i%2==0:
print i*2
Else:
print i*3
2. How many time(s) the following loop will execute?
for x in range(-300, 300, 100):
print(x, end=” ”)
3. How many time(s) the following loop will execute?
for A in [15, 30, 50, 100]:
print(A,” % ”)
4. How many time(s) the following loop will execute?
for K in range(10):
print(K, end=”@”)
print(K*2, end=”\n”)
1
iii) for I in range(5, 20, 3):
print(I, end=” \t”)
iv) for K in range(200, 100, -30):
print(K, end=”\n”)
v) for J in range(50, 100, 15):
print(J*2, end=”*”)
else:
print(“Loop Ends…”)
6. How many time(s) the following loop will execute?
i) for J in range(101,125):
if J % 7 == 0 :
print(J)
ii) i=10
while i <50:
print(“Hello”)
i=i+5
Section B
7. Write a program to find factorial value of the given number.
8. Write a program to print the multiplication table of any number given by a user.
num = int(input("Enter the number : "))