Skip to content
TestMacher
Chapter 4 · Class 11 Computer Science

Introduction to Python — Important Questions

53 questions With answers CBSE format

SUMMARY: The chapter introduces the basics of Python programming, including its syntax, semantics, and fundamental programming constructs.
KEY TOPICS: Python syntax, variables and data types, operators, control structures, functions, input and output operations

Q1 1 Mark

Which of the following is a valid Python identifier?

A2name
Bname_2
Cname 2
Dfor
Check answerHide answer
Correct answer: Option 2 — name_2
Q2 1 Mark

The output of print(type(3.14)) is:

A<class 'int'>
B<class 'float'>
C<class 'str'>
D<class 'bool'>
Check answerHide answer
Correct answer: Option 2 — <class 'float'>
Q3 1 Mark

Which of the following is NOT a Python keyword?

Aif
Bfor
CFunction
Dwhile
Check answerHide answer
Correct answer: Option 3 — Function
Q4 1 Mark

The result of 7 // 2 in Python is:

A3.5
B3
C4
D3.0
Check answerHide answer
Correct answer: Option 2 — 3
Q5 1 Mark

The operator used for exponentiation in Python is:

A^
B**
Cexp
Dpow
Check answerHide answer
Correct answer: Option 2 — **
Q6 1 Mark

What is the correct way to declare a variable in Python?

Avar x = 10
Bx := 10
Cx = 10
Ddeclare x = 10
Check answerHide answer
Correct answer: Option 3 — x = 10
Q7 1 Mark

Which of the following data types is immutable in Python?

AList
BDictionary
CSet
DTuple
Check answerHide answer
Correct answer: Option 4 — Tuple
Q8 1 Mark

What will be the output of the following code: print(5 * 2 ** 3) ?

A10
B40
C80
D20
Check answerHide answer
Correct answer: Option 2 — 40
Q9 1 Mark

Which of the following operators is used for logical AND in Python?

A&&
BAND
C&
Dand
Check answerHide answer
Correct answer: Option 4 — and
Q10 1 Mark

How do you start a comment in Python?

