Font size
WorksheetsPython basic 2
Total questions: 15
Worksheet time: 8mins
Which is an invalid variable name in python
a
mark
else
x
none of the above
In Precedence of operators which has the lowest precedence
Logical Not
Addition
Exponentiation
==
=
A variable defined inside a function which is not available outside the function is known as
Fariable
variable
local variable
global variable
none of the above
>>> i = "Indian"
>>> i[2:]
displays
In
Ind
dian
india
Extracting a part of string from original is called
cutting
fitting
hitting
slicing
extracting
Which is a comment entry in python
*this is a comment
//this is a comment//
<this is a comment>
#this is a comment
None of the above
Which of the following is a valid List
x=[2,3,4,5]
x=(2,3,4,5)
x=["a","b",1,2,3.4,2+4j]
x="1,2,2,3,5"
None of the above
x=0.23400004, the command to display 0.23 is
print "%0.2d"%x
print "%0.2f"%x
print "%0.2f"x
print x "0.2f"
None of the above
List is mutable.
True
False
Find the mistake in the following code segment
import math
x=x+30
print sin(x)
import math.py
x=x+30, value of x not initialised
print sin(x), should use math.sin(x)
No error all fine
An unordered collection of distinct/unique elements is called
string
list
set
variable
The command range(5) creates
a list [0,1,2,3,4]
a list [0,1,2,3,4,5]
a set (0,1,2,3,4)
a set (0,1,2,3,4,5)
gives error
tuple and frozenset are
mutable
immutable
variable names
none of the above
Which are valid dictionary command
x=['a':1,'b':2,'c':3]
x={'a':1,'b':2,'c':3}
lst=[('a',1),('b',2),('c',3)]
x=dict(lst)
None of the above
The instruction to skip few lines of a loop in python
skip
break
continue
exit()
None of the above
