Class 11 Computer Science - Chapter 5 (Python Basics)
Q1. Write the features of Python
- Python is a high-level, free, and open-source language.
- It is an interpreted language, executed line by line.
- It has simple syntax and clear structure, easy to read and write.
- Python is case-sensitive (e.g., Number != number).
- It is portable and platform-independent.
- Has a rich standard library of functions.
- Used in web development, data analysis, and many other fields.
- Uses indentation to define blocks instead of braces {}.
Q2. Define execution modes and its types
Python has two execution modes:
1. Interactive Mode: Executes code line by line directly on the Python shell (>>>). Useful for testing.
2. Script Mode: Code is written in a .py file and executed together. Useful for long programs.
Q3. What is meant by Python keywords and its example
Keywords are reserved words with special meanings in Python. They cannot be used as variable names.
Examples: if, else, for, while, def, True, False, None.
Q4. Define identifiers and explain naming of identifiers (any 4 rules)
Identifiers are names used to identify variables, functions, etc.
Rules:
1. Must start with a letter (A-Z, a-z) or underscore (_).
2. Cannot start with a digit.
3. Can contain letters, digits, and underscore only.
4. Cannot use special characters like $, %, @.
5. Should not be a Python keyword.
6. Case-sensitive (e.g., Name != name).
Class 11 Computer Science - Chapter 5 (Python Basics)
Q5. Difference between variable and constant in Python program
Variable:
- A named memory location whose value can change during program execution.
- Example: x = 5, then x = 10
Constant:
- A fixed value that does not change throughout the program.
- Python doesn't have built-in constants, but by convention we use uppercase names: PI = 3.14