Periodic Test-1 (Revision worksheet-1)
1. Which of the following is an invalid variable?
a. my_day_2 b. 2nd_day c. Day_two d. _2
2. What will be the output of following code?
X, Y=2,6
X, Y, X = Y, X*2, Y-2
print(X,Y, sep=”&”)
3. What will be the output of following code?
12 & 13
a) 12 b)13 c)12 & 13
4. Which are correct arithmetical operations?
a. a = 1*2
b. 2 = 1+1
c. 5 + 6 = y
d. Seven = 3 * 4
5. What will be the output of the following code?
a = 3 – 4 + 10
b=5*6
c = 7.0/8.0
print (a,b,c, sep=”,”)
a. 9,30,0 b. 9,30,1 c. 10,30,0
6. Names given to different parts of a Python program are __________
a. Identifiers b. functions c. Keywords d. literals
7. Data items having fixed value are called _________
a. Identifiers b. functions c. Keywords d. literals
8. Which of the following is/are correct ways of creating strings?
a. name = Jiya b. name = 'Jiya' c. name = "Jiya" d. name = (Jiya)
9. Which of the following is not a legal integer type value in Python?
a. Decimal b. Octal c. Hexadecimal d. Roman
10. Value 17.25 is equivalent to
a. 0.1725E-2 b. 0.1725E+2 c. 1725E2 d. 0.1725E2
11. Value 0.000615 is equivalent to
a. 615E3 b. 615E-3 c. 0.615E3 d. 0.615E-3
12. The lines beginning with a certain character, and which are ignored by a
compiler and not executed, are called ________
a. operators b. operands c. functions d. comments
13. Which of the following can be used to create comments?
a. // b. # c. ''' d. ''' . . . '''
14. To convert the read value through input( ) into integer type, ..........( ) is
used.
a. Floating b. float c. int d. integer
15. What is an expression and a statement ?
16. What do you understand by block/code block/suite in Python ?
17. What is Dynamic Typing feature of Python ?
18. What is the error in following code : X, Y = 7 ?
19. Following variable definition is creating problem X = 0281, find reasons.
20. What is the order of precedence in python?
a) Exponential, Parentheses, Multiplication, Division, Addition, Subtraction
b) Exponential, Parentheses, Division, Multiplication, Addition, Subtraction
c) Parentheses, Exponential, Multiplication, Addition, Division, Subtraction
d) Parentheses, Exponential, Multiplication, Division, Addition, Subtraction
21. What will be the output of the following Python code snippet if x=1?
x<<2
a) 4 b) 2 c) 1 d) 8
22. Which of the following is true for variable names in Python?
a) underscore and ampersand are the only two special characters allowed
b) unlimited length
c) all private members must have leading and trailing underscores
d) none of the mentioned
23. What are the values of the following Python expressions?
print(2**(3**2))
print((2**3)**2)
print(2**3**2)
a) 512, 64, 512
b) 512, 512, 512
c) 64, 512, 64
d) 64, 64, 64
24. Which of the following is the use of id() function in python?
a) Every object doesn’t have a unique id
b) Id returns the identity of the object
c) All of the mentioned
d) None of the mentioned
27. What will be the output of the following Python statement?
print("a"+"bc")
a) bc
b) abc
c) a
d) bca
28. Which one of the following is not a keyword in Python language?
a) pass
b) eval
c) assert
d) nonlocal
29. What is the output of the following code?
value = 2 + 3 * 4 / 2
print(value)
a. 4.5 b. 10.0 c. 8.0 d. 12.0
30. What is the value of result in the following code?
num = "8"
result = int(num) + 5
print(result)
a. 13 b. "85" c. 58 d. "13"
31. Find the output of the below python code:
str = "GFG"
print(not (not(str and "")))
a. GFG b. Empty String c. True d. False
32. Identify the data types of the values given below:
3, 3j, 13.0, ‘13’, “13”, 3+0j, 13, [3,13,2], (3,13,2)
33. What will be the output produced by these?
(a) 12/4 (b) 14/14 (c) 14%4
(d) 14.0/4 (e) 14.0//4 (f) 14.0%4
34. What will be the output of following code? Explain reason behind output of
every line:
a. 5 < 5 or 10
b. 5 < 10 or 5
c. 5 < (10 or 5)
d. 5 < (5 or 10)
35. What will be the output produced by following code statements?
(a) 87 // 5
(b) 87 // 5.0
(c) (87 // 5.0) == (87 // 5)
(d) (87 // 5.0) == int(87 / 5.0)
(e) (87 // int(5.0) == (87 // 5.0)
36. What will be the output produced by these code statement ?
(a) bool(int(‘0’))
(b) bool(str(0))
(c) bool(float(‘0.0’))
(d) bool(str(0.0))
37. How would you write xy in Python as an expression ?
a. x^y b. x**y c. x^^y d. none of these
38. Evaluate the expression given below if A = 16 and B = 15.
A % B // A
a. 0.0 b. 0 c. 1.0 d. 1
39. What is the value of x?
x = int(13.25 + 4/2)
a. 17 b. 14 c. 15 d. 23
40. Which of the following expressions results in an error?
a. float('12')
b. int('12')
c. float('12.5')
d. int('12.5')