Question
Earlier in this assignment, you were asked to implement a particular formula as a script which took input from the user and printed output on
Earlier in this assignment, you were asked to implement a particular formula as a script which took input from the user and printed output on the screen. For this problem, you are going to implement the same formula as a function. In other words, you need to write a function that takes multiple numeric arguments (not input from the keyboard!) and that returns the result of the formula (not printing the output on the screen!). Include this function definition in the lab3.py script.
Hint: This is a pure function. If you're using input() or print() in your function definition, your function will be rejected. In fact, the whole point of this particular problem is to make sure you understand the difference.
the formula earlier in the assignment is:
print("This program will find the volume of a triangle.") a = float(input("Enter height of a triangle (in centimeters): ")) b = float(input("Enter base of a triangle (in centimeters): ")) c = float(input("Enter length of a triangle (in centimeters): "))
print('the volume of the triangle is:', (a*b*c)/2, 'cubic centimeters.')
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started