UNIT I – Python Basics
1. What is Python? Explain its features and applications.
Python is a high-level, interpreted, general-purpose programming language. It is easy to learn and
widely used for various applications.
Features:
• Simple and easy to learn
• Interpreted language
• Platform independent
• Large standard library
• Object-oriented
Applications:
• Web development
• Data science and AI
• Automation and scripting
• Game development
2. Explain Python variables and different data types with examples.
Variables are used to store data values.
Example:
x = 10
name = "Python"
Data Types:
int – 10, 20
float – 10.5
str – "Hello"
bool – True, False
3. Explain numeric data types in Python and type casting.
Numeric types include int, float, and complex.
Example:
a = 10
b = 5.5
Type Casting:
int(5.6) → 5
float(5) → 5.0
str(10) → "10"
4. Explain basic Python operators with examples.
Arithmetic: +, -, *, /
Relational: >, <, ==
Logical: and, or, not
Assignment: =, +=
Membership: in, not in
Identity: is, is not
5. Explain Python blocks and indentation.
Python uses indentation to define blocks of code. It improves readability and avoids confusion.
Example:
if a > b:
print("a is greater")
6. Explain the Python programming cycle. Why is Python called an interpreted language?
Steps:
• Write code
• Interpret code
• Execute output
Python is called an interpreted language because code is executed line by line.