Worksheetspython programming quiz
Total questions: 26
Worksheet time: 11mins
Write the output of the following code:
x=2
x=5
x=x+x
print(x)
7
10
4
Error
Write the output of the following code :
x=2
y=3
x+y+5
print(x+y)
8
6
10
5
What is a keyword?
Reserved Word
Predefined Word
Keywords are part of the syntax and they cannot be used as an identifier.
All of them
Which statement will display square of number (n)
print(n * n)
print(math.pow(n,2)) # math module is already imported
All of the above
Only First
Which of the following data types is not supported in python?
String
Number
List
Slice
Select the reserved keyword in python-
else
raise
import
All of them
What will be the output of this string operation s[2:5] , if s="hello world" -
lo
llo
llow
ell
What will be the output of this string operation s[6:] , if s="hello world" -
'world'
'orld'
' world'
'worl'
What is the maximum possible length of the identifier?
31 Characters
36 Characters
33 Characters
34 Characters
Which statement is adding remainder of 8 divided by 3 to the product of 5 and 6?
8 % 3 + 5 * 6
8/3 + 5 * 6
8 // 3 + 6.5
None of the above
Is a,b = 6 statement will return an error.(T/F)
True
False
Both the print statement will return same output (T/F)
a=9
b=a
print(id(a)) print(id(b))
False
True
Write the output of the following code :
>>> a=9
>>> x=str(a)
>>> b=5
>>> y=str(b)
>>> x+y
14
9,5
95
None of the above
In which language is Python written?
English
PHP
C
All of the above
Which one of the following is the correct extension of the Python file?
.py
.python
.p
None of these
What do we use to define a block of code in Python language?
Key
Brackets
Indentation
None of these
Which of the following declarations is incorrect?
_x = 2
__x = 3
__xyz__ = 5
None of these
Write the output of the following code :
>>> 7+2//1**2 > 5+2**2//3
True
False
Write the output of the following :
>>> num1 = 7
>>> num2 = 3
>>> num1 //= num2
>>> num1
3
2
7
1
print(“I” + “am” + “in” + “school”) display________
I am in school
Iaminschool
I Am In School
iaminschool
int(20.5 + 2.7) and int(20.5) + int(2.7) will produce the same result.(T/F)
True
False
Study the following statements:
>>> str1 = "javat"
>>> str2 = ":"
>>> str3 = "point"
>>> str1[-1:] What will be the output of this statement?
t
j
point
java
if s = "hello" then what will be the output of print(3*s)?
hellohello
3hello
3*hello
hellohellohello
a = 5
print("The type of a", type(a)) ?
float
int
bool
5
str1 = 'hello javatpoint' #string str1
str2 = ' how are you' #string str2
then print (str1 + str2)?
helo javapointhow are you
helo javapoint how are you
helojavapointhow are you
helojavapoint howareyou
Write the output of the following:
print(range(0,8,2))
range(0, 8, 2)
0,2,4,6
Error
None of the above
