Python Programming
Python fundamentals to advanced for interviews
38 Questions 10 Topics Take Test
Advertisement
Showing 31–38 of 38 questions
Q.31 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.

Take Test
Q.32 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.

Take Test
Q.33 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.

Take Test
Q.34 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.

Take Test
Q.35 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.

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

5.0 is a floating-point number in Python. The type() function returns <class 'float'> for decimal numbers.

Take Test
Q.37 Easy Basics & Syntax
Which of the following is NOT a valid Python identifier?
A _variable
B variable2
C 2variable
D var_name
Correct Answer:  C. 2variable
EXPLANATION

Python identifiers cannot start with a digit. They must begin with a letter or underscore.

Take Test
Q.38 Easy Basics & Syntax
What is the correct way to create a variable in Python?
A variable_name = value
B $variable_name = value
C variable-name = value
D variable name = value
Correct Answer:  A. variable_name = value
EXPLANATION

Python variables are created using the assignment operator (=) with valid identifiers containing letters, digits, and underscores.

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