WORKSHEET
FLOW OF CONTROL
Q1. What is the difference between else and elif construct of if statement?
Q2. . Write the output of the following if a = 9
if (a > 5 and a <=10):
print("Hello")
else:
print("Bye")
Q3. What will be the output of the following code fragment? I) if a = 25 ii) a=12 iii) if a=48
if ( a % 3 == 0):
if(a % 4 ==0):
b = a * 10
else:
if(a%8 ==0):
b = a + 50
else:
b = a * 20
print(“Result”, b)
Q4. What is the error in the following code? Correct the code.
a, b = 30, 15
if a%3 = 0 :
c=b*3
print(“Result = ”,c)
Elif a%5 == 0
d=b*5
Print(“Result = “,d)
else:
f==d*10
print(“Result = “,f)
Q5. Find the errors in the code given below and correct the code:
x=25
if d==1
y==x*2
elif : d==2
y=x*3
elif
d==3:
y=x*20
else
y=x*50
print(“Value Y = ”,y)
Q6. What gets printed with the following code?
X=True
Y=False
Z=False
if X or Y and Z:
print (“Yes”)
else:
print (“No”)
Q7. What will the program print if the user provides the following input?
(a) 3 (b) 21 (c) 17 (d) 5 (e) -5
val = eval(input())
if val < 10:
if val != 5:
print(“Wow ”, end=’ ’)
else:
val += 1
else:
if val == 17:
val += 10
else:
print(“Well “, end=’ ’)
print(val)
Q8. Find the output of the following codes.
a.
x=3
if x>2 or x<5 and x==6:
print("ok")
else:
print("no output")
b.
x=50
if x>10:
if x>25:
print("ok")
if x>60:
print("good")
elif x>40:
print("average")
else:
print("no output")
Q9. Evaluate the following statements:
a=True
b=True
c=True
d=True
i. print(not a or b or c )
ii. print(not (a and b and c))
iii. print(not (a or b or c) )
iv. print(not a and not b and not c)
v. print(not a or not b or not c )
vi. print(not (not a or not b or not c))
Q10. Do the following :
1. Write a Python program to check whether a No. is Odd or Even or not.
2. Write a Python program to check whether a No. is multiple of 5 or not.
3.. Write a Python program to check whether a No. is divisible by 8 or not.
4. Write a Python program to find out who is elder person in 2 different persons.
5. Write a Python program to check a character is vowel or not.
6. Write a Python program to input an arithmetic operator and two numbers and perform the
operation based on the input operator.
7. Write a Python program to print the Income, Tax & Surcharge of Employ. The Tax and Surcharge
based on the following conditions.
Income Tax % Surcharge
< Rs. 15000 15% 7%
Rs. 15001 to Rs. 20000 18% 11%
Above Rs. 21000 20% 13%
[Total Income =Income- Tax-Surcharge]
[Tax=Income< Tax_percentage >)/100].
Display all information like Income, Tax & Surcharge .
8. Write a Python program to get input distance and print fare for the passenger according to:
DISTANCE FARE (in Rs.)
Upto 20km 10 P/Km
Next 20km 7 P/Km
Above 6 P/Km
9. Write a Python program to input a basic salary of an employee and calculate the Special Incentive
based on the following criteria:
Basic Salary Special Incentive
Less than 10000 15 % of Basic Salary
Between 10000 and 19999 25 % of Basic Salary
Between 20000 and 49999 35 % of Basic Salary
Otherwise 50 % of Basic Salary
10. Write a program to input 3 sides of a triangle (in cm) and print whether it is a scalene or isosceles
or equilateral triangle.