Welcome to Week 2
• Python Coding Club
• Theme: Variables and Data Types
Objectives
• - Understand variables and how to use them.
• - Learn about different data types (int, float,
string, list, tuple, dictionary, set).
• - Use basic string operations (concatenation,
formatting).
What are Variables?
• - Containers for storing data values.
• - Naming rules:
• - Start with a letter or underscore.
• - No spaces or special characters.
• - Example:
• x = 10
• name = "Alice"
Data Types
• - int: Whole numbers (e.g., 5, -10).
• - float: Decimal numbers (e.g., 3.14, -0.01).
• - string: Text values (e.g., "Hello").
• - list: A collection of items (e.g., [1, 2, 3]).
• - tuple: Like a list but unchangeable (e.g., (1, 2,
3)).
• - dictionary: Key-value pairs (e.g., {"name":
"John", "age": 25}).
• - set: Unique values (e.g., {1, 2, 3}).
Variables in Action
• - Assigning values to variables:
• score = 95
• pi = 3.14
• - Swapping values:
• x, y = y, x
String Operations
• - Concatenation: Combining strings
• greeting = "Hello" + " World"
• - Formatting (f-strings):
• name = "Alice"
• print(f"Hello, {name}!")
Practice Exercise
• - Create two string variables: one for your
favorite color and one for your favorite animal.
• - Combine them in a sentence.
• color = "blue"
• animal = "cat"
• print("I like " + color + " " + animal + "s.")
Group Activity
• - Create a program that asks for user input and
stores it in a list.
• - Example: Ask for 5 names and display them
alphabetically.
Q&A
• - Any questions?
• - Next week: Control Flow (if, else, loops)
Homework
• - Write a program that asks the user for their
name, age, and favorite color.
• - Display the information neatly.
• - Optional Challenge: Create a dictionary of 3
countries with their capitals.