Hahahaha Python Questions - Variable Names
Hahahaha Python Questions - Variable Names
a) i,ii,iii,iv,v,vi
b) ii,i,iii,iv,v,vi
c) ii,i,iv,iii,v,vi
d) i,ii,iii,iv,vi,v
9. The expression Int(x) implies that the variable x is converted to integer. State whether true
or false.
a) True
b) False
10. Which one of the following has the highest precedence in the expression?
a) Exponential
b) Addition
c) Multiplication
d) Parentheses
Python Questions and Answers – Core Data types
This set of Python Multiple Choice Questions & Answers (MCQs) focuses on “Core Data
Types”.
2. Given a function that does not return any value, What value is thrown by default when
executed in shell.
a) int
b) bool
c) void
d) None
3. Following set of commands are executed in shell, what will be the output?
>>>str="hello"
>>>str[:2]
>>>
a) he
b) lo
c) olleh
d) hello
.
5. What is the return type of function id?
a) int
b) float
c) bool
d) dict
6. In python we do not specify types,it is directly interpreted by the compiler, so consider the
following operation to be performed.
>>>x = 13 ? 2
objective is to make sure x has a integer value, select all that apply (python 3.xx)
a) x = 13 // 2
b) x = int(13 / 2)
c) x = 13 % 2
d) All of the mentioned
def example(a):
a = a + '2'
a = a*2
return a
>>>example("hello")
a) indentation Error
b) cannot perform mathematical operation on strings
c) hello2
d) hello2hello2
10. In order to store values in terms of key and value we use what core data type.
a) list
b) tuple
c) class
d) dictionary
13. What is the average value of the code that is executed below ?
>>>grade1 = 80
>>>grade2 = 90
>>>average = (grade1 + grade2) / 2
a) 85.0
b) 85.1
c) 95.0
d) 95.1
8.
. Which of the following is incorrect?
a) float(‘inf’)
b) float(‘nan’)
c) float(’56’+’78’)
d) float(’12+34′)
1. The value of the expressions 4/(3*(2-1)) and 4/3*(2-1) is the same. State whether true or
false.
a) True
b) False
A % B // A
a) 0.0
b) 0
c) 1.0
d) 1
4. Which of the following operators has its associativity from right to left?
a) +
b) //
c) %
d) **
x = int(43.55+2/2)
a) 43
b) 44
c) 22
d) 23
2+4.00, 2**4.0
a) (6.0, 16.0)
b) (6.00, 16.00)
c) (6, 16)
d) (6.00, 16.0)
2**(3**2)
(2**3)**2
2**3**2
a) 64, 512, 64
b) 64, 64, 64
c) 512, 512, 512
d) 512, 64, 512
8/4/2, 8/(4/2)
a) (1.0, 4.0)
b) (1.0, 1.0)
c) (4.0. 1.0)
d) (4.0, 4.0)
float(22//3+3/3)
a) 8
b) 8.0
c) 8.3
d) 8.33
print(4.00/(2.0+2.0))
a) Error
b) 1.0
c) 1.00
d) 1
X = 2+9*((3*12)-8)/10
a) 30.0
b) 30.8
c) 28.4
d) 27.2
24//6%3, 24//4//2
a) (1,3)
b) (0,3)
c) (1,0)
d) (3,1)
5. Which among the following list of operators has the highest precedence?
float(4+int(2.39)%2)
a) 5.0
b) 5
c) 4.0
d) 4
4+2**5//10
a) 3
b) 7
c) 77
d) 0
10. The expression 2**2**3 is evaluates as: (2**2)**3. State whether this statement is true or
false.
a) True
b) False
Syke boiiiiiiiiiiiiiiiiiiiii