Revision Test 1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Revision Test Topic: Python Basics

Q1. Which of the following is not considered a valid identifier in Python? ( 1 mark questions)
(i)three3 (ii)_min (iii) hello_kv1 (iv) 2thousand

Q2.Which of the following is a mutable data type in Python:


(i)int (ii) string (iii)tuple (iv)list

Q3. Which of the following statements converts a tuple into a list in Python:
(i) len(tup) (ii) list(tup) (iii) tup(list) (iv) List(tup)

Q4. Name of the process of arranging sequence elements in a specified order.


i)indexing ii) slicing iii) sorting iv) traversing

Q5. What type of value is returned by input() function by default?


i)int ii) float iii) string iv)list

Q6. Which of the following operators cannot be used with string?


(i) + ii) * iii) - iv) All of these

Q7. If L = [0.5 * x for x in range(0,4)] then L is


i)[0,1,2,3] ii)[0,1,2,3,4] iii) [0.0,0.5,1.0,1.5] iv) [0.0,0.5,1.0,1.5,2.0]

Q8. Write the output of the following python code:


x = 123
for i in x:
print(i)
i)1 2 3 ii) 123 iii) infinite loop iv) Syntax Error

Q9. Write the output of following code.


A = 10/2
B = 10//3
print( A, B)
i)5, 3.3 ii) 5.0, 3.3 iii) 5.0, 3 iv) 5, 4

Q10. Name the built-in mathematical function / method that is used to return square root
of a number.
i)sqr() ii)sqrt() iii) sqt() iv) square()

Q11. Find the output of the following Python expressions: ( 2 marks)


a) (3-10**2+99/11) b) not 12 > 6 and 7 < 17 or not 12 < 4
c) 2 ** 3 ** 2 d) 7 // 5 + 8 * 2 / 4 – 3

Q12. i) Convert the following for loop into while loop. (2 marks)
for i in range(10,20,5):
print(i)

ii) >>>not False and True or False and True iii. s= “This is my book”
print(s.split(“is”,1))

Q.13. Rewrite the correct code and underline the corrections. (3 marks)
x = int((“enter the value”))
for i in range [0,11]:
if x = y
print x+y
else:
print x-y

You might also like