Quiz
phyton
Erstelle ein kostenloses Konto, um dieses Quiz zu beenden
Speichere deinen Fortschritt und sieh dir dein Endergebnis an.
oder mit deiner E-Mail registrieren
Schon ein Konto? Anmelden
Fragen in diesem Quiz (102)
1This set of Python Multiple Choice Questions & Answers (MCQs) focuses on “Variable Names”.
- Aa) yes
- Bb) no
- Cc) machine dependent
- Dd) none of the mentioned
2What is the maximum possible length of an identifier?
- Aa) 31 characters
- Bb) 63 characters
- Cc) 79 characters
- Dd) none of the mentioned
3Which of the following is invalid?
- Aa) _a = 1
- Bb) __a = 1
- Cc) __str__ = 1
- Dd) none of the mentioned
4Which of the following is an invalid variable?
- Aa) my_string_1
- Bb) 1st_string
- Cc) foo
- Dd) _
5Why are local variable names beginning with an underscore discouraged?
- Aa) they are used to indicate a private variables of a class
- Bb) they confuse the interpreter
- Cc) they are used to indicate global variables
- Dd) they slow down execution
6Which of the following is not a keyword?
- Aa) eval
- Bb) assert
- Cc) nonlocal
- Dd) pass
7All keywords in Python are in _________
- Aa) lower case
- Bb) UPPER CASE
- Cc) Capitalized
- Dd) None of the mentioned
8Which of the following is true for variable names in Python?
- Aa) unlimited length
- Bb) all private members must have leading and trailing underscores
- Cc) underscore and ampersand are the only two special characters allowed
- Dd) none of the mentioned
9 Which of the following is an invalid statement?
- Aa) abc = 1,000,000
- Bb) a b c = 1000 2000 3000
- Cc) a,b,c = 1000, 2000, 3000
- Dd) a_b_c = 1,000,000
10 Which of the following cannot be a variable?
- Aa) __init__
- Bb) in
- Cc) it
- Dd) on
11 Which is the correct operator for power(xy)?
- Aa) X^y
- Bb) X**y
- Cc) X^^y
- Dd) None of the mentioned
122. Which one of these is floor division?
- Aa) /
- Bb) //
- Cc) %
- Dd) None of the mentioned
13What is the order of precedence in python?
i) Parentheses
ii) Exponential
iii) Multiplication
iv) Division
v) Addition
vi) Subtraction- Aa) i,ii,iii,iv,v,vi
- Bb) ii,i,iii,iv,v,vi
- Cc) ii,i,iv,iii,v,vi
- Dd) i,ii,iii,iv,vi,v
14What is the answer to this expression, 22 % 3 is?
- Aa) 7
- Bb) 1
- Cc) 0
- Dd) 5
15Mathematical operations can be performed on a string.
- Aa) True
- Bb) False
16Operators with the same precedence are evaluated in which manner?
- Aa) Left to Right
- Bb) Right to Left
- Cc) Can’t say
- Dd) None of the mentioned
17What is the output of this expression, 3*1**3?
- Aa) 27
- Bb) 9
- Cc) 3
- Dd) 1
18Which one of the following has the same precedence level?
- Aa) Addition and Subtraction
- Bb) Multiplication, Division and Addition
- Cc) Multiplication, Division, Addition and Subtraction
- Dd) Addition and Multiplication
19The expression Int(x) implies that the variable x is converted to integer.
- Aa) True
- Bb) False
20Which one of the following has the highest precedence in the expression?
- Aa) Exponential
- Bb) Addition
- Cc) Multiplication
- Dd) Parentheses
21 Which of these in not a core data type?
- Aa) Lists
- Bb) Dictionary
- Cc) Tuples
- Dd) Class
22Given a function that does not return any value, What value is thrown by default when executed in shell.
- Aa) int
- Bb) bool
- Cc) void
- Dd) None
23What will be the output of the following Python code?
>>>str="hello"
>>>str[:2]
>>>- Aa) he
- Bb) lo
- Cc) olleh
- Dd) hello
24Which of the following will run without errors?
- Aa) round(45.8)
- Bb) round(6352.898,2,5)
- Cc) round()
- Dd) round(7463.123,2,1)
25What is the return type of function id?
- Aa) int
- Bb) float
- Cc) bool
- Dd) dict
26 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)- Aa) x = 13 // 2
- Bb) x = int(13 / 2)
- Cc) x = 13 % 2
- Dd) All of the mentioned
27What error occurs when you execute the following Python code snippet?
apple = mango- Aa) SyntaxError
- Bb) NameError
- Cc) ValueError
- Dd) TypeError
28 What will be the output of the following Python code snippet?
def example(a):
a = a + '2'
a = a*2
return a
>>>example("hello")- Aa) indentation Error
- Bb) cannot perform mathematical operation on strings
- Cc) hello2
- Dd) hello2hello2
29What data type is the object below?
L = [1, 23, 'hello', 1]- Aa) list
- Bb) dictionary
- Cc) array
- Dd) tuple
30In order to store values in terms of key and value we use what core data type.
- Aa) list
- Bb) tuple
- Cc) class
- Dd) dictionary
31Which of the following results in a SyntaxError?
- Aa) ‘”Once upon a time…”, she said.’
- Bb) “He said, ‘Yes!'”
- Cc) ‘3\’
- Dd) ”’That’s okay”
32The following is displayed by a print function call. Select all of the function calls that result in this output.
tom
dick
harry- Aa)
print('''tom
\ndick
\nharry''') - Bb) print(”’tomdickharry”’)
- Cc) print(‘tom\ndick\nharry’)
- Dd)
print('tom
dick
harry')
- Aa)
33What is the average value of the following Python code snippet?
>>>grade1 = 80
>>>grade2 = 90
>>>average = (grade1 + grade2) / 2- Aa) 85.0
- Bb) 85.1
- Cc) 95.0
- Dd) 95.1
34Select all options that print.
hello-how-are-you- Aa) print(‘hello’, ‘how’, ‘are’, ‘you’)
- Bb) print(‘hello’, ‘how’, ‘are’, ‘you’ + ‘-‘ * 4)
- Cc) print(‘hello-‘ + ‘how-are-you’)
- Dd) print(‘hello’ + ‘-‘ + ‘how’ + ‘-‘ + ‘are’ + ‘you’)
35What is the return value of trunc()?
- Aa) int
- Bb) bool
- Cc) float
- Dd) None
36What is the output of print 0.1 + 0.2 == 0.3?
- Aa) True
- Bb) False
- Cc) Machine dependent
- Dd) Error
37Which of the following is not a complex number?
- Aa) k = 2 + 3j
- Bb) k = complex(2, 3)
- Cc) k = 2 + 3l
- Dd) k = 2 + 3J
38What is the type of inf?
- Aa) Boolean
- Bb) Integer
- Cc) Float
- Dd) Complex
39What does (ирек)4 evaluate to?
- Aa) -5
- Bb) -4
- Cc) -3
- Dd) +3
40What does ~~~~~~5 evaluate to? 6 ирек
- Aa) +5
- Bb) -11
- Cc) +11
- Dd) -5
41Which of the following is incorrect?
- Aa) x = 0b101
- Bb) x = 0x4f5
- Cc) x = 19023
- Dd) x = 03964
42What is the result of cmp(3, 1)?
- Aa) 1
- Bb) 0
- Cc) True
- Dd) False
43Which of the following is incorrect?
- Aa) float(‘inf’)
- Bb) float(‘nan’)
- Cc) float(’56’+’78’)
- Dd) float(’12+34′)
44What is the result of round(0.5) – round(-0.5)?
- Aa) 1.0
- Bb) 2.0
- Cc) 0.0
- Dd) None of the mentioned
45What does 3 ^ 4 evaluate to?
- Aa) 81
- Bb) 12
- Cc) 0.75
- Dd) 7
46 What will be the value of the following Python expression?
4 + 3 % 5- Aa) 4
- Bb) 7
- Cc) 2
- Dd) 0
47The value of the expressions 4/(3*(2-1)) and 4/3*(2-1) is the same.
- Aa) True
- Bb) False
48Evaluate the expression given below if A = 16 and B = 15.
A % B // A- Aa) 0.0
- Bb) 0
- Cc) 1.0
- Dd) 1
49 Which of the following operators has its associativity from right to left?
- Aa) +
- Bb) //
- Cc) %
- Dd) **
50. What will be the value of x in the following Python expression?
x = int(43.55+2/2)- Aa) 43
- Bb) 44
- Cc) 22
- Dd) 23
51What is the value of the following expression?
2+4.00, 2**4.0- Aa) (6.0, 16.0)
- Bb) (6.00, 16.00)
- Cc) (6, 16)
- Dd) (6.00, 16.0)
52Which of the following is the truncation division operator?
- Aa) /
- Bb) %
- Cc) //
- Dd) |
53What are the values of the following Python expressions?
2**(3**2)
(2**3)**2
2**3**2- Aa) 64, 512, 64
- Bb) 64, 64, 64
- Cc) 512, 512, 512
- Dd) 512, 64, 512
54 What is the value of the following expression?
8/4/2, 8/(4/2)- Aa) (1.0, 4.0)
- Bb) (1.0, 1.0)
- Cc) (4.0. 1.0)
- Dd) (4.0, 4.0)
55What is the value of the following expression?
float(22//3+3/3)- Aa) 8
- Bb) 8.0
- Cc) 8.3
- Dd) 8.33
56What will be the output of the following Python expression?
print(4.00/(2.0+2.0))- Aa) Error
- Bb) 1.0
- Cc) 1.00
- Dd) 1
57What will be the value of X in the following Python expression?
X = 2+9*((3*12)-8)/10- Aa) 30.0
- Bb) 30.8
- Cc) 28.4
- Dd) 27.2
58Which of the following expressions involves coercion when evaluated in Python?
- Aa) 4.7 – 1.5
- Bb) 7.9 * 6.3
- Cc) 1.7 % 2
- Dd) 3.4 + 4.6
59What will be the output of the following Python expression?
24//6%3, 24//4//2- Aa) (1,3)
- Bb) (0,3)
- Cc) (1,0)
- Dd) (3,1)
60+, -, **, %, /, <<, >>, |
- Aa) <<, >>
- Bb) **
- Cc) |
- Dd) %
61What will be the value of the following Python expression?
float(4+int(2.39)%2)- Aa) 5.0
- Bb) 5
- Cc) 4.0
- Dd) 4
62 Which of the following expressions is an example of type conversion?
- Aa) 4.0 + float(3)
- Bb) 5.3 + 6.3
- Cc) 5.0 + 3
- Dd) 3 + 7
63Which of the following expressions results in an error?
- Aa) float(‘10’)
- Bb) int(‘10’)
- Cc) float(’10.8’)
- Dd) int(’10.8’)
64What will be the value of the following Python expression?
4+2**5//10- Aa) 3
- Bb) 7
- Cc) 77
- Dd) 0
65 The expression 2**2**3 is evaluates as: (2**2)**3.
- Aa) True
- Bb) False
66What will be the output of the following Python code snippet if x=1?
x<<2- Aa) 8
- Bb) 1
- Cc) 2
- Dd) 4
67What will be the output of the following Python expression?
bin(29)- Aa) ‘0b10111’
- Bb) ‘0b11101’
- Cc) ‘0b11111’
- Dd) ‘0b11011
68What will be the value of x in the following Python expression?
x>>2=2- Aa) 8
- Bb) 4
- Cc) 2
- Dd) 1
69To find the decimal value of 1111, that is 15, we can use the function:
- Aa) int(1111,10)
- Bb) int(‘1111’,10)
- Cc) int(1111,2)
- Dd) int(‘1111’,2)
70What will be the output of the following Python expression if x=15 and y=12?
x & y- Aa) b1101
- Bb) 0b1101
- Cc) 12
- Dd) 1101
71Which of the following expressions results in an error?
- Aa) int(1011)
- Bb) int(‘1011’,23)
- Cc) int(1011,2)
- Dd) int(‘1011’)
72 Which of the following represents the bitwise XOR operator?
- Aa) &
- Bb) ^
- Cc) |
- Dd) !
73 What is the value of the following Python expression?
bin(0x8)- Aa) ‘0bx1000’
- Bb) 8
- Cc) 1000
- Dd) ‘0b1000’
74What will be the output of the following Python expression?
0x35 | 0x75- Aa) 115
- Bb) 116
- Cc) 117
- Dd) 118
75The one’s complement of 110010101 is:
- Aa) 001101010
- Bb) 110010101
- Cc) 001101011
- Dd) 110010100
76It is not possible for the two’s complement value to be equal to the original value in any case.
- Aa) True
- Bb) False
77Bitwise _________ gives 1 if either of the bits is 1 and 0 when both of the bits are 1.
- Aa) OR
- Bb) AND
- Cc) XOR
- Dd) NOT
78What will be the output of the following Python expression?
4^12- Aa) 2
- Bb) 4
- Cc) 8
- Dd) 12
79 Any odd number on being AND-ed with ________ always gives 1. Hint: Any even number on being AND-ed with this value always gives 0.
- A10
- B2
- C1
- D0
80What will be the value of the following Python expression?
bin(10-2)+bin(12^4)- Aa) 0b10000
- Bb) 0b10001000
- Cc) 0b1000b1000
- Dd) 0b10000b1000
81 Which of the following expressions can be used to multiply a given number ‘a’ by 4?
- Aa) a<<2
- Bb) a<<4
- Cc) a>>2
- Dd) a>>4
82a=10
b=20
a=a^b
b=a^b
a=a^b
print(a,b)- Aa) 10 20
- Bb) 10 10
- Cc) 20 10
- Dd) 20 20
83What is the two’s complement of -44?
- Aa) 1011011
- Bb) 11010100
- Cc) 11101011
- Dd) 10110011
84['hello', 'morning'][bool('')]
- Aa) error
- Bb) no output
- Cc) hello
- Dd) morning
85['f', 't'][bool('spam')]
- Aa) t
- Bb) f
- Cc) No output
- Dd) Error
86l=[1, 0, 2, 0, 'hello', '', []]
list(filter(bool, l))- Aa) Error
- Bb) [1, 0, 2, 0, ‘hello’, ”, []]
- Cc) [1, 0, 2, ‘hello’, ”, []]
- Dd) [1, 2, ‘hello’]
87class Truth:
pass
x=Truth()
bool(x)- Aa) pass
- Bb) true
- Cc) false
- Dd) error
88if (9 < 0) and (0 < -9):
print("hello")
elif (9 > 0) or False:
print("good")
else:
print("bad")- Aa) error
- Bb) hello
- Cc) good
- Dd) bad
89Which of the following Boolean expressions is not logically equivalent to the other three?
- Aa) not(-6<0 or-6>10)
- Bb) -6>=0 and -6<=10
- Cc) not(-6<10 or-6==10)
- Dd) not(-6>10 or-6==10)
90What will be the output of the following Python code snippet?
not(10<20) and not(10>30)- Aa) True
- Bb) False
- Cc) Error
- Dd) No output
91X=”hi”
print(“05d”%X)- Aa) 00000hi
- Bb) 000hi
- Cc) hi000
- Dd) error
92What will be the output of the following Python code snippet?
X=”san-foundry”
print(“%56s”,X)- Aa) 56 blank spaces before san-foundry
- Bb) 56 blank spaces before san and foundry
- Cc) 56 blank spaces after san-foundry
- Dd) no change
93What will be the output of the following Python expression if x=456?
print("%-06d"%x)- Aa) 000456
- Bb) 456000
- Cc) 456
- Dd) error
94print(“%06d”%X)
- Aa) 345000
- Bb) 000345
- Cc) 000000345
- Dd) 345000000
95Which of the following formatting options can be used in order to add ‘n’ blank spaces after a given string ‘S’?
- Aa) print(“-ns”%S)
- Bb) print(“-ns”%S)
- Cc) print(“%ns”%S)
- Dd) print(“%-ns”%S)
96What will be the output of the following Python expression if X = -122?
print("-%06d"%x)- Aa) -000122
- Bb) 000122
- Cc) –00122
- Dd) -00122
97What will be the output of the following Python expression if x=56.236?
print("%.2f"%x)- Aa) 56.00
- Bb) 56.24
- Cc) 56.23
- Dd) 0056.236
98What will be the output of the following Python expression if x=22.19?
print("%5.2f"%x)- Aa) 22.1900
- Bb) 22.00000
- Cc) 22.19
- Dd) 22.20
99 The expression shown below results in an error.
print("-%5d0",989)- Aa) True
- Bb) False
100'%d %s %g you' %(1, 'hello', 4.0)
- Aa) Error
- Bb) 1 hello you 4.0
- Cc) 1 hello 4 you
- Dd) 1 4 hello you
101The output of which of the codes shown below will be: “There are 4 blue birds.”?
- Aa) ‘There are %g %d birds.’ %4 %blue
- Bb) ‘There are %d %s birds.’ %(4, blue)
- Cc) ‘There are %s %d birds.’ %[4, blue]
- Dd) ‘There are %d %s birds.’ 4, blue
102What will be the output of the python code shown below for various styles of format specifiers?
x=1234
res='integers:...%d...%-6d...%06d' %(x, x, x)
res- Aa) ‘integers:…1234…1234 …001234’
- Bb) ‘integers…1234…1234…123400’
- Cc) ‘integers:… 1234…1234…001234’
- Dd) ‘integers:…1234…1234…001234’
Informationen
- Beschreibung
- Quiz am phyton, erstellt von Меруерт Бекен am 27/12/2019.
- Autor
- Меруерт Бекен
- Sprache
- English
- Aufrufe
- 2
- Bewertung
- Noch keine Bewertungen Bewerte dieses Quiz