-
Notifications
You must be signed in to change notification settings - Fork 130
Expand file tree
/
Copy path1_your_first_function.py
More file actions
30 lines (23 loc) · 1.03 KB
/
1_your_first_function.py
File metadata and controls
30 lines (23 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# ==========================================
# DAY 5: Introducing Functions
# ==========================================
# print("Welcome to Day 5! Today, we'll learn how to package our code into reusable blocks called functions.")
# print("This is the key to writing clean, organized, and powerful programs!")
# print("\n" + "="*50)
# ==========================================
# SECTION 1: Your First Function - Defining and Calling
# ==========================================
print("SECTION 1: Your First Function")
print("-" * 30)
# A function is a named block of code that performs a specific task.
# You create it using the 'def' keyword.
# This function is DEFINED here, but it won't run yet.
def show_greeting():
print("Hello, World!")
print("Welcome to the world of functions.")
# To run the code inside the function, you must CALL it by its name.
print("Calling the function now:")
show_greeting()
print("\nCalling it again:")
show_greeting() # The beauty is you can reuse it as many times as you want!
print("\n" + "="*50)