Answer to Question #320892 in Python for leigh

Question #320892

Code the formula for:

Speed

Distance

Time


1
Expert's answer
2022-04-03T08:00:04-0400
# Function to calculate speed
def cal_speed(dist, time):
    print(" Distance(km) :", dist);
    print(" Time(hr) :", time);
    return dist / time;
 
# Function to calculate distance traveled
def cal_dis(speed, time):
    print(" Time(hr) :", time) ;
    print(" Speed(km / hr) :", speed);
    return speed * time;
 
# Function to calculate time taken
def cal_time(dist, speed):
    print(" Distance(km) :", dist);
    print(" Speed(km / hr) :", speed);
    return dist / speed;
 
# Driver Code
 
# Calling function cal_speed()
print(" The calculated Speed(km / hr) is :",
                     cal_speed(45.9, 2.0 ));
print("");
 
# Calling function cal_dis()
print(" The calculated Distance(km) :",
                   cal_dis(62.9, 2.5));
print("");
 
# Calling function cal_time()
print(" The calculated Time(hr) :",
              cal_time(48.0, 4.5));

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS