Lab 6: Functions | CMSC 105 Elementary Programming - Fall 2024

Lab 6: Functions

Points Possible: 100

Due: Thursday, October 10th

In this lab, we will write programs using functions.

Submission:

  1. Submit a Python file for each of the programs.

Program 1: Calculate Discount

Write a function calculate_discount that takes as input 2 parameters: price, discount rate (in %), and return the discount.

Write a test program to read the price and discount rate values (using input statements outside the function) and display the discount by calling the calculate_discount function (invoke function) and printing the return value of the discount.

Save the program is discount.py and attach it to the Blackboard lab assignment.

Program 2: Divide By

Write 3 functions with the requirement as mentioned below:

Write a test program to read a number from the user (using an input statement outside the functions) and call the divBy5and6(num) function (invoke function) and printing the return value from the function.

Save the program is divideby.py and attach it to the Blackboard lab assignment.

Grading Rubric for each of the functions:

Grading Points Possible
Appropriate docstring and comments 5
Input and output 5
Computation 10
Function invocation 5

TOTAL 25 points for each function