You are on page 1of 3

Exercise

1. What do you understand by a character set?


2. What are variables?
3. What are float variables?
4. What is the extension of a Python Program?
5. Write the function of input () method.
6. Classify the following into valid and invalid identifiers:
• Mybook • Break
• -DK • My.book
7. Out of the following, find those identifiers, which cannot be used for naming Variables or
functions in a Python program:
Total * Tax, While, Class, Switch, 3rd Row, finally, Column 31, Total.
8. Out of the following, find the identifiers, which cannot be used for naming Variable or
Functions in a Python program:
_Cost, Price*Qty, float, switch, Address one, Delete, Number12, do
9. Give the output of the following
i) num=100.2
perc=num
print (int( perc))
ii) x=2
y=5.7
print(x+10*y)
print (“\n the value of y is”) x+10/y
iii) a=25+4-4
print(a)
10. Write a Python program that inputs a student’s marks obtained out of 600 and print the
percentage of marks.
11. What is the purpose of break statement?
12. What are the two ways to get out of a loop?
13. What is normal exit from a loop?
14. What is abnormal exit from a loop?
15. What are the differences between entry control loop and exit control loop?
16. What are the differences between break and continue statements?
17. What is the use of pass statement?
18. Write a program to check whether a number is prime or not.
19. Write a program to check whether a number is a palindrome or not.
20. Write a program to find the sum of the digits of the given number.
21. Name the Python Library modules which need to be imported to invoke the follwing
functions :

i.sqrt()
ii.dump()
iii.Uniform()
iv.fabs()

22. How many times will Python execute the code inside the following while loop?
i=1
while i < 10000 and i > 0:
print ("Hello ...")
i=2*i
23. Convert the following for loop into while loop,
for i in range (1,100):
if i % 4 == 2 :
print ( i,"mod", 4 , "= 2")
24. Convert the following while loop into for loop:
i=0
while i < 100:
if i % 2 == 0:
print (i, "is even")
else:
print(i, "is odd")
i =i+1

25. Write for statement to print the series 105, 98, 91,….7
26. Give the output of the following
i) num=100.2
perc=num
print (int(perc))
27. How many times will the following for loop execute and what’s the output?
i) for i in range(-1,7,-2):
for j in range(3):
print(i,j)
ii)for i in range(1,3,1):
for j in range(i+1):
print(‘*’)
28. Predict the output of the following codes:
i) x=10
y=5
for i in range(x-y*2):
print(“%”,i)
ii) x=10
y=0
while x>y:
print(x,y)
x=x-1
y=y+1

You might also like