Course Content
Module 2: Variables and Data Types
๐ŸŽฏ Module Objective: To help learners understand how to store, manage, and work with different types of data in Python using variables, and how to recognize and convert between data types.
0/3
Topic 3: Control Flow
๐ŸŽฏ Module Objective This module introduces learners to Python operators used in calculations, comparisons, and logic. Learners will understand how expressions are evaluated and how to build logical conditions using operators.
0/2
Module 4: Control Flow
๐ŸŽฏ Module Objective: This module introduces the concept of decision-making and repetition in Python programs using: if-else statements for loops while loops break, continue and basic loop control
0/3
Module 5: Functions
๐ŸŽฏ Module Objective: This module helps learners understand how to organize code using functions. Theyโ€™ll learn how to: Create and call functions Use parameters and return values Understand the concept of scope Get introduced to recursion
0/2
Module 6: Lists and Tuples
๐ŸŽฏ Module Objective: This module introduces learners to two important data collection types in Python โ€” lists and tuples. Learners will: Create, access, and modify lists Use list methods like append(), remove(), sort() Understand the difference between mutable (lists) and immutable (tuples)
0/2
Module 7: Dictionaries and Sets
๐ŸŽฏ Module Objective: This module introduces two powerful Python data types: Dictionaries: for storing keyโ€“value pairs Sets: for storing unordered, unique items Learners will: Understand the syntax and usage of dictionaries and sets Perform operations like adding, removing, updating Use dictionary methods (get(), update(), keys(), values())
0/2
Module 8: File Handling
๐ŸŽฏ Module Objective: This module introduces learners to the basics of file handling โ€” reading from and writing to text files using Python. Learners will: Open and read from a file Write to and append content in a file Use the with statement for safe file handling
0/1
๐Ÿ› ๏ธ Module 9: Error Handling in Python
๐ŸŽฏ Module Objective: This module introduces learners to error handling in Python โ€” a critical skill for writing stable and reliable programs. Learners will: Understand what exceptions are Learn how to use try, except, else, and finally Handle common Python errors (e.g., ZeroDivisionError, ValueError, FileNotFoundError) Write code that doesnโ€™t crash when unexpected issues occur
0/1
Module 10: Final Project
๐ŸŽฏ Module Objective: To help learners consolidate and apply all the skills theyโ€™ve gained throughout the course by building a small, real-world project. Upon successful completion, learners can earn a course completion certificate via Tutor LMS.
0/4
Python for Absolute Beginners: From Zero to Hero
About Lesson

๐ŸŽฏ Learning Objectives

By the end of this lesson, learners will be able to:

  • Understand local and global variable scope

  • Recognize where variables can be accessed or modified

  • Understand the basics of recursive functions

  • Create a simple recursive function with a base condition


๐Ÿ“š Lesson Content


๐Ÿ”น Part 1: Variable Scope in Python

๐Ÿ”ธ What is Scope?

Scope refers to the region of a program where a variable can be accessed.

There are two main types:

  • Local Scope: Inside a function

  • Global Scope: Outside all functions


๐Ÿ”ธ Local Variable

Defined inside a function, only usable within that function.

python
def greet():
message = "Hello!"
print(message)

greet()
# print(message) โŒ Error: message is not defined


๐Ÿ”ธ Global Variable

Defined outside any function, accessible throughout the program.

python
message = "Hi there!"

def greet():
print(message)

greet() # โœ… Works fine


๐Ÿ”ธ Modifying Global Variables Inside Functions

Use the global keyword if you want to change a global variable inside a function:

python
x = 10

def update():
global x
x = 20

update()
print(x) # 20

โš ๏ธ Avoid using global frequently โ€” it’s better to return values.


๐Ÿ” Part 2: Recursion (Intro)

๐Ÿ”ธ What is Recursion?

A function that calls itself is called recursive.

Recursion helps solve problems by breaking them down into smaller parts.


๐Ÿ”ธ Recursive Function Structure

python
def recurse():
if base_condition:
return
else:
recurse()

Base condition is important to prevent infinite loops.


โœ… Example: Countdown

python
def countdown(n):
if n == 0:
print("Done!")
else:
print(n)
countdown(n - 1)

countdown(5)

Output:

ย 
5
4
3
2
1
Done!

๐Ÿ”ธ Example: Factorial Using Recursion

python
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n - 1)

print(factorial(5)) # Output: 120


โš ๏ธ Recursion Tips

Rule Why It’s Important
Always include a base case To stop recursion (avoid infinite loop)
Use for problems that reduce e.g., factorial, Fibonacci, trees
Keep input values decreasing To reach the base condition

๐Ÿ“ Assignment

  1. Create a function say_hello(n) that prints "Hello" n times using recursion.

  2. Create a function sum_to_n(n) that returns the sum of numbers from 1 to n using recursion.

Scroll to Top