Python Function - Exercise
Subject : Programming
Topic : Python Function
Teacher : Andreas
Date : 1 October 2021
Instructions:
Complete the all 3 exercises given bellow using your Python IDE. Once you get the correct
result, then you can paste your code in the space given here together with the screenshot of the
result and submit this file.
Exercise 1: Create a function in Python
Write a program to create a function that takes two arguments, name and age, and print their
value.
Given:
function1(“Roy”, 17)
Expected Output
Roy is 17 years old
Write Your answer (Python code) here:
Screenshot the result:
Exercise 2: Return multiple values from a function
Write a program to create function calculation() such that it can accept two variables and
calculate addition and subtraction. Also, it must return both multiplication and division in a
single return call, and print the result
Given:
calculation(10, 5)
Expected Output
Multiplication: 50
Division: 2
Write Your answer (Python code) here:
Screenshot the result:
Exercise 3: Create a function with default argument
Write a program to create a function show_employee() using the following conditions.
It should accept the employee’s name and salary and display both.
If the salary is missing in the function call then assign default value 9000 to salary
Ex:
Given:
showEmployee("Ben", 12000)
showEmployee("Jessa")
Expected output:
Name: Ben salary: 12000
Name: Jessa salary: 9000
Write Your answer (Python code) here:
Screenshot the result: