Introduction to Python - Class 11 Notes
What is Python?
Python is a popular high-level programming language, created by Guido van Rossum and released in 1991. Python emphasizes code readability and simplicity, making it suitable for beginners and experts alike. It is widely used in web development, data analysis, artificial intelligence, automation, and more.
Why Learn Python?
Python offers several benefits:
- Easy to learn and write
- Extensive libraries and frameworks for various applications
- Widely used in industries like web development, machine learning, data science, and automation
- Supports multiple programming paradigms (procedural, object-oriented, functional)
Key Features of Python
- High-level language with dynamic typing
- Interpreted language (no need for compilation)
- Open-source and cross-platform
- Extensive standard libraries
- Supports modules and packages
Installing Python
To begin using Python, you need to install it on your computer:
- Go to the official Python website: www.python.org.
- Download the latest version compatible with your operating system.
- Follow the installation instructions.
- Set up a code editor or use Python’s built-in IDLE.
Hello World Program
Let’s start with a simple Python program that prints "Hello, World!" to the screen:
print("Hello, World!")
Basic Syntax in Python
Python uses simple and clean syntax. Here are a few basic rules:
- Python uses indentation to define blocks of code.
- Statements are written without semicolons.
- Comments are added using the hash symbol
#
.
Data Types in Python
Python supports various data types, including:
- int: Integer values (e.g.,
10
,-20
) - float: Floating-point numbers (e.g.,
10.5
,-20.5
) - str: Strings of text (e.g.,
"Hello"
,'Python'
) - bool: Boolean values (
True
,False
)
Example: Simple Arithmetic in Python
Let's perform basic arithmetic operations:
# Addition
a = 10
b = 20
print(a + b) # Output: 30