Is Python case sensitive when dealing with identifiers?
A) Yes | B) No |
C) Machine dependent | D) None of the mentioned |
Is Python case sensitive when dealing with identifiers?
A) Yes | B) No |
C) Machine dependent | D) None of the mentioned |
What is the maximum possible length of an identifier?
A) 31 characters | B) 63 characters |
C) 79 characters | D) None of the mentioned |
Which of the following is invalid?
A) _a = 1 | B) __a = 1 |
C) __str__ = 1 | D) None of the mentioned |
Which of the following is an invalid variable?
A) my_string_1 | B) 1st_string |
C) foo | D) _ |
Why are local variable names beginning with an underscore discouraged?
A) they are used to indicate a private variables of a class | B) they confuse the interpreter |
C) they are used to indicate global variables | D) they slow down execution |
Which of the following is not a keyword?
A) eval | B) assert |
C) nonlocal | D) pass |
All keywords in Python are in _________
A) lower case | B) UPPER CASE |
C) Capitalized | D) None of the mentioned |
Which of the following is true for variable names in Python?
A) unlimited length | B) all private members must have leading and trailing underscores |
C) underscore and ampersand are the only two special characters allowed | D) none of the mentioned |
Which of the following is an invalid statement?
A) abc = 1,000,000 | B) a b c = 1000 2000 3000 |
C) a,b,c = 1000, 2000, 3000 | D) a_b_c = 1,000,000 |
Which of the following cannot be a variable?
A) __init__ | B) in |
C) it | D) on |
Which is the correct operator for power(xy)?
A) X^y | B) X**y |
C) X^^y | D) None of the mentioned |
Which one of these is floor division?
A) / | B) // |
C) % | D) None of the mentioned |
What is the order of precedence in python?
i) Parentheses
ii) Exponential
iii) Multiplication
iv) Division
v) Addition
vi) Subtraction
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 |
What is the answer to this expression, 22 % 3 is?
A) 7 | B) 1 |
C) 0 | D) 5 |
Mathematical operations can be performed on a string.
A) True | B) False |
Operators with the same precedence are evaluated in which manner ?
A) Left to Right | B) Right to Left |
C) Can’t say | D) None of the mentioned |
What is the output of this expression, 3*1**3 ?
A) 27 | B) 9 |
C) 3 | D) 1 |
Which one of the following has the same precedence level?
A) Addition and Subtraction | B) Multiplication, Division and Addition |
C) Multiplication, Division, Addition and Subtraction | D) Addition and Multiplication |
The expression Int(x) implies that the variable x is converted to integer.
A) True | B) False |
Which one of the following has the highest precedence in the expression?
A) Exponential | B) Addition |
C) Multiplication | D) Parentheses |
What is the output of print 0.1 + 0.2 == 0.3?
A) True | B) False |
C) Machine dependent | D) Error |
Which of the following is not a complex number?
A) k = 2 + 3j | B) k = complex(2, 3) |
C) k = 2 + 3l | D) k = 2 + 3J |
What is the type of inf ?
A) Boolean | B) Integer |
C) Float | D) Complex |
What does ~4 evaluate to ?
A) -5 | B) -4 |
C) -3 | D) +3 |
What does ~~~~~~5 evaluate to?
A) +5 | B) -11 |
C) +11 | D) -5 |
Which of the following is incorrect?
A) x = 0b101 | B) x = 0x4f5 |
C) x = 19023 | D) x = 03964 |
What is the result of cmp(3, 1)?
A) 1 | B) 0 |
C) True | D) False |
Which of the following is incorrect?
A) float(‘inf’) | B) float(‘nan’) |
C) float(’56’+’78’) | D) float(’12+34′) |
What is the result of round(0.5) – round(-0.5) ?
A) 1.0 | B) 2.0 |
C) 0.0 | D) Value depends on Python version |
What does 3 ^ 4 evaluate to ?
A) 81 | B) 12 |
C) 0.75 | D) 7 |
Which of the following statements assigns the value 25 to the variable x in Python:
A) x ← 25 | B) x = 25 |
C) int x = 25 | D) x << 25 |
In Python, a variable may be assigned a value of one type, and then later assigned a value of a different type:
A) False | B) True |
Which one of the following is the correct way of declaring and initializing a variable, x with the value 7 ?
A) x=7 | B) int x |
C) int x=7 | D) declare x=7 |
What will be the output of statement 2**2**2**2
A) 16 | B) 256 |
C) 32768 | D) 65536 |
Which of the following statement is False ?
A) Variable names can be arbitrarily long. | B) They can contain both letters and numbers. |
C) Variable name can begin with underscore. | D) Variable name can begin with number. |
What is the output of the following code: print 9//2
A) 4 | B) 4.5 |
C) 4.0 | D) Error |
Which of the following is not a valid variable name in Python?
A) _var | B) var_name |
C) var11 | D) 5var |
What is the maximum length of an identifier in python?
A) 32 | B) 31 |
C) 63 | D) None of the above |
Which of the following declarations is incorrect?
A) None Of the below | B) _x = 2 |
C) __x = 3 | D) __xyz__ = 5 |
What is the result of round(0.5) – round(-0.5)?
A) 1.0 | B) 2.0 |
C) 0 | D) None Of the above |
What is the result of executing the following code?
number = 5
while number <= 5:
if number < 5:
number = number + 1
print(number)
A) The program will loop indefinitely | B) The value of number will be printed exactly 1 time |
C) The while loop will never get executed | D) The value of number will be printed exactly 5 times |
What will the following code print ?
counter = 1
sum = 0
while counter <= 6:
sum = sum + counter
counter = counter + 2
print(sum)
A) 12 | B) 9 |
C) 7 | D) 8 |
What will be printed by the following code when it executes?
sum = 0
values = [1,3,5,7]
for number in values:
sum = sum + number
print(sum)
A) 4 | B) 0 |
C) 7 | D) 16 |
What is the last thing printed when the following code is run ?
number = 0
while number <= 10:
print("Number: ", number)
number = number + 1
A) Number: 10 | B) Number: number |
C Number: 0 | D) Number: 11 |
What does the following code print ?
output = ""
x = -5
while x < 0:
x = x + 1
output = output + str(x) + " "
print(output)
A) 5 4 3 2 1 | B) -4 -3 -2 -1 0 |
C) -5 -4 -3 -2 -1 | D) This is an infinite loop, so nothing will be printed |
What are the values of var1 and var2 that are printed when the following code executes ?
output = ""
var1 = -2
var2 = 0
while var1 != 0:
var1 = var1 + 1
var2 = var2 - 1
print("var1: " + str(var1) + " var2 " + str(var2))
A) var1 = -2, var2 = 0 | B) var1 = 0, var2 = -2 |
C) var1 = 0, var2 = -1 | D) This is an infinite loop, so nothing will be printed |
How many asterisks will be printed when the following code executes? for x in [0, 1, 2, 3]: for y in [0, 1, 2, 3, 4]: print('*')
A) 0 | B) 4 |
C) 5 | D) 20 |
The following code contains an infinite loop. Which is the best explanation for why the loop does not terminate ?
n = 10 answer = 1 while n > 0: answer = answer + n n = n + 1 print(answer)
A) n starts at 10 and is incremented by 1 each time through the loop, so it will always be positive. | B) answer starts at 1 and is incremented by n each time, so it will always be positive. |
C) You cannot compare n to 0 in the while loop. You must compare it to another variable. | D) In the while loop body, we must set n to False, and this code does not do that. |
Which type of loop can be used to perform the following iteration: You choose a positive integer at random and then print the numbers from 1 up to and including the selected integer.
A) a for-loop or a while-loop | B) only a for-loop |
C) only a while-loop | D) a for-loop And a while-loop |
Which of the following statements won’t be printed when this Python code is run?
for letter in 'Python': if letter == 'h': continue print('Current Letter : ' + letter)
A) Current Letter : P | B) Current Letter : t |
C) Current Letter : h | D) Current Letter : o |
for i in range(-3), how many times this loop will run ?
A) 0 | B) 1 |
C) Infinite | D) Error |
for i in [1,2,3]:, how many times a loop run ?
A) 0 | B) 1 |
C) 2 | D) 3 |
for loop in python are work on
A) range | B) iteration |
C) Both of the above | D) None of the above |
How many times it will print the statement ?, for i in range(100): print(i)
A) 101 | B) 99 |
C) 100 | D) 0 |
For loop in python is
A) Entry control loop | B) Exit control loop |
C) Simple loop | D) None of the above |
In which of the following loop in python, we can check the condition ?
A) for loop | B) while loop |
C) do while loop | D) None of the above |
It is possible to create a loop using goto statement in python ?
A) Yes | B) No |
C) Sometimes | D) None of the above |
To break the infinite loop , which keyword we use ?
A) continue | B) break |
C) exit | D) None of the above |
l=[],for i in l: print(l), what is the output ?
A) [] | B) list |
C) print() | D) None of the above |
What is the final value of the i after this, for i in range(3): pass
A) 1 | B) 2 |
C) 3 | D) 0 |
What is the value of i after the for loop ?, for i in range(4):break
A) 0 | B) 1 |
C) 3 | D) 2 |
What we put at the last of the loop ?
A) semicolon | B) colon |
C) comma | D) None of the above |
which of the following is consider as a infinite loop
A) while(infinte): | B) while(1): |
C) for(1): | D) None of the above |
Which of the following is Exit control loop in python ?
A) for loop | B) while loop |
C) do while loop | D) None of the above |
Which of the following is the loop in python ?
A)for | B) while |
C) do while | D) 1 and 2 |
Which of the following loop is not supported by the python programming language ?
A) for loop | B) while loop |
C) do while loop | D) None of the above |
Which of the following loop is work on the particular range in python ?
A) for loop | B) while loop |
C) do while loop | D) recursion |
While(0), how many times a loop run ?
A) 0 | B) 1 |
C) 3 | D) infinite |
while(1): print(2), How many times a loops run ?
A) 1 | B) 2 |
C) 3 | D) None of the above |
while(1==3):, how many times a loop run ?
A) 1 | B) infinite |
C) 3 | D) 0 |
Not a member yet? Register now
Are you a member? Login now