Question Bank Python Programming: 1) What Is The Maximum Possible Length of An Identifier?
Question Bank Python Programming: 1) What Is The Maximum Possible Length of An Identifier?
PYTHON PROGRAMMING
a. 16
b. 32
c. C.64
d. d.None of these above
a. Zim Den
c. Niene Stom
a. 1995
b. 1972
c. 1981
d. 1989
a. English
b. PHP
c. C
5) Which one of the following is the correct extension of the Python file?
a. .py
b. .python
c. .p
d. None of these
a. 2008
b. 2000
c. 2010
d. 2005
a. Key
b. Brackets
c. Indentation
d. None of these
a. /
b. //
c. #
d. !
class Name:
def __init__(javatpoint):
javajavatpoint = java
name1=Name("ABC")
name2=name1
a. It will throw the error as multiple references to the same object is not possible
c. Both name1 and name2 will have reference to two different objects of class
Name
a. Object
b. Function
c. Attribute
d. Argument
a. _x = 2
b. __x = 3
c. __xyz__ = 5
d. None of these
Show Answer Workspace
13) Why does the name of local variables start with an underscore
discouraged?
d. None of these
b. raise
c. try
d. with
15) Which of the following statements is correct for variable names in Python
language?
b. Unlimited length
a. xyzp = 5,000,000
d. x_y_z_p = 5,000,000
a. _val
b. val
c. try
d. _try_
18) Which of the following operators is the correct option for power(ab)?
a. a ^ b
b. a**b
c. a ^ ^ b
d. a ^ * b
20) Which one of the following has the same precedence level?
21) Which one of the following has the highest precedence in the expression?
a. Division
b. Subtraction
c. Power
d. Parentheses
a. val()
b. print()
c. print()
d. None of these
round(4.576)
a. 4
b. 5
c. 576
d. 5
24) Which of the following is correctly evaluated for this function?
pow(x,y,z)
a. (x**y) / z
b. (x / y) * z
c. (x**y) % z
d. (x / y) / z
all([2,4,0,6])
a. False
b. True
c. 0
d. Invalid code
x = 1
while True:
if x % 5 = = 0:
break
print(x)
x + = 1
a. error
b. 2 1
c. 0 3 1
d. None of these
27) Which one of the following syntaxes is the correct syntax to read from a
simple text file stored in ''d:\java.txt''?
a. Infile = open(''d:\\java.txt'', ''r'')
c. Infile = open(''d:\java.txt'',''r'')
d. Infile = open.file(''d:\\java.txt'',''r'')
Show Answer Workspace
1. x = ['XX', 'YY']
2. for i in a:
3. i.lower()
4. print(a)
a. ['XX', 'YY']
b. ['xx', 'yy']
c. [XX, yy]
d. None of these
Show Answer Workspace
1. import math
2. abs(math.sqrt(36))
a. Error
b. -6
c. 6
d. 6.0
Show Answer Workspace
30) Study the following function:
1. any([5>8, 6>3, 3>1])
a. False
b. Ture
c. Invalid code
d. None of these
Show Answer Workspace
1. >>>"a"+"bc"
a. a+bc
b. abc
c. a bc
d. a
Show Answer Workspace
1. >>>"javatpoint"[5:]
a. javatpoint
b. java
c. point
d. None of these
Show Answer Workspace
a. character
b. ascii_lowercase_string.digits
c. lowercase_string.upercase
d. ascii_lowercase+string.ascii_upercase
>>> str1 = "javat"
>>> str2 = ":"
>>> str3 = "point"
>>> str1[-1:]
a. t
b. j
c. point
d. java
>>> print (r"\njavat\npoint")
a. Java point
b. java point
c. \njavat\npoint
a. 33
b. 63
d. None of these
class book:
def __init__(a, b):
a.o1 = b
class child(book):
def __init__(a, b):
a.o2 = b
obj = page(32)
print "%d %d" % (obj.o1, obj.o2)
a. 32
b. 32 32
c. 32 None
d. Error is generated
class Std_Name:
def __init__(self, Std_firstName, Std_Phn, Std_lastName):
self.Std_firstName = Std_firstName
self. Std_PhnStd_Phn = Std_Phn
self. Std_lastNameStd_lastName = Std_lastName
Std_firstName = "Wick"
name = Std_Name(Std_firstName, 'F', "Bob")
Std_firstName = "Ann"
name.lastName = "Nick"
print(name.Std_firstName, name.Std_lastName)
a. Ann Bob
b. Ann Nick
c. Wick Bob
d. Wick Nick
>>> print(ord('h') - ord('z'))
a. 18
b. -18
c. 17
d. -17
x = ['xy', 'yz']
for i in a:
i.upper()
print(a)
a. ['xy', 'yz']
b. ['XY', 'YZ']
c. [None, None]
d. None of these
i = 1:
while True:
if i%3 == 0:
break
1. print(i)
a. 1 2 3
b. 3 2 1
c. 1 2
d. Invalid syntax
a = 1
while True:
if a % 7 = = 0:
break
print(a)
a += 1
a. 1 2 3 4 5
b. 1 2 3 4 5 6
c. 1 2 3 4 5 6 7
d. Invalid syntax
i = 0
while i < 5:
print(i)
i += 1
if i == 3:
break
else:
print(0)
a. 1 2 3
b. 0 1 2 3
c. 0 1 2
d. 3 2 1
i = 0
while i < 3:
print(i)
i += 1
else:
print(0)
a. 0 1
b. 0 1 2
c. 0 1 2 0
d. 0 1 2 3
z = "xyz"
j = "j"
while j in z:
print(j, end=" ")
What will be the output of this statement?
a. xyz
b. No output
c. x y z
d. j j j j j j j..
x = 'pqrs'
for i in range(len(x)):
x[i].upper()
print (x)
a. PQRS
b. pqrs
c. qrs
d. None of these
d = {0: 'a', 1: 'b', 2: 'c'}
for i in d:
print(i)
a. a b c
b. 0 1 2
c. 0 a 1 b 2 c
d = {0, 1, 2}
for x in d:
print(x)
b. 0 1 2
c. Syntax_Error
49) Which of the following option is not a core data type in the python
language?
a. Dictionary
b. Lists
c. Class
50) What error will occur when you execute the following code?
MANGO = APPLE
a. NameError
b. SyntaxError
c. TypeError
d. ValueError