-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions2.py
More file actions
20 lines (18 loc) · 825 Bytes
/
Copy pathfunctions2.py
File metadata and controls
20 lines (18 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# This function converts fluid ounces to milliliters and returns the
# result of the conversion.
# Functions
def convert_volume(fluid_ounce):
# Calculate value of the "ml" variable using the parameter variable
# "fluid_ounce". There are approximately 29.5 milliliters in 1 fluid
# ounce.
ml = fluid_ounce * 29.5
# Return the result of the calculation.
return ml
# Call the conversion from within the print() function using 2 fluid
# ounces. Convert the return value from a float to a string.
print("The volume in millimeters is " + str(convert_volume(2)))
# Call the function again and double the 2 fluid ounces from within
# the print function.
print("The volume in millimeters is " + str(convert_volume(2)*2))
# Alternative calculation:
# print("The volume in millimeters is " + str(convert_volume(4))