Module 1: Python Fundamentals

Learn Python fundamentals including syntax, data structures, functions, and object-oriented programming for Django development.

Back to Course|5 hours|Beginner

Python Fundamentals

Learn Python fundamentals including syntax, data structures, functions, and object-oriented programming for Django development.

Progress: 0/5 topics completed0%

Select Topics Overview

Python Syntax & Basics

Learn the basics of Python syntax, variables, string formatting, arithmetic operations, and user input for Django development.

Content by: Meet Sherasiya

Python Django Developer

Connect

What is Python?

Python is a high-level, interpreted programming language known for its simplicity and readability. It's widely used in web development, data science, AI, and many other fields.

Basic Syntax

Code Example
# This is a comment
print("Hello, World!")  # Simple output

# Variables
name = "John"
age = 25
height = 1.75
is_student = True

# String formatting
print(f"My name is {name} and I am {age} years old")

# Basic arithmetic
x = 10
y = 3
print(f"Addition: {x + y}")
print(f"Subtraction: {x - y}")
print(f"Multiplication: {x * y}")
print(f"Division: {x / y}")
print(f"Floor division: {x // y}")
print(f"Modulus: {x % y}")
print(f"Exponent: {x ** y}")

# Input from user
user_name = input("What's your name? ")
print(f"Hello, {user_name}!")
Swipe to see more code

Practice Exercise: Basic Calculator

Code Example
# Create a simple calculator
def calculator():
    print("Simple Calculator")
    print("1. Addition")
    print("2. Subtraction")
    print("3. Multiplication")
    print("4. Division")
    
    choice = input("Enter choice (1-4): ")
    num1 = float(input("Enter first number: "))
    num2 = float(input("Enter second number: "))
    
    if choice == '1':
        result = num1 + num2
        print(f"{num1} + {num2} = {result}")
    elif choice == '2':
        result = num1 - num2
        print(f"{num1} - {num2} = {result}")
    elif choice == '3':
        result = num1 * num2
        print(f"{num1} * {num2} = {result}")
    elif choice == '4':
        if num2 != 0:
            result = num1 / num2
            print(f"{num1} / {num2} = {result}")
        else:
            print("Error: Division by zero")
    else:
        print("Invalid choice")

# Run the calculator
calculator()
Swipe to see more code

🎯 Practice Exercise

Test your understanding of this topic:

Additional Resources

📚 Recommended Reading

  • Python Crash Course by Eric Matthes
  • Python Official Documentation
  • Learning Python by Mark Lutz

🌐 Online Resources

  • Python Tutorial (python.org)
  • Real Python Tutorials
  • Python for Beginners

Ready for the Next Module?

Continue your learning journey and master the next set of concepts.

Continue to Module 2