Revision Worksheet
Revision Worksheet
Revision Worksheet
3. What error occurs when you execute the following Python code snippet?
apple = mango
a) SyntaxError
b) NameError
c) ValueError
d) TypeError
a) 30.0
b) 30.8
c) 28.4
d) 27.2
6. Select all options that print. hello-how-are-you
a. print(‘hello’, ‘how’, ‘are’, ‘you’)
b. print(‘hello’, ‘how’, ‘are’, ‘you’ + ‘-‘ * 4)
c. print(‘hello-‘ + ‘how-are-you’)
d. print(‘hello’ + ‘-‘ + ‘how’ + ‘-‘ + ‘are’ + ‘you’)
11. Which of the following statement is true for extend () list method?
a) adds element at last c) adds multiple elements at last
b) adds element at specified index d) adds elements at random index
Sum = 0
for k in range(5):
Sum = Sum+k
print(Sum)
Sum = 0
for k in range(10 , 1, -2):
Sum = Sum+k
print(Sum)
for k in range(4):
for j in range(k):
print(‘*’, end = ‘ ‘)
print()
5. How many times the following loop will execute? Justify your answer
A=0
while True:
print(A)
A =A+1
6. Give the output of the following. Also find how many times the loop will execute.
A=0
while A<10:
print(A, ‘ , ‘)
A =A+1
7. Give the output of the following. Also find how many times the loop will execute.
A=0
while A<10:
print(A, ‘ , ‘)
A =A+1
print(‘\n’, A)
10. What kind of error message will be generated if the following code is executed
A=5
B = ‘hi’
d = A+B
print(d)
S = ‘abcdefgh’
L = list(S)
print(L[1:4])
2. Write Python code to remove an element as entered by the user form the list, L
3. Create a list k, by selecting all the odd numbers within the given range, m and n. User input the values
of m , n at run time
4. Write Python code to create and add items to a dictionary. Ask the user to input key
value pairs. Continue as long as the user wishes.
5. Write Python code to find whether the given item is present in the given list using for
loop.
6. Create a list, L, with the squares of numbers from 0 to 10
7. Mr. Rahul wants created a dictionary to store the details of his students and to
manipulate thedata.
He wrote a code in Python, help him to complete the code:
studentDict = # stmt 1
n = int(input("How Many Students you Want To Input?"))
for i in range( ): # stmt 2 - to enter n number of students data
rollno = input("Enter Roll No:")
name = input("Enter Name:") physicsMarks =
int(input("Enter Physics Marks:"))
chemistryMarks = int(input("Enter Chemistry Marks:"))
mathMarks = int(input("Enter Maths Marks:"))
studentDict[rollno]= # stmt 3