Unit 1: Basics of Python - Subjective Questions

CAP776 — Programming In Python • Practice Questions with Detailed Answers

20 questions

1

Define Python and explain its major features and applications.

2

Compare Python IDLE, Jupyter Notebook, and Google Colab as environments for writing and executing Python programs.

3

Describe the procedure for creating and running a Python program using IDLE.

4

Explain how to create, save, and execute a Python file from both an editor and a command-line interface.

5

Explain Python's user input and output operations with suitable examples. Why is type conversion often required for input?

6

Describe Python's principal numeric data types and illustrate each one with an example.

7

Distinguish between implicit and explicit type conversion in Python. Explain possible errors associated with conversion.

8

Classify Python operators and explain each category with examples.

9

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

10

Explain the forms of conditional statements available in Python, including the importance of indentation.

11

Develop and explain a Python program that reads marks and displays a grade using the following rules: is A, is B, is C, and below is F. It must reject marks outside .

12

Compare for and while loops in Python. State situations in which each loop is appropriate.

13

Explain the range() function and determine the values generated by range(5), range(2, 8), and range(10, 2, -2).

14

Write and explain a sentinel-controlled while loop that repeatedly reads numbers and calculates their sum until the user enters 0.

15

Differentiate among break, continue, and pass in Python, with suitable loop-related examples.

16

Describe nested loops and write a Python program to display the following pattern for : 1, 12, 123, 1234 on separate lines.

17

Define a user-defined function in Python. Explain its syntax, function call, parameters, and return value.

18

Explain positional, keyword, and default arguments in Python functions. Also distinguish between local and global variables.

19

Develop a user-defined function to calculate the factorial of a non-negative integer. Explain the algorithm and show how invalid input can be handled.

20

Design a Python program using input/output, a loop, conditional statements, and user-defined functions to read numbers and report their sum, average, largest value, and count of even integers.