Python Programming

Simple syntax. Powerful capabilities. Endless possibilities.

Introduction to Python

Python is one of the most beginner-friendly yet powerful programming languages in the world. It’s widely used for web development, automation, data science, AI, and more.

# Hello World in Python
print("Welcome to Developer HUB")

Variables & Data Types

Python supports various data types such as integers, floats, strings, lists, tuples, sets, and dictionaries.

# Variables and Data Types
name = "Muaaz"
age = 20
skills = ["HTML", "CSS", "Python", "JavaScript"]

print(f"My name is {name}, and I’m {age} years old.")
print("Skills:", skills)

Conditional Statements

Control the flow of your program using if, elif, and else statements.

# Conditional Example
score = 85

if score >= 90:
    print("Excellent!")
elif score >= 75:
    print("Good job!")
else:
    print("Keep improving!")

Loops

Loops allow you to run a block of code multiple times. Python supports both for and while loops.

# For Loop Example
for i in range(1, 6):
    print(f"Iteration {i}")

Functions

Functions make your code reusable and organized. Use the def keyword to define a function.

# Function Example
def greet(name):
    return f"Hello, {name}! Welcome to Developer HUB."

print(greet("Muaaz"))

Object-Oriented Programming (OOP)

Python supports object-oriented programming with classes and objects, promoting modular and reusable code.

# Class Example
class Developer:
    def __init__(self, name, language):
        self.name = name
        self.language = language

    def intro(self):
        return f"I’m {self.name}, and I code in {self.language}."

dev = Developer("Muaaz", "Python")
print(dev.intro())

Advanced Topics