Course Content
Programming Foundations Topics:
-Introduction to Python -Installing Python & Setting Up IDE -Variables, Data Types & Operators -Input & Output -Conditional Statements (if, else, elif) -Loops (for, while) -Functions and Parameters -Error Handling (Try/Except)
0/9
Web Development with Python
Topics: Introduction to Flask Introduction to Django Building Your First Web App Routing and Templates Handling Forms Connecting to Databases (SQLite/MySQL) User Authentication Deploying Python Apps Online
Data Science & AI
Topics: Python for Data Analysis Numpy & Pandas Basics Data Cleaning Techniques Data Visualization (Matplotlib, Seaborn) Introduction to Machine Learning (Scikit-Learn) Supervised vs Unsupervised Learning Linear Regression, KNN, and Decision Trees Basic Neural Networks
Automation & Scripting
Topics: Automating Files and Folders Sending Emails with Python Web Scraping (BeautifulSoup, Selenium) Working with Excel & CSV files Scheduling Tasks with Python Scripts PDF and Image Manipulation
Game Development
Topics: Intro to Pygame Creating a Game Window Sprite Movement & Collision Score Tracking Sound and Music in Games Game Projects: Pong, Snake, Flappy Bird
Career & Interview Prep
Topics: Common Python Coding Problems String & List Manipulation Challenges Recursion & Algorithm Practice Big-O Notation Basics Cracking Python Interview Questions Building a Python Portfolio
Advanced Python
Topics: Object-Oriented Programming (OOP) Working with APIs (REST APIs, JSON) Unit Testing with unittest File Handling (Text, JSON, Pickle) Decorators, Generators, and Lambda Functions Multithreading & Asynchronous Programming
Python Full Course

📝 Overview

Functions allow you to group code into reusable blocks. In this lesson, you’ll learn how to define and call functions, use parameters, and return values to make your code clean, organized, and modular.


🎯 What You’ll Learn

  • How to define and call a function

  • What parameters and arguments are

  • How to return values from a function

  • The difference between built-in and user-defined functions


📘 1. What is a Function?

A function is a named block of code that performs a specific task. Instead of repeating code, you can call a function whenever you need it.


🛠️ 2. Creating a Function

python
def greet():
print("Hello, Python learner!")

To use (or “call”) the function:

python
greet()

📌 Output:

 
Hello, Python learner!

🎯 3. Function with Parameters

You can pass data into functions using parameters.

python
def greet(name):
print("Hello, " + name + "!")
python
greet("Maya")
greet("Juan")

📌 Output:

 
Hello, Maya!
Hello, Juan!

🔁 4. Function with Return Value

Use return to send a value back from the function:

python
def add(a, b):
return a + b

result = add(5, 3)
print("Sum is:", result)

📌 Output:

csharp
Sum is: 8

🧠 5. Why Use Functions?

✅ Organize code
✅ Reuse code
✅ Reduce errors
✅ Improve readability


🚀 Practice Task 1

Write a function that takes two numbers and returns the bigger one:

python
def max_number(a, b):
if a > b:
return a
else:
return b

print("Max is:", max_number(10, 6))


🧠 Mini Challenge

Create a function that:

  • Accepts a name and age

  • Returns a string like "Hi, Ana! You are 20 years old."

python
def profile(name, age):
return f"Hi, {name}! You are {age} years old."

print(profile("Ana", 20))


Summary

  • Functions help you reuse code efficiently

  • Use def to define a function

  • Parameters accept input; return sends output

  • Functions improve your program’s structure


⏭️ Next Lesson Preview

→ Error Handling in Python (try, except)