Python Programming – Beginner's Notes
1. Introduction to Python
Python is a high-level, interpreted programming language known for its simple syntax
and readability. It is widely used in web development, data analysis, automation,
artificial intelligence, machine learning, and scripting.
Key Features
• Easy-to-learn syntax
• Open-source and free
• Cross-platform
• Large standard library
• Supports object-oriented programming
• Widely used in data science and AI
2. Variables
A variable is used to store a value.
Example:
name = "John"
age = 25
salary = 45000.50
Python automatically determines the data type.
3. Common Data Types
• String – text values
• Integer – whole numbers
• Float – decimal numbers
• Boolean – True or False
• List – ordered collection
• Tuple – immutable collection
• Dictionary – key-value pairs
• Set – collection of unique values
4. Conditional Statements
Conditional statements allow a program to make decisions.
Example:
if age >= 18:
print("Adult")
else:
print("Minor")
5. Loops
Python provides for and while loops.
Example:
for i in range(5):
print(i)
A while loop executes as long as a condition is true.
6. Functions
Functions are reusable blocks of code.
Example:
def add(a, b):
return a + b
result = add(10, 20)
7. Lists
Lists can store multiple values.
Example:
fruits = ["Apple", "Banana", "Orange"]
You can add, remove, and modify elements in a list.
8. Dictionaries
A dictionary stores data as key-value pairs.
Example:
student = {
"name": "John",
"age": 20,
"course": "Computer Science"
}
9. Exception Handling
Errors can be handled using try and except.
try:
number = int(input("Enter a number: "))
except ValueError:
print("Invalid number")
10. Conclusion
Python is a versatile programming language suitable for beginners and professionals.
Learning variables, conditions, loops, functions, collections, and exception handling
provides a strong foundation for further Python development.