Skip to Content
Course content

Session 1.pptx (Lecture Slide)


Revision of Python Programming


"Python is an experiment in how much freedom programmers need."

- Guido van Rossum (Creator of Python)

 


💡Introduction

This session is designed to revise the core concepts of Python programming that students have learned from Class 7. It focuses on three fundamental building blocks of programming:

  • Conditional Programming – Decision-making using if, elif, else.
  • Loops – Repeating tasks using for and while loops.
  • Functions – Reusable blocks of code that perform specific tasks.

These concepts are foundational for writing logical, efficient, and reusable Python programs. This session will reinforce the practical understanding of these concepts with a hands-on activity.


📘 Pre-requisite Knowledge

  • Basic Understanding of Computers.
  • Introduction to Coding Concepts.
  • Logical Thinking and Flow.


🎯 Learning Objectives

  • Recall and apply conditional statements to make decisions in code.
  • Understand and use loops for repeating tasks.
  • Define and call functions to organize code efficiently.
  • Combine all three concepts in a simple, real-world activity.
  • Enhance their problem-solving and logical thinking using Python.


🛠 Tools & Materials Required

  • A computer/laptop with Python installed (e.g., IDLE, Jupyter notebook, etc,…).

Conditional Programming

Conditional programming allows the program to make decisions based on certain conditions. Using statements like if, elif, and else, Python can check if something is true or false and execute different blocks of code accordingly.

Activity- Weather Advisor

Code

Output - 

Loops in Python

Loops are used to repeat a block of code multiple times without rewriting it.

  • For loop is used when the number of repetitions is known.
    Example: for i in range(5):
  • While loop is used when the condition is checked before each repetition.
    Example: while balance > 0:

Loops are crucial in scenarios where repetitive tasks need to be automated.

Functions in Python

Functions are blocks of code that are written once and can be reused many times. Functions improve code organization, reduce repetition, and make debugging easier. They are defined using the def keyword:


Then called like:

Functions can also accept parameters and return values, making them versatile tools for larger programs.


Activity - Robot Helper Mission using Loops & Function


Robo is your home assistant. It repeats tasks until they're done, loops through items to organize, and greets you every morning. Help Robo finish its morning routine!

Fill in the code blocks to complete Robo’s routine.

Part 1: Use While Loop to Make Robo Brush His Teeth for 3 Minutes.

 Part 2: Use For Loop to Make Robo Arrange 5 Items on the Table.

Part 3: Create a Function for Robo’s Morning Greeting.

Complete Code

Output

DIY

Create another function named remind_task() that prints "Don't forget to water the plants!" and call it at the end.

*In future we'll learn how to apply these codes into real world - Session 10

Try it yourself

Online Simulator: https://www.w3schools.com/python/trypython.asp?filename=demo_compiler



🔍Observation

  • Understand the role of functions in structuring reusable and organized Python code.
  • Identify the use of conditional statements (if-else) to handle logic for item selection and validation.
  • Apply loops (while and for) to repeat tasks such as menu input and printing receipt items.
  • Understand how real-world systems (like a restaurant) can be translated into code using basic programming logic.

 
0 0

There are no comments for now.

to be the first to leave a comment.