Programming For Problem Solving Using Python
GITA, Autonomous College BHUBANESWAR
Module-II
Sl.N PO
Part-I (Short Answer Tyte Question) Module BL CO
o PSO
What will be the output of the following code?
if 4+5 == 10:
print(“TRUE”)
1 Mod-1
else:
print(“FALSE”)
print(“TRUE”)
Consider the following python program.
N=int(input(“Enter a number:”))
i,sum=1,0
while i<N:
2 if i%2==0: Mod-1
sum+=i
i+=1
print(sum)
What is the output when input value is 7 ?
3 Write difference between break and conitue. Mod-1
4 Explain the purpose of range() with example. Mod-1
5 Write for loop in python to print first 10 multiples of 4 in descending order. Mod-1
def show(msg):
msg=msg+” to Python”
print(msg)
6 s=” WELCOME” Mod-1
print(s)
show(s)
print(s)
Find output:
m=100
while True:
7 print(m) Mod-1
if(m<40) :
break
m-=30
8 What is a recursive function? Why is it used for? Mod-1
Rewrite following for loop using while loop
s=0
9 for n in range(20,1,-3): Mod-1
s+=n
print(s)
10 Find outpot: Mod-1
keepgoing=True
X=100
while keepgoing:
pint(x)
x=x-10
If x<50:
keepgoing=False
PO
[Link] Part-II (Focused Type Question) Module BL CO &
PSO
Find Output and also print how many times will the following loop is
executed?
a,b=2,50
while a<=10:
1. Mod1
a=a-1
b-=a
a=a-1
printf(“A=”,a ,”B=”, b)
Write a program to input 20 integer numbers and print number of even
2. Mod1
numbers and number of odd numbers.
Write a program to accept three sides of a triangle and print whether or
3. not it is an “EQUILATERAL” or “ISCOSCELES” or “SCALENE” Mod 1
triangle.
Write a nested for loop to print the following pattern
15 14 13 12 11
10 9 8 7
4. Mod 1
6 5 4
3 2
1
5. Explain loop else with an example. Mod1
PO
[Link] Part-III (Long Type Question) Module BL CO &
PSO
Write program to input name of a person and his/her annual income.
Calculate tax as per the following criteria:
Annual Income (in Rs) Tax
Upto 500000 Nil
500001-750000 10% of income exceeding 500000
1. Mod1
750000-1000000 25000+20%of income exceeding
750000
More than 1000000 50000 + 30% of income exceeding
1000000
Print name annual income and tax amount.
2. WA P to generate first n terms of Fibonacci Series. Mod1
0,1,1,2,3,5,8………n terms (Accept n as user input)
Write program to input a number and print whther or not it is a special
3. number. A number is said to be a special number if sum of factorial of its Mod1
digits is equal to the number itself. Eg. 145
Write a program to input 20 numbers and print those numbers which are
4. Mod1
prime.
Explain mandatory/Positional , Keyword/Named and Default arguments
5. Mod1
with suitable example.