Python Programming — Basics & Syntax
Python fundamentals to advanced for interviews
100 Questions 10 Topics Take Test
Advertisement
Showing 41–50 of 100 questions in Basics & Syntax
Q.41 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
Q.42 Easy Basics & Syntax
What is the output of: print('Hello' + ' ' + 'World')?
A HelloWorld
B Hello World
C Hello + World
D Error
Correct Answer:  B. Hello World
EXPLANATION

String concatenation using + operator combines 'Hello', ' ', and 'World' into 'Hello World'.

Take Test
Q.43 Easy Basics & Syntax
Which of the following is the correct syntax for a Python comment?
A // This is a comment
B
C # This is a comment
D /* This is a comment */
Correct Answer:  C. # This is a comment
EXPLANATION

Python uses the hash symbol (#) for single-line comments. The other syntaxes are used in other programming languages.

Take Test
Q.44 Easy Basics & Syntax
Consider the code: num = '123'. What will int(num) return?
A 123.0
B 123
C '123'
D Error
Correct Answer:  B. 123
EXPLANATION

int(num) converts the string '123' to the integer 123. The result is an integer type.

Take Test
Q.45 Easy Basics & Syntax
What does the len() function return when applied to a string 'India'?
A 4
B 5
C 6
D Error
Correct Answer:  B. 5
EXPLANATION

The string 'India' has 5 characters (I, n, d, i, a), so len('India') returns 5.

Take Test
Q.46 Easy Basics & Syntax
What will be the result of executing: print(type(5.0))?
A
B
C
D
Correct Answer:  B.
EXPLANATION

5.0 is a floating-point number, so type(5.0) returns <class 'float'>.

Take Test
Q.47 Easy Basics & Syntax
In Python, which of the following is an immutable data type?
A List
B Dictionary
C Tuple
D Set
Correct Answer:  C. Tuple
EXPLANATION

Tuples are immutable in Python, meaning their elements cannot be changed after creation. Lists, dictionaries, and sets are all mutable.

Take Test
Q.48 Hard Basics & Syntax
What will be the output of: print(any([False, False, True]))
A True
B False
C Error
D None
Correct Answer:  A. True
EXPLANATION

any() returns True if at least one element in the iterable is True.

Take Test
Q.49 Hard Basics & Syntax
Consider: x = [i**2 for i in range(4)]. What is x?
A [0, 1, 2, 3]
B [1, 4, 9, 16]
C [0, 1, 4, 9]
D [2, 4, 6, 8]
Correct Answer:  C. [0, 1, 4, 9]
EXPLANATION

List comprehension: i**2 for i in [0,1,2,3] produces [0, 1, 4, 9].

Take Test
Q.50 Hard Basics & Syntax
What will be the output of: d = {'a': 1, 'b': 2}; print(list(d.items()))
A [('a', 1), ('b', 2)]
B ['a', 'b']
C [1, 2]
D Error
Correct Answer:  A. [('a', 1), ('b', 2)]
EXPLANATION

dict.items() returns key-value pairs as tuples, converted to a list: [('a', 1), ('b', 2)].

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