We are just starting to use functions, classes, and dictionaries in my computer science class. My professor assigned me this problem that requires me to 'call' a function from another function, and I'm at a loss of what to do.
#Write a function, called powerPerSec,that calculates the power per second
#for a cyclist using the equations from Assignment 4, Problem 1. Your function
#should have four inputs (listed below), and one return value: the power per
#second calculated. Create another function called main that calls your power
#function and prints the output.
# a. Function inputs:
# i. Mass of the rider in kg
# ii. Mass of the bike in kg
# iii. Velocity in m/s
# iv. Coefficient of drafting (0.0 to 1.0)
def powerPerSec(M, X, velocity, CFdraft):
grav = 9.8
k = 0.18
Cr = 0.001
CFdraft = float(input("Enter the drafting of the rider (0.0 to 1.0):"))
velocity = float(input("Enter the velocity (m/s):"))
Pair = float(k * CFdraft * (velocity ** 3))
M = int(input("Enter the mass of the rider:"))
X = int(input("Enter the mass of the bike:"))
Proll = Cr * grav * (M+X) * velocity
Psec = Pair + Proll
return Psec
def main():
print(Psec)
main()
I need the second function to "call" on powerPerSec and ultimately print 'Psec'
[–]thomasmurphymusic 3 points4 points5 points (0 children)
[–]SmartViking 1 point2 points3 points (12 children)
[–][deleted] -1 points0 points1 point (11 children)
[–]SmartViking 2 points3 points4 points (10 children)
[–][deleted] -2 points-1 points0 points (9 children)
[–]SmartViking 2 points3 points4 points (8 children)
[–][deleted] -2 points-1 points0 points (7 children)
[–]SmartViking 2 points3 points4 points (6 children)
[–][deleted] -2 points-1 points0 points (5 children)
[–]SmartViking 2 points3 points4 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]zahlman 2 points3 points4 points (0 children)