Python Basics for Absolute Beginners
1. Introduction to Python
Python is a high-level, interpreted programming language known for its simplicity and readability. It
is widely used in web development, automation, data science, artificial intelligence, and more.
2. Why Learn Python?
- Easy to learn and use
- Versatile and powerful
- Large supportive community
- Excellent for beginners and professionals alike
3. Basic Syntax
Example of a simple Python program:
print('Hello, World!')
This program prints the message to the screen.
4. Variables and Data Types
- Variables store data for later use.
- Common data types: int, float, str, bool
Example:
name = 'John'
age = 25
height = 5.9
is_student = True
5. Control Structures
Python uses indentation to define blocks of code.
Example of if-else:
if age > 18:
print('Adult')
else:
print('Minor')
6. Loops
For loop example:
for i in range(5):
print(i)
While loop example:
count = 0
while count < 5:
print(count)
count += 1
7. Functions
Functions help organize code into reusable blocks.
Example:
def greet(name):
print('Hello, ' + name)
greet('Alice')