Python Basics for Beginners
Python Basics for 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.
3. Basic Syntax
Example of a simple Python program:
print('Hello, World!')
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)
count = 0
print(count)
count += 1
7. Functions
Functions help organize code into reusable blocks.
Example:
def greet(name):
greet('Alice')