Master Python programming from scratch. Build real-world projects and become a confident Python developer.
Detailed study material
Practical code samples
On completion
Unlimited access
Python is a high-level, interpreted programming language known for its simplicity and readability. Created by Guido van Rossum in 1991, Python has become one of the most popular programming languages in the world.
# My first Python program
print("Hello, World!")
# Variables
name = "John"
age = 25
print(f"Name: {name}, Age: {age}")
Variables are containers for storing data values. Python has no command for declaring a variable. A variable is created the moment you first assign a value to it.
# Different data types
x = 5 # int
y = 3.14 # float
name = "Python" # str
is_active = True # bool
print(type(x)) #
print(type(y)) #
print(type(name)) #
Control flow statements allow you to execute code conditionally or repeatedly. Python uses indentation to define blocks of code.
# If-Else Example
age = 18
if age >= 18:
print("Adult")
else:
print("Minor")
# For Loop
for i in range(5):
print(i)
A function is a block of code which only runs when it is called. You can pass data, known as parameters, into a function. A function can return data as a result.
# Function definition
def greet(name):
return f"Hello, {name}!"
print(greet("World"))
# Lambda function
square = lambda x: x ** 2
print(square(5)) # 25
Python has four built-in data structures: List, Tuple, Dictionary, and Set. Each has unique properties and use cases.
# Lists
fruits = ["apple", "banana", "cherry"]
fruits.append("date")
# Dictionary
person = {"name": "John", "age": 30}
print(person["name"])
# Set
numbers = {1, 2, 3, 4, 5}