Python Interview Questions
Are you Preparing for Interview in Python?
Who should Practice these Python Basic Interview Questions ?
- Anyone wishing to sharpen their knowledge.
- Anyone preparing for JOB interview. ( Python Basic Interview Questions )
What is the Importance of Python?
What you’ll learn
- How to Solve Python Basic Questions
Are there any course requirements or prerequisites?
- Basic knowledge of Computer Programming ( Python programming interview questions )
- Basic Knowledge of Python ( Python practice questions )
Who this course is for:
- Learner Who want to Preparing for Interview
This is Fundamental Python Interview Questions
In which year was the Python language developed ?
A. 1995
B. 1972
C. 1981
D. 1989
Eplanation
The Correct Answer is D.
Python language was developed by Guido van Rossum in 1989.
In which language is Python written?
A. English
B. PHP
C. C
D. All of the above
Eplanation
The Correct Answer is C.
Python is written in C programming language, and it is also called CPython.
In which year was the Python 3.0 version developed?
A. 2008
B. 2000
C. 2010
D. 2005
Eplanation
The Correct Answer is A.
Python 3.0 version was developed on December 3, 2008.
What do we use to define a block of code in Python language?
A. Key
B. Brackets
C. Identation
D. None of these
Eplanation
The Correct Answer is C.
Python uses indentation to define blocks of code. Indentations are simply spaces or tabs used as an indicator that is part of the indent code child. As used in curly braces C, C++, and Java.
Which of the following statements is correct in this python code?
class Name:
def __init__(javatpoint):
javajavatpoint = java
name1=Name("ABC")
name2=name1
B. id(name1) and id(name2) will have same value
C. Both name1 and name2 will have referenceto two different objects of class Name
D. All of the above
Eplanation
The Correct Answer is B.
name1 and "name2" refer to the same object, so id(name1) and id(name2) will have the same value.
What is the method inside the class in python language?
A. Object
B. Function
C. Attribute
D. Argument
Eplanation
The Correct Answer is B.
Function is also known as the method.
Why does the name of local variables start with an underscore discouraged?
A. To identify the variable
B. It confuses the interpreter
C. It indicates a private vsraiable of class
D. None of these
Eplanation
The Correct Answer is C.
Since there is no concept of private variables in Python language, the major underscore is used to denote variables that cannot be accessed from outside the class.
Which of the following is not a keyword in Python language?
A. val
B. raise
C. try
D. with
Eplanation
The Correct Answer is A.
"val" is not a keyword in python language.
Which of the following words cannot be a variable in python language?
A. _val
B. val
C. try
D. _try_
Eplanation
The Correct Answer is C.
"try" is a keyword.
Which one of the following has the highest precedence in the expression?
A. Division
B. Subtraction
C. Power
D. Parentheses
Eplanation
The Correct Answer is D.
PEMDAS (similar to BODMAS).
Which of the following functions is a built-in function in python language?
A. val()
B. print()
C. prints()
D. None of these
Eplanation
The Correct Answer is B.
The print() function is a built-in function in python language that prints a value directly to the system.
Study the following program:
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
Eplanation
The Correct Answer is A.
Syntax error, there should not be a space between + and =.
File "
if x % 5 = = 0:
SyntaxError: invalid syntax
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)
A. 32
B. 32 32
C. 32 None
D. Error is generated
Eplanation
The Correct Answer is D.
Error is generated because self.o1 was never created.
File "
a.o1 = b
IndentationError: expected an indented block
Study the following statements:
class book:
>>> print(ord('h') - ord('z'))
A. 18
B. -18
C. 17
D. -17
Eplanation
The Correct Answer is B.
ASCII value of h is less than the z. Hence the output of this code is 104-122, which is equal to -18.
Study the following program:
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
Eplanation
The Correct Answer is D.
The Correct Answer is D.
Study the following program:
i = 1:
while True:
if i%3 == 0:
break
print(i)
A. 1 2 3
B. 0 1 2 3
C. 0 1 2
D. 3 2 1
Eplanation
The Correct Answer is C.
0 1 2
Study the following program:
x = 'pqrs'
for i in range(len(x)):
x[i].upper()
print (x)
A. PQRS
B. pqrs
C. qrs
D. None of these
Eplanation
The Correct Answer is B.
pqrs
Study the following program:
def example(a):
aa = a + '1'
aa = a*1
return a
>>>example("javatpoint")
A. hello2hello2
B. hello2
C. Cannot perform mathematical operation on strings
D. identation Error
Eplanation
The Correct Answer is D.
File "
aa = a + '1'
^
IndentationError: expected an indented block
Which of the following will run without errors ?
A. round(45.8)
B. round(6352.898,2,5)
C. round()
D. round(7463.123,2,1)
Eplanation
The Correct Answer is A.
The Correct Answer is A.
What dataype is the object below ?
L = [1, 23, ‘hello’, 1].
B. dictionary
C. array
D. tuple
Eplanation
The Correct Answer is A.
List data type can store any values within it.