Python Programming
Python fundamentals to advanced for interviews
119 Questions 10 Topics Take Test
Advertisement
Showing 51–60 of 119 questions
Q.51 Medium Basics & Syntax
What will be the output of: print(isinstance(5, int))?
A True
B False
C None
D Error
Correct Answer:  A. True
EXPLANATION

isinstance() checks if an object is an instance of a class. 5 is an integer, so isinstance(5, int) returns True.

Take Test
Q.52 Medium Basics & Syntax
Consider the code: x = 5; y = x; x = 10. What is the value of y?
A 5
B 10
C 15
D Error
Correct Answer:  A. 5
EXPLANATION

When y = x is executed, y gets the value 5. Later changing x to 10 does not affect y's value because integers are immutable.

Take Test
Q.53 Medium Basics & Syntax
What is the output of: print(5 == '5')?
A True
B False
C Error
D None
Correct Answer:  B. False
EXPLANATION

The == operator compares values and types. 5 (integer) and '5' (string) are different types, so the result is False.

Take Test
Q.54 Medium Basics & Syntax
Consider: lst = [1, 2, 3, 2, 1]. What will lst.count(2) return?
A 1
B 2
C 3
D Error
Correct Answer:  B. 2
EXPLANATION

The count() method returns the number of occurrences of an element. 2 appears twice in the list.

Take Test
Q.55 Medium Basics & Syntax
What will be printed: for i in range(1, 4): print(i, end=' ')?
A 0 1 2 3
B 1 2 3
C 1 2 3 4
D 0 1 2
Correct Answer:  B. 1 2 3
EXPLANATION

range(1, 4) generates numbers from 1 to 3 (4 is excluded). The end=' ' parameter prints with space separator.

Take Test
Advertisement
Q.56 Medium Basics & Syntax
Consider the code: def func(a, b=5): return a + b. What is func(3)?
A 3
B 5
C 8
D Error
Correct Answer:  C. 8
EXPLANATION

b has a default value of 5. When func(3) is called, a=3 and b=5 (default), so return 3+5=8.

Take Test
Q.57 Medium Basics & Syntax
Which of the following will correctly check if a key exists in a dictionary?
A if key in dict:
B if dict.has_key(key):
C if dict[key]:
D if key.exists(dict):
Correct Answer:  A. if key in dict:
EXPLANATION

The 'in' operator checks for key existence in a dictionary. has_key() was removed in Python 3.

Take Test
Q.58 Medium Basics & Syntax
Consider: s = 'Python'. What is s[-1]?
A 'P'
B 'y'
C 'n'
D Error
Correct Answer:  C. 'n'
EXPLANATION

Negative indexing starts from the end. s[-1] gives the last character 'n'. s = 'Python' has characters indexed from 0 to 5.

Take Test
Q.59 Easy Basics & Syntax
What will be the output of: print(10 // 3)?
A 3.33
B 3
C 1
D 4
Correct Answer:  B. 3
EXPLANATION

The floor division operator (//) returns the quotient without decimal places. 10 // 3 = 3.

Take Test
Q.60 Easy Basics & Syntax
Which method is used to add an element to a list in Python?
A add()
B append()
C insert()
D push()
Correct Answer:  B. append()
EXPLANATION

The append() method adds an element to the end of a list. insert() requires index specification, add() is for sets.

Take Test
IGET
iget AI
Online · Ask anything about exams
Hi! 👋 I'm your iget AI assistant.

Ask me anything about exam prep, MCQ solutions, study tips, or strategies! 🎯
UPSC strategy SSC CGL syllabus Improve aptitude NEET Biology tips