Font size
Worksheetspython basic
Total questions: 27
Worksheet time: 14mins
.
What is the maximum length of a Python identifier?
32
16
128
No fixed length is specified
What will be the output of the following code snippet?
print(2**3 + (5 + 6)**(1 + 1))
129
8
121
None of the above.
.
What will be the datatype of the var in the below code snippet?
var = 10 print(type(var))
var = "Hello" print(type(var))
str and int
int and int
str and str
int and str
.
How is a code block indicated in Python?
Brackets
Indentation
key
none of the above
What will be the output of the following code snippet?
a = [1, 2, 3, 4, 5]
sum = 0
for ele in a:
sum += ele
print(sum)
15
0
20
None of the above
What is the correct extension for python files ?
.py
.pyth
.python
Which of the following is true about comments
Comments are used by programmers to document the code
# is used to create a comment in python
''' can be used to create a comment in python
/* */ can be used to crate a comment in python
Python ignores comments.
Which of the following is not a keyword?
if
not
global
swap
Python is uses braces to block off code
True
False
Is python an interpreter or compiler programming language?
Compiler
Interpreter
x = 5
print(x > 3 and x < 10)
True
False
How many times hi will be printed?
10
9
Infinite times
0
What will be the output of the following code snippet?
count = 0 while(True):
if count % 3 == 0:
print(count, end = " ")
if(count > 15):
break
count += 1
0 1 2........15
infinite loop
0 3 6 9 12 15
0 3 6 9 12
Which of the following are valid escape symbol in Python?
\n
\t
\\
All of the above
(a)
What is the output if the user types "Python"?
What is the output?
condition
True
Program has a syntax error.
3 > 2
What is the output?
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
......(repeated continuously)
What will be the output of the given code?
0,1,2,3,4,5,6,7,8,9
0,3,6,9
0,3,6
0,1,2,3,4,5,6,7,8,9,10
Which of the following concepts is not a part of Python?
pointers
Loops
Dynamic typing
All of the above
What will be the output of the following code snippet?
a = 3
b = 1
print(a, b)
a, b = b, a
print(a, b)
3 1 1 3
3 1 3 1
1 3 1 3
1 3 3 1
Which of the following types of loops are not supported in Python?
for
while
do-while
none of the above
Which of the following is the proper syntax to check if a particular element is present in a list?
if ele in list
if not ele not in list
Both a and b
none of the above
What will be the output of the following code snippet?
example = ["Sunday", "Monday", "Tuesday", "Wednesday"]
print(example[-3:-1])
['Monday' , 'Tuesday']
['Monday' , 'Sunday']
['Monday' , 'Wednesday']
['Wednesday' , 'Tuesday']
