1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Ket [755]
2 years ago
11

Write a program to display MPH (Miles per Hour). Create a function to calculate the MPH. Ask the user for the number of miles dr

iven and the number of minute it took to drive that many miles. Validate that both the number of miles and the number of minutes is a positive, non-zero number. Pass both the number of miles and the number of minutes to the function, and have the function return the MPH.
Computers and Technology
1 answer:
puteri [66]2 years ago
7 0

Answer:

In Python:

def MPH(miles,minutes):

   mph = round(60 * miles/minutes,1)

   return mph

   

miles = float(input("Miles: "))

minutes = float(input("Minutes: "))

if miles>0 and minutes>0:

   print("MPH: ",MPH(miles,minutes))

else:

   print("Positive inputs only")

Explanation:

This defines the function

def MPH(miles,minutes):

This calculates mph rounded to 1 decimal place

   mph = round(60 * miles/minutes,1)

This returns the calculated mph

   return mph

The main begins here

This gets input for miles    

miles = float(input("Miles: "))

This gets input for minutes

minutes = float(input("Minutes: "))

If miles and minutes are positive

if miles>0 and minutes>0:

This calls the MPH function

   print("MPH: ",MPH(miles,minutes))

If otherwise, this prompts the user for positive inputs

<em>else:</em>

<em>    print("Positive inputs only")</em>

You might be interested in
Please list the computer data hierarchy from bit to database
vladimir2022 [97]

Answer:

 Data hierarchy is basically define to the data which is organized in the systematic manner. The main concept of the data hierarchy is to check the basic structure of the data. It basically involve the fields records and files for the data organization.

The following is the list of the computer data hierarchy from nit to address are:

1) Bit: It is the smallest unit of the data.

2) Field: The collection of all the characters in the data is known as field.

3) Record: The collection of the different fields is known as records.

4) File: The collection of various types of records in the database is known as file.

8 0
3 years ago
What is the ascii code for the letter D
PilotLPTM [1.2K]

Answer:

068

Explanation:

Or if you want binary it's 01000100

4 0
2 years ago
Which of the following would be the most appropriate way to define a method that calculates and returns the final price, after t
Oksanka [162]

D. I hope it helped
5 0
2 years ago
The following code processes a file containing five positive numbers. What will the variable $result contain after the code is e
Tanzania [10]

Answer:

highest of five numbers in the file

Explanation:

  • This code reads the file "some-file.txt" and saves the result in variable "somefile"
  • The runs a for loop for a count of 5.
  • In each loop it compares the current value of the file with the value of the variable result and if the result is true it updates the value of the variable result.
  • At the end of this code the variable result will contain the highest value in the file "some-file.txt" and print it.

3 0
3 years ago
You can open an HTML document only in ________.
oksano4ka [1.4K]

Answer:

You can open a HTML document in internet explorer usually browsers can open HTML files.

6 0
2 years ago
Other questions:
  • Which functions are performed by server-side code??​
    10·1 answer
  • When might it be necessary or advisable to write a shell script instead of a shell function? give as many reasons as you can thi
    15·1 answer
  • Why is it important to begin development of a software solution with a programming design in place? A programming design summari
    11·2 answers
  • In round-robin scheduling,a) the time quantum should be larger than the context switch time. b) the time quantum should be as sm
    15·1 answer
  • There are local administrators for each of the departments, excluding the IT. These local administrators will use the local admi
    7·1 answer
  • Write a function maxTemp which takes a filename as string argument and returns the maximum temperature as float type for the wee
    13·1 answer
  • Assuming 8-bit 2's complement notation, what is the result of subtracting 00001001 from 00001101?
    11·1 answer
  • The merge and center
    14·1 answer
  • During the data transmission there are chances that the data bits in the frame might get corrupted. This will require the sender
    6·1 answer
  • You have been asked to replace a cracked screen on a laptop. The replacement screen was delivered today, but it did not include
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!