A//
B#
C/*
D<!--
Check answerHide answer
Correct answer: Option 2 — #
Q11 1 Mark

What is the output of the following code: print('Hello' + 'World')?

AHello World
BHelloWorld
CHello+World
DError
Check answerHide answer
Correct answer: Option 2 — HelloWorld
Q12 1 Mark

Which of the following is a valid way to define a function in Python?

Adef myFunction[]:
Bfunction myFunction():
Cdef myFunction():
DmyFunction() = def:
Check answerHide answer
Correct answer: Option 3 — def myFunction():
Q13 1 Mark

What will the following code snippet return: len('Python')?

A6
B7
C5
D8
Check answerHide answer
Correct answer: Option 1 — 6
Q14 1 Mark

What will be the output of the following code: print(10 % 3)?

A1
B3
C0
D10
Check answerHide answer
Correct answer: Option 1 — 1
Q15 1 Mark

Which of the following statements is true about Python lists?

ALists are immutable
BLists can contain mixed data types
CLists cannot be nested
DLists are fixed in size
Check answerHide answer
Correct answer: Option 2 — Lists can contain mixed data types
Q16 3 Marks

Differentiate between mutable and immutable data types in Python with two examples each.

Q17 3 Marks

List any three rules for naming a variable in Python.

Q18 3 Marks

What is the difference between = and == in Python?

Q19 3 Marks

Explain the use of the input() function with one example.

Q20 3 Marks

Differentiate between integer and float types in Python.

Q21 3 Marks

What are the basic data types available in Python?

View sample solutionHide solution
The basic data types in Python include integers, floats, strings, and booleans. Integers represent whole numbers, floats represent decimal numbers, strings are sequences of characters, and booleans represent True or False values.
Q22 3 Marks

Explain the concept of operators in Python. Provide examples of at least two types of operators.

View sample solutionHide solution
Operators in Python are special symbols that perform operations on variables and values. Examples include arithmetic operators like + (addition) and - (subtraction), and comparison operators like == (equal to) and != (not equal to).
Q23 3 Marks

What is the purpose of control structures in Python? Give an example of a control structure.

View sample solutionHide solution
Control structures in Python are used to dictate the flow of execution in a program. An example is the 'if' statement, which executes a block of code only if a specified condition is true.
Q24 3 Marks

Describe the syntax for defining a function in Python. What is the significance of the 'return' statement?

View sample solutionHide solution
A function in Python is defined using the 'def' keyword followed by the function name and parentheses. The 'return' statement is used to exit a function and send a value back to the caller, allowing the function to produce output.
Q25 3 Marks

How can you take multiple inputs from a user in Python? Provide a code snippet as an example.

View sample solutionHide solution
Multiple inputs can be taken using the input() function in combination with split(). For example: 'x, y = input("Enter two numbers: ").split()' allows the user to input two numbers separated by space.
Q26 6 Marks

Differentiate between mutable and immutable data types in Python in tabular form with examples.

Q27 6 Marks

Compare for loop and while loop in Python with the help of a table.

Q28 6 Marks

Differentiate between break and continue statements in tabular form.

Q29 6 Marks

Compare = and == in Python with the help of a table.

Q30 6 Marks

Differentiate between print() and input() functions in Python in tabular form.

Q31 6 Marks

Write a Python program to compute the area and circumference of a circle given its radius. Use input() and round the output to 2 decimal places.

Q32 1 Mark

Assertion (A): Python is dynamically typed.

Reason (R): Variables do not need to be declared with a type before use.

Show explanationHide explanation
Correct answer: Option 1 — Both A and R are true, and R is the correct explanation of A.
Q33 1 Mark

Assertion (A): Indentation is mandatory in Python.

Reason (R): It defines blocks of code instead of using braces.

Show explanationHide explanation
Correct answer: Option 1 — Both A and R are true, and R is the correct explanation of A.
Q34 1 Mark

Assertion (A): Python is an interpreted language.

Reason (R): The interpreter executes Python code line by line.

Show explanationHide explanation
Correct answer: Option 1 — Both A and R are true, and R is the correct explanation of A.
Q35 1 Mark

Assertion (A): The print() function ends with a newline by default.

Reason (R): The default value of the end parameter is '\n'.

Show explanationHide explanation
Correct answer: Option 1 — Both A and R are true, and R is the correct explanation of A.
Q36 1 Mark

Assertion (A): Boolean values in Python are True and False.

Reason (R): They are subtypes of the integer type with values 1 and 0.

Show explanationHide explanation
Correct answer: Option 1 — Both A and R are true, and R is the correct explanation of A.
Q37 1 Mark

Assertion (A): In Python, a variable can hold values of different data types during the execution of a program.

Reason (R): This is due to Python's dynamic typing feature.

Show explanationHide explanation
Correct answer: Option 1 — Both A and R are true, and R is the correct explanation of A.
Q38 1 Mark

Assertion (A): The syntax for defining a function in Python requires the use of the keyword 'def'.

Reason (R): This keyword is used to indicate the start of a function definition.

Show explanationHide explanation
Correct answer: Option 1 — Both A and R are true, and R is the correct explanation of A.
Q39 1 Mark

Assertion (A): Python supports both single-line and multi-line comments.

Reason (R): Single-line comments start with a hash symbol (#), while multi-line comments are enclosed in triple quotes.

Show explanationHide explanation
Correct answer: Option 1 — Both A and R are true, and R is the correct explanation of A.
Q40 1 Mark

Statement 1: Python uses indentation to define code blocks.

Statement 2: A consistent number of spaces (usually 4) is the convention.

Show answerHide answer
Correct answer: Option 1 — Both statements are true.
Q41 1 Mark

Statement 1: Comments in Python begin with the # symbol.

Statement 2: They are ignored by the interpreter.

Show answerHide answer
Correct answer: Option 1 — Both statements are true.
Q42 1 Mark

Statement 1: The input() function reads a string from the user.

Statement 2: It must be type-converted if a number is needed.

Show answerHide answer
Correct answer: Option 1 — Both statements are true.
Q43 1 Mark

Statement 1: Operator precedence in Python follows mathematical rules.

Statement 2: Parentheses can be used to override the default precedence.

Show answerHide answer
Correct answer: Option 1 — Both statements are true.
Q44 1 Mark

Statement 1: Type conversion can be implicit or explicit.

Statement 2: int() float() str() are explicit conversion functions.

Show answerHide answer
Correct answer: Option 1 — Both statements are true.
Q45 1 Mark

Statement 1: In Python, a variable name can start with a digit.

Statement 2: The float data type can represent decimal numbers.

Show answerHide answer
Correct answer: Option 3 — Only Statement 2 is true.
Q46 1 Mark

Statement 1: The 'if' statement in Python is used to create loops.

Statement 2: Python supports multiple data types including lists and tuples.

Show answerHide answer
Correct answer: Option 2 — Only Statement 1 is true.
Q47 1 Mark

Statement 1: The 'while' loop in Python executes as long as a condition is true.

Statement 2: Functions in Python can return multiple values using tuples.

Show answerHide answer
Correct answer: Option 1 — Both statements are true.
Q48 3 Marks
A bank intern is asked to write a Python program to compute simple interest given the principal P rate R and time T. The formula is SI = (P * R * T) / 100. The intern uses input() to read three values then computes and prints SI. The program should also display the maturity amount A = P + SI.
  1. To assign a value to a variable in Python use:
    A=
    B==
    C=:
    Dis
  2. If the user enters 5000 for principal what type does input() return by default?
    Aint
    Bfloat
    Cstr
    Dbool
  3. Write the complete Python program with type-conversion error handling.
Show answersHide answers
1. Option 1 — =
2. Option 3 — str
3. The Python program is: P = float(input('Principal: ')); R = float(input('Rate: ')); T = float(input('Time: ')); SI = (P * R * T) / 100; A = P + SI; print('Simple Interest:' SI); print('Maturity Amount:' A). The input() function always returns a string so we use float() to convert to a number. Without conversion the multiplication would fail or give unexpected results.
Q49 6 Marks

Identify the data type of each Python literal.

LiteralType
42?
3.14?
'Hello'?
True?
[1, 2, 3]?
(1, 2, 3)?
{'a':1}?
Q50 6 Marks

Predict the output of each Python expression.

ExpressionOutput
3 + 2 * 4?
10 / 3?
10 // 3?
10 % 3?
2 ** 3?
'a' + 'b'?
'ab' * 3?
Q51 5 Marks

Identify the result of each comparison in Python.

ComparisonResult
5 == 5?
5 == 5.0?
5 is 5.0?
'5' == 5?
[1, 2] == [1, 2]?
[1, 2] is [1, 2]?
Q52 3 Marks

Study the table of Python operators and answer:

OperatorMeaningExampleResult
+Addition or concat3 + 58
**Exponent2 ** 38
//Floor div7 // 23
%Modulus7 % 21
==Equality5 == 5True
  1. The output of 7 // 2 in Python is:
    A2
    B3
    C3.5
    D4
  2. The output of 2 ** 3 is:
    A8
    B9
    C6
    D5
  3. Discuss any five categories of operators in Python with examples.
Show answersHide answers
1. Option 2 — 3
2. Option 1 — 8
3. Python operators include arithmetic (+ - * / // % **) relational (< <= > >= == !=) logical (and or not) assignment (= += -= *= /=) and bitwise (& | ^ ~ << >>). Operator precedence follows mathematical conventions: ** then * / // % then + - then comparison then logical. Use parentheses to override the default precedence.
Q53 3 Marks

Study the Python data type hierarchy and answer:

Introduction to Python figure
  1. Which of the following is a MUTABLE data type?
    Aint
    Blist
    Cstr
    Dtuple
  2. Which is an immutable sequence?
    Alist
    Bdict
    Ctuple
    Dset
  3. Differentiate between mutable and immutable data types in Python with examples.
Show answersHide answers
1. Option 2 — list
2. Option 3 — tuple
3. Python data types are categorised as Numeric (int float complex) Sequence (list tuple str range) Mapping (dict) and Set (set frozenset). Mutable types (list dict set) can be changed in place; immutable types (int float str tuple frozenset) cannot. Mutability matters for function arguments and dict keys.

Make a full Computer Science paper on Introduction to Python.

Pick the question mix, set the marks, hit generate. You get a ready-to-print paper with an answer key.

Generate your paper — free