SHARE
SPREAD
HELP

The Tradition of Sharing

Help your friends and juniors by posting answers to the questions that you know. Also post questions that are not available.


To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

 

#
Authors:
Y Daniel Lang
Chapter:
To Computers Programs And Python
Exercise:
Programming Excercises
Question:10 | ISBN:978013274719 | Edition: 6

Question

(Average speed) Assume a runner runs 14 kilometers in 45 minutes and 30 seconds.
Write a program that displays the average speed in miles per hour. (Note that 1 mile is 1.6 kilometers.)

TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Answer

kilometers = 14.0;
miles = kilometers / 1.6;
rate = (45.5 * 60.0 + 30.0) / (60.0 * 60.0);
milesPerHour = miles / rate;
print("The average speed in miles per hour:",milesPerHour)

Sample output:

Python 3.2.1 (default, Jul 10 2011, 21:51:15) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
>>> 
The average speed in miles per hour: 11.41304347826087
>>> 

 

0 0

Discussions

Post the discussion to improve the above solution.