Slide Session 1: Writing First Code & Basic Data Types
Slide 1: Title Slide
Course Name: Introduction to Python Programming
Session Title: Writing Your First Code & Basic Data Types
Instructor Name & Date
Slide 2: What is Programming? (5 min)
A program is a step-by-step recipe that tells the computer what to do.
Programming languages are used to write instructions in a structured way.
Syntax & semantics in programming are like grammar & meaning in human
languages.
Real-Life Example: Python in Automation (Renaming thousands of files in a
folder).
o Example Code:
o import os
o for filename in os.listdir("folder_path"):
o os.rename(filename, filename.replace("old_name",
"new_name"))
Slide 3: Writing Your First Code Using print() (25 min)
Instructor Demo (5 min): Installing Python or using an online interpreter (Replit,
Google Colab, Thonny)
Students' Task (10 min):
o Write and run: print("Hello, MUBS, here I’m")
Discussion (10 min):
o How print() outputs text to the screen.
o How print() works:
1. Python reads the statement print("Hello, MUBS, here I’m ")
2. Text is sent to standard output (console/terminal).
3. New line is automatically added unless specified otherwise.
o Printing multiple items:
o print("My name is", "Alice", "and I am", 25, "years old.")
o Controlling line breaks with end="":
o print("Hello", end=" ")
o print("World!")
Slide 4: Using f-strings for Formatted Output (10 min)
Concept: f-strings help insert variables into text.
Example:
name = "Alice"
print(f"Hello, {name}!")
o Explanation: {name} gets replaced by the variable’s value.
Class Practice (5 min): Modify the code to print a personalized greeting.
Ask students to modify the code by changing the name variable to their own name.
Slide 5: Using input() to Take User Input (25 min)
Problem Statement (5 min): Modify the previous code to take user input for the
name instead of hardcoding it.
Example Code (5 min):
name = input("Enter your name: ")
print(f"Hello, {name}!")
Instructions (5 min):
1. Run the program.
2. Enter a name when prompted.
3. Discuss how input() works.
Breakdown of input() (10 min):
o Definition: input() allows Python to take input from the user.
o Syntax: input(prompt)
o How it works:
Program pauses and waits for user input.
User presses "Enter," and input is captured as a string.
o Optional prompt:
o input("Enter your name: ")
o Input is always a string; conversion is needed for numbers:
o age = int(input("Enter your age: "))
o Example application:
o favorite_color = input("What is your favorite color? ")
o print(f"Your favorite color is {favorite_color}.")
Slide 6: Poll & Team Activity (10 min)
Poll: What is Python Mostly Used For?
o A) Web Development
o B) Data Science
o C) Automation
o D) All of the above ✅
o (Students vote using Kahoot or Mentimeter.)
Team Activity: Debugging Challenge (5 min):
o Instructor provides a broken Python script. Students fix it in teams.
o Example Code:
o name = input("Enter your name: ")
o print("Hello, name!") # Find and fix the mistake
o Expected Fix:
o print(f"Hello, {name}!")
Slide 7: Quiz (10 min)
5-Question Quiz:
1. What does a programming language do?
Answer: It allows humans to write instructions that a computer
can execute.
2. Who created Python?
Answer: Guido van Rossum (1991).
3. What does print("Hello, World!") do?
Answer: Displays "Hello, World!" on the screen.
4. What is the purpose of f-strings in Python?
Answer: Embeds variables directly into strings for formatted
output.
5. How do you take user input in Python?
Answer: Using the input() function.
Slide 8: Wrap-up and Q&A (5 min)
Review Key Points:
o What programming is and why it’s useful.
o Writing and running a Python program.
o Using print(), input(), and f-strings.
Answer Any Remaining Questions.
Slide 9: Homework/Practice (Optional)
Task: Create a Python program that asks for the user's name, age, and favorite
color. Then, print a personalized message with that information.