NOTES
CLASS 11TH
SUBJECT – INFORMATICS PRACTICES
CHAPTER- 3 BRIEF OVERVIEW OF PYTHON
1. Introduction to Python
• Python is a high-level, interpreted, and object-oriented programming language.
• Developed by Guido van Rossum and released in 1991.
• Python emphasizes code readability and provides constructs that allow for clear
programming on both small and large scales.
2. Features of Python
• Easy to learn and use: Python's syntax is clear and closer to human language.
• Interpreted Language: Python code is executed line-by-line, making debugging
easier.
• Dynamically Typed: No need to declare variable types, Python infers the type
automatically.
• Cross-platform compatibility: Python works on Windows, macOS, Linux, etc.
• Extensive Library Support: Python has numerous libraries for various tasks, such as
NumPy, Pandas, Matplotlib, etc.
• Open Source: Python is free to use and distribute.
• Object-oriented: Supports object-oriented programming, enabling encapsulation,
inheritance, and polymorphism.
3. Python Installation and Setup
• To install Python, visit the official Python website
(https://www.python.org/downloads/), download the appropriate version, and
install it on your system.
• IDLE (Integrated Development and Learning Environment) is the default editor for
Python, which comes with Python installation. Other popular editors include
PyCharm, Jupyter, and VS Code.
4. Python Syntax
• Indentation is crucial in Python as it defines the blocks of code.
• Statements in Python generally end with a newline; no semicolon is needed.
• Comments in Python start with a # for single-line comments, while multi-line
comments use triple quotes (''' or """).
Example:
python
# This is a comment
print("Hello, World!") # Output: Hello, World!
5. Basic Python Constructs
• Variables and Data Types:
o Variables are containers to store data.
o Python supports different data types such as int, float, str, bool, etc.
Example:
python
a = 10 # int
b = 20.5 # float
name = "John" # str
is_true = True # bool
• Type Conversion: Python supports implicit and explicit type conversion.
Example:
python
a = 5 # int
b = float(a) # Explicit conversion to float
• Operators:
o Arithmetic Operators: +, -, *, /, //, %, **
o Comparison Operators: ==, !=, >, <, >=, <=
o Logical Operators: and, or, not
• Input and Output:
o input() function is used to take user input.
o print() function is used for output.
Example:
python
name = input("Enter your name: ")
print("Hello", name)
6. Conditional Statements
• Python uses if, elif, and else for conditional execution.
Example:
python
x = 10
if x > 0:
print("Positive")
elif x == 0:
print("Zero")
else:
print("Negative")
7. Loops
• For loop: Used for iterating over a sequence.
• While loop: Used when a condition is to be checked repeatedly.
Example:
python
# For loop
for i in range(5):
print(i)
# While loop
i=0
while i < 5:
print(i)
i += 1
8. Functions
• Functions allow for reusability and better organization of code.
• def keyword is used to define a function.
Example:
python
def greet(name):
print("Hello", name)
greet("Alice")
9. Data Structures in Python
• List: Ordered, mutable collection of items. Example: my_list = [1, 2, 3, 4]
• Tuple: Ordered, immutable collection of items. Example: my_tuple = (1, 2, 3)
• Set: Unordered, mutable collection with no duplicate items. Example: my_set = {1, 2,
3}
• Dictionary: Unordered, mutable collection of key-value pairs. Example: my_dict =
{"name": "Alice", "age": 25}
10. Libraries and Modules
• Python has a wide variety of built-in modules and external libraries. A module is a
file containing Python definitions and statements.
• You can import modules using the import keyword.
Example:
python
import math
print(math.sqrt(16)) # Output: 4.0
Key Takeaways:
• Python is versatile and easy to use, making it suitable for beginners.
• Its extensive standard library supports a wide range of tasks, from web development
to data analysis.
• Python's simple syntax and dynamic typing enable quick development cycles.