Python Week 1: Python Basics – Variables and Data Types

Welcome to your Python journey! This week, we’ll learn the foundation of Python programming. By the end of this week, you’ll write your first Python programs!

Day 1: What is Python & Your First Program

What is Python?

Python is a programming language created by Guido van Rossum in 1991. It’s named after “Monty Python,” a British comedy group!

Why learn Python?

  • ✅ Easy to read and write (looks almost like English!)
  • ✅ Used by Google, Netflix, NASA, and many others
  • ✅ Great for beginners
  • ✅ Powerful enough for professionals
  • ✅ Used for websites, games, AI, data science, and more!

Your First Program: Hello, World!

print("Hello, World!")
Code language: Python (python)

What does this do?

  • print() is a function that displays text on screen
  • The text inside quotes is called a string
  • Parentheses () are where you put the information

Try these:

print("My name is [Your Name]")
print("I am learning Python!")
print("This is awesome!")
Code language: Python (python)

Day 2: Variables – Storing Information

What are Variables?

Variables are like labeled boxes that store information. You can put data in them and use them later!

# Creating variables
name = "Jibran"
age = 14
height = 5.4
is_student = True
Code language: Python (python)

Variable naming rules:

  • ✅ Can contain letters, numbers, and underscores
  • ✅ Must start with a letter or underscore
  • ✅ Cannot use special characters (@, #, $, etc.)
  • ✅ Case-sensitive (age and Age are different!)

Day 3: Numbers and Math Operations

# Addition
total = 10 + 5        # Result: 15

# Subtraction
difference = 20 - 8   # Result: 12

# Multiplication
product = 6 * 7       # Result: 42

# Division
quotient = 20 / 4     # Result: 5.0

# Exponents
squared = 5 ** 2      # Result: 25Code language: Python (python)

Day 4: Strings and User Input

# Getting user input
name = input("What is your name? ")
print("Hello, " + name + "!")

# String operations
message = "Python is fun!"
print(message.upper())  # PYTHON IS FUN!
print(len(message))     # 14Code language: Python (python)

Day 5: Lists

# Creating a list
colors = ["red", "blue", "green"]

# Accessing items
print(colors[0])  # red

# Adding items
colors.append("yellow")

# List operations
numbers = [5, 2, 8, 1, 9]
numbers.sort()
print(numbers)  # [1, 2, 5, 8, 9]
Code language: Python (python)

Week 1 Quiz

Week 1 Challenge Project

Create a Personal Profile Generator that collects user information and displays a formatted profile card!

print("=== PERSONAL PROFILE GENERATOR ===")
name = input("What is your name? ")
age = int(input("How old are you? "))
city = input("What city do you live in? ")
fav_color = input("Favorite color: ")

print("\n" + "=" * 40)
print("PROFILE CARD")
print("=" * 40)
print("Name: " + name)
print("Age: " + str(age))
print("Location: " + city)
print("Favorite Color: " + fav_color)
print("=" * 40)
Code language: Python (python)

Next Week Preview

We’ll learn about conditionals (if/else statements) – how to make your programs make decisions!

Practice Resources:

Scroll to Top