Unit 1: Python basics - Subjective Questions

ECAP776 • Practice Questions with Detailed Answers

20 questions

1

Define Python and explain its major features and applications.

2

Explain how a Python program is executed. Distinguish between interactive mode and script mode.

3

What are identifiers, keywords, variables, and literals in Python? State the rules for naming identifiers.

4

Describe Python's basic built-in data types with suitable examples.

5

Distinguish between mutable and immutable data types in Python. Explain the distinction using examples.

6

Explain implicit and explicit type conversion in Python. Illustrate both with examples and mention possible conversion errors.

7

Classify and explain the operators available in Python with suitable examples.

8

Explain operator precedence and associativity in Python. Evaluate the expression 2 + 3 * 4 ** 2 // 8 - 1 step by step.

9

Compare the /, //, %, and ** operators in Python. Explain how floor division and remainder are related.

10

Differentiate between equality, identity, and membership operations in Python.

11

Explain simple if, if-else, and if-elif-else statements in Python. Why is indentation significant?

12

Describe nested conditional statements and logical operators. Write the logic for determining whether a given year is a leap year.

13

Explain the while loop in Python. Write and trace a program that calculates the sum of the first natural numbers.

14

Explain the for loop and the range() function. Compare for and while loops with examples of suitable use cases.

15

Describe the purpose of break, continue, and pass in Python. How does the optional else clause of a loop behave?

16

What is a function in Python? Explain function definition, function call, parameters, arguments, and return values.

17

Compare positional, keyword, default, and variable-length arguments in Python functions.

18

Explain local, global, and nonlocal scope in Python using the LEGB name-resolution rule.

19

Define recursion. Explain how a recursive factorial function works, including its base case and recursive case.

20

Explain lambda expressions and distinguish them from functions defined with def. Also describe the role of docstrings.