Python Learning Series · @onlysamarrr · Day 14 / 30
Day 14 teaches functions. def creates a reusable block of code, parameters are its inputs, and return sends a value back. print only shows something; it does not return it.
Phase: Beginner · Reels: 66/450 – 70/450
Day 14 teaches functions. def creates a reusable block of code, parameters are its inputs, and return sends a value back. print only shows something; it does not return it.
def square(n):
"""Return the square of n"""
return n * n
def greet(name):
print("Hi", name)
print(square(4))
print(square(5))
result = greet("Arhan")
print(result)
16 25 Hi Arhan None
Every real app is built from functions: one for login, one for payment, one for sending email.
Select (tick) an option, then tap Check answer to see instantly whether your answer is right or wrong, with an explanation. You can change your answer and check again.
Q1. What does square(4) return if square returns n * n?
Q2. What does a function return if it only prints?
Q3. What keyword defines a function?
| 66/450 | Concept | def se function banao |
| 67/450 | Live demo | Parameters aur return |
| 68/450 | Common mistake | print vs return |
| 69/450 | Quiz | Quiz: square function |
| 70/450 | Interview / real life | Interview: function kyun zaroori |