PYTHON FORENSICS QUIZ DESCRIPTION

What is the maximum possible length of an identifier?

  • 16
     

  • 32

  • 64

  • None of these above

Why does the name of local variables start with an underscore discouraged?

  • To identify the variable
     

  • It confuses the interpreter

  • It indicates a private variable of a class

  • None of these

Which of the following operators is the correct option for power(ab)?

  • a ^ b
     

  • a**b

  • a ^ ^ b

  • a ^ * b

Study the following program:
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)
Which of the following is the correct output of this program?

  • 32

  • 32 32

  • 32 None

  • Error is generated

Which of the following statements is correct in this python code?

class Name:
def __init__(javatpoint):
javajavatpoint = java
name1=Name(“ABC”)
name2=name1
 

  • It will throw the error as multiple references to the same object is not possible
     

  • id(name1) and id(name2) will have same value

  • Both name1 and name2 will have reference to two different objects of class Name

  • All of the above

Which of the following is correctly evaluated for this function?
pow(x,y,z)

  • (x**y) / z
     

  • (x / y) * z

  • (x**y) % z

  • (x / y) / z

What is the method inside the class in python language?

  • Object
     

  • Function

  • Attribute

  • Argument

Study the following program:
a = 1
while True:
if a % 7 = = 0:
break
print(a)
a += 1
Which of the following is correct output of this program?

 

  • 1 2 3 4 5
     

  • 1 2 3 4 5 6

  • 1 2 3 4 5 6 7

  • Invalid syntax

Study the following code:
>>> print (r”\njavat\npoint”)
What will be the output of this statement?

  • java
    point
     

  • java point

  • javat point

  • Print the letter r and then javat and then point

Study the following program:
i = 0
while i < 3:
print(i)
i += 1
else:
print(0)
What will be the output of this statement?

 

  • 0 1
     

  • 0 1 2

  • 0 1 2 0

  • 0 1 2 3

Study the following program:
d = {0: ‘a’, 1: ‘b’, 2: ‘c’}
for i in d:
print(i)
What will be the output of this statement?

  •  a b c
     

  • 0 1 2

  • 0 a 1 b 2 c

  • None of these above

What do we use to define a block of code in Python language?

  • Key
     

  • Brackets

  • Indentation

  • None of these

Study the following statements:
1. >>> str1 = “javat”
2. >>> str2 = “:”
3. >>> str3 = “point”
4. >>> str1[-1:]
What will be the output of this statement?

  • t
     

  • j

  • point

  • java

Study the following program:
x = ‘pqrs’
for i in range(len(x)):
x[i].upper()
print (x)
Which of the following is the correct output of this program?

 

  • PQRS
     

  • pqrs

  • qrs

  • None of these

What error will occur when you execute the following code?
MANGO = APPLE

  •  NameError
     

  • SyntaxError

  • TypeError

  • ValueError

In which language is Python written?

  •  English
     

  • PHP

  • C

  • All of the above

Which of the following declarations is incorrect in python language?

  • xyzp = 5,000,000
     

  • x y z p = 5000 6000 7000 8000

  • x,y,z,p = 5000, 6000, 7000, 8000

  • x_y_z_p = 5,000,000

Study the following statements:
print(ord(‘h’) – ord(‘z’))
What will be the output of this statement?

  • 18

  • -18

  • 17

  • -17

Study the following code:
”javatpoint”[5:]
What will be the output of this code?

  • javatpoint
     

  • java

  • point

  • None of these

Study the following statements:
>>> print(0xA + 0xB + 0xC)
What will be the output of this statement?

  • 33

  • 63

  • 0xA + 0xB + 0xC

  • None of these

 Study the following statement:
”a”+”bc”
What will be the output of this statement?

  • a+bc
     

  • abc

  • a bc

  • a

Which one of the following has the highest precedence in the expression?

  • Division
     

  • Subtraction

  • Power

  • Parentheses

Study the following program:
z = “xyz”
j = “j”
while j in z:
print(j, end=” “)
What will be the output of this statement?

  • xyz
     

  • No output

  • x y z

  • j j j j j j j..

Which of the following precedence order is correct in Python?

  • Parentheses, Exponential, Multiplication, Division, Addition, Subtraction
     

  • Multiplication, Division, Addition, Subtraction, Parentheses, Exponential

  • Division, Multiplication, Addition, Subtraction, Parentheses, Exponential

  • Exponential, Parentheses, Multiplication, Division, Addition, Subtraction

Who developed the Python language?

  • Zim Den
     

  • Guido van Rossum

  • Niene Stom

  • Wick van Rossum

Which character is used in Python to make a single line comment?

  • /

  • //

  • #

  • !

Which of the following statements is correct regarding the object-oriented programming concept in
Python?

  • Classes are real-world entities while objects are not real
     

  • Objects are real-world entities while classes are not real

  • Both objects and classes are real-world entities

  • All of the above

Which of the following statements is correct for variable names in Python language?

  • All variable names must begin with an underscore.
     

  • Unlimited length

  • The variable name length is a maximum of 2.

  • All of the above

Which of the following declarations is incorrect?

  • _x = 2
     

  • __x = 3

  • __xyz__ = 5

  • None of these

Study the following program:
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)
What will be the output of this statement?

  • Ann Bob
     

  • Ann Nick

  • Wick Bob

  • Wick Nick