...
Python is a high-level, interpreted programming language known for its simplicity, readability, and wide usage in web development, AI, data science, automation, and more. Created by Guido van Rossum in 1991, it is one of the most popular languages globally.
A variable is a name that stores data in a program. It acts as a container that holds values.
name = "ArdiLand" # Variable storing a string
Data Types define the kind of data a variable can hold.
Common Python data types:
int: Whole numbers (e.g., 10)
float: Decimal numbers (e.g., 3.14)
str: Strings/text (e.g., "Hello")
bool: Boolean values (True, False)
list, tuple, dict, set: Collection types
Example:
age = 21 # int
name = "Maya" # str
price = 19.5 # float
is_active = True # bool
To display output, use the built-in print() function:
print("Welcome to Ardiland!")
Operators are special symbols used to perform operations on variables and values.
Arithmetic: +, -, *, /, %, **
Comparison: ==, !=, <, >
Logical: and, or, not
Assignment: =, +=, -=
Example:
x = 5
y = 3
print(x + y) # 8
Conditional Statements let your code make decisions. They check if conditions are True or False.
if age >= 18:
print("You are an adult")
else:
print("You are a minor")
A loop allows you to repeat a block of code multiple times.
for i in range(3):
print(i)
x = 0
while x < 3:
print(x)
x += 1
A function is a reusable block of code that performs a specific task. It is defined using the def keyword.
def greet(name):
return f"Hello, {name}"
*args: Accepts multiple positional arguments
**kwargs: Accepts multiple keyword arguments
lambda: Anonymous function
A list is an ordered, mutable collection of items.
fruits = ["apple", "banana", "orange"]
A dictionary stores data as key-value pairs.
student = {"name": "Maya", "grade": "A"}
A tuple is like a list but immutable (unchangeable).
coordinates = (10, 20)
A set is an unordered collection with no duplicates.
unique_items = {1, 2, 3}
A class is a blueprint for creating objects. It defines properties (attributes) and behaviors (methods).
class Student:
def __init__(self, name):
self.name = name
An object is an instance of a class. It holds real data.
s1 = Student("Christian")
Encapsulation – Hiding internal data
Inheritance – Child class inherits parent class
Polymorphism – Same method, different behavior
Abstraction – Hiding complexity, showing essentials
Python can read/write files using open().
with open("data.txt", "w") as f:
f.write("ArdiLand Notes")
Python uses try...except blocks to handle errors and prevent crashes.
try:
result = 10 / 0
except ZeroDivisionError:
print("Cannot divide by zero")
✅ Web Development
✅ Data Science
✅ Machine Learning & AI
✅ Automation & Scripting
✅ Web Scraping
✅ Game Development