Home Subjects Python Programming Basics & Syntax

Python Programming
Basics & Syntax

Python fundamentals to advanced for interviews

33 Q 2 Topics Take Mock Test
Advertisement
Difficulty: All Easy Medium Hard 21–30 of 33
Topics in Python Programming
All Basics & Syntax 100 Data Types & Lists 19
Q.21 Easy Basics & Syntax
Which of the following will correctly concatenate two strings 'Hello' and 'World'?
A 'Hello' + 'World'
B 'Hello' - 'World'
C 'Hello' & 'World'
D 'Hello' | 'World'
Correct Answer:  A. 'Hello' + 'World'
EXPLANATION

The + operator concatenates strings in Python. Other operators don't perform string concatenation.

Test
Q.22 Easy Basics & Syntax
What will be the output of: len('hello world')?
A 10
B 11
C 12
D 5
Correct Answer:  B. 11
EXPLANATION

The len() function counts all characters including the space. 'hello world' has 11 characters (including 1 space).

Test
Q.23 Easy Basics & Syntax
Which of the following is an immutable data type in Python?
A list
B dictionary
C tuple
D set
Correct Answer:  C. tuple
EXPLANATION

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

Test
Q.24 Easy Basics & Syntax
What is the output of: print(10 // 3)?
A 3
B 3.33
C 4
D 3.0
Correct Answer:  A. 3
EXPLANATION

The floor division operator (//) returns the quotient rounded down to the nearest integer. 10 // 3 = 3.

Test
Q.25 Easy Basics & Syntax
What will be the output of: print("Python"[2:5])?
A Pyt
B yth
C tho
D hon
Correct Answer:  B. yth
EXPLANATION

String slicing [2:5] extracts characters from index 2 to 4 (5 is exclusive). 'Python'[2:5] = 'yth'.

Test
Q.26 Easy Basics & Syntax
Which of the following keywords is used to create a function in Python?
A function
B def
C func
D define
Correct Answer:  B. def
EXPLANATION

The 'def' keyword is used to define a function in Python. Other options are not valid Python keywords.

Test
Q.27 Easy Basics & Syntax
What will be the output of: print(type(5 / 2))?
A
B
C
D
Correct Answer:  B.
EXPLANATION

The division operator (/) in Python 3 always returns a float, even if both operands are integers.

Test
Q.28 Easy Basics & Syntax
Which statement about Python comments is correct?
A Comments must be on their own line
B Comments start with # and can be inline or on separate lines
C Comments use // like in C++
D Multiple line comments use /* */
Correct Answer:  B. Comments start with # and can be inline or on separate lines
EXPLANATION

Python comments start with # and can appear anywhere. Multi-line comments use triple quotes or multiple # symbols.

Test
Q.29 Easy Basics & Syntax
What will be the output of: len('Python')?
A 5
B 6
C 7
D Error
Correct Answer:  B. 6
EXPLANATION

The string 'Python' has 6 characters: P, y, t, h, o, n. The len() function returns the number of characters.

Test
Q.30 Easy Basics & Syntax
Which keyword is used to create a function in Python?
A function
B def
C func
D define
Correct Answer:  B. def
EXPLANATION

The 'def' keyword is used to define functions in Python. It is followed by the function name and parameters.

Test
IGET
IGET AI
Online · Exam prep assistant
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