Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

Unit 3 — Arguments, Return Values, Formal vs Actual

Lesson 35 of 50 in the free Python Programming notes on Siksha Sarovar, written by Rohit Jangra.

Arguments and Return Values

Passing Arguments

def add(a, b):        # a, b are FORMAL parameters (placeholders)
    return a + b

result = add(5, 3)     # 5, 3 are ACTUAL arguments (real values passed)
print(result)            # 8

Formal vs Actual Arguments

TermMeaning
Formal ParameterVariable name listed in the function definition (a, b above)
Actual ArgumentReal value passed when calling the function (5, 3 above)
def multiply(x, y):    # x, y = formal parameters
    return x * y

print(multiply(4, 5))    # 4, 5 = actual arguments -> 20

return Statement

return sends a value back to the caller and ends function execution immediately.

def check_even(n):
    if n % 2 == 0:
        return True
    return False

print(check_even(10))   # True
print(check_even(7))    # False

Returning Multiple Values

Python functions can return multiple values as a tuple:

def min_max(numbers):
    return min(numbers), max(numbers)

low, high = min_max([4, 9, 1, 7])
print(low, high)   # 1 9

Function with no arguments and no return

def welcome():
    print("Welcome!")

welcome()   # Welcome!

Positional Arguments (order matters)

def student_info(name, age, course):
    print(name, age, course)

student_info("Riya", 21, "BCA")   # matched by POSITION

Passing a function's return value into another function

def square(n):
    return n * n

def cube(n):
    return n * n * n

print(square(3) + cube(2))   # 9 + 8 = 17