22PLC15B - Introduction to Python Programming
Question bank for 1st Internal Assessment
1. What are variables? Give examples. List the rules to select the valid names for variables.
2. Write a Python program to do the following:
a) Read the name of the user and display the number of characters in the name entered by the user.
b) Read the age of the user and display the year of his birth.
3. Explain different Data-Types of Python, with example for each.
4. Explain the following functions with examples for each:
a) input()
b) int()
c) float()
5. Explain different comparison operators and Boolean operators with examples.
6. Explain the following with examples:
a) if-else
b) if-elif-else
c) Break and Continue
7. Implement project: Guess the Number
8. Implement Project: Username and Password Authentication
9. What do the following expressions evaluate to?
a) (5 > 4) and (3 == 5)
b) not (5 > 4)
c) (5 > 4) or (3 == 5)
d) not ((5 > 4) or (3 == 5))
e) (True and True) and (True == False)
f) (not False) or (not True)
10. Write code that prints Hello if 1 is stored in spam, prints Howdy if 2 is stored in spam, and prints
Greetings! if anything else is stored in spam.
11. How many iterations will be there for the following range in for loop:
a) range(10)
b) range(2,10)
c) range(2,10,2)
d) range(0,22,3)
e) range(30,-1,-1)
f) range(20,5,-2)
12. Write a short program that prints the numbers 1 to 10 using a for loop. Then write an equivalent program
that prints the numbers 1 to 10 using a while loop.
13. If you had a function named bacon() inside a module named spam, how would you call it after importing
spam?
14. What statement creates a function?
15. What is a return value? Can a return value be part of an expression?
16. How would you assign the value 'hello' as the third value in a list stored in a variable named spam?
(Assume spam contains [2, 4, 6, 8, 10].)
17. Explain the following functions with examples:
a) insert()
b) index()
c) append()
d) pop()
e) del()
f) remove()
18. What are the operators for list concatenation and list replication?
19. What are two ways to remove values from a list?
20. What is the difference between the append() and insert() list methods?