answer.
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
Marysya12
28 days ago
5

Write a function so that the main program below can be replaced by the simpler code that calls function mph_and_minutes_to_miles

(). Original main program:miles_per_hour = float(input())minutes_traveled = float(input())hours_traveled = minutes_traveled / 60.0miles_traveled = hours_traveled * miles_per_hourprint('Miles: %f' % miles_traveled)Sample output with inputs: 70.0 100.0Miles: 116.666667

Computers and Technology
1 answer:
Natasha_Volkova [897]28 days ago
6 0

Answer:

def mph_and_minutes_to_miles(hours_traveled, miles_traveled):

   hours_traveled = minutes_traveled / 60

   miles_traveled = hours_traveled * miles_per_hour

   print('Miles: %f' % miles_traveled)

Explanation:

This function, written in Python, specifies two input parameters (hours_traveled, miles_traveled)

When executed, the main function prompts the user for necessary data, calls this method, and passes the inputs as arguments. Refer to the complete code and output that follows.

You might be interested in
Which of the following is an absolute cell reference
Amiraneli [921]
The term for the contents of the cell is an absolute cell reference. Excel allows each cell to contain numbers, strings, or formulas. Users can enter values into a cell and apply built-in formulas to perform calculations and obtain results in the target cell. When users attempt to copy and paste data into another cell, they can use the paste special option to select values, meaning that only the data is copied, excluding the formula; this is known as the absolute reference of the cell. With paste special, users can also replicate images or Unicode.
6 0
20 days ago
The is_positive function should return True if the number received is positive, otherwise it returns None. Can you fill in the g
zubka84 [945]

Question:

The function is_positive should yield True if the supplied number is positive; otherwise, it gives None. Can you fill in the blanks accordingly?

def is_positive(number):

       if  _____ :

           return _____

Answer:

def is_positive(number):

   if (number > 0):

       return True

  else:

       return "None"

---------------------------------------------------------------------------------

Code Test and Sample Output:

print(is_positive(6))

>> True

print(is_positive(-7))

>> None

----------------------------------------------------------------------------------

Explanation:

This segment of code is composed in Python.

To explain it further, let's break down the content of each line;

Line 1: Creates a function identified as is_positive which takes in a variable number.i.e

def is_positive(number):

Line 2: Evaluates if the given number is positive; a number qualifies as positive if it exceeds zero. i.e

if (number > 0):

Line 3: Produces a boolean result of True when the input number is positive. i.e

return True

Line 4: Initiates the else block to be executed in case the input number isn’t positive. i.e

else:

Line 5: Returns the string "None" when the number is not positive. i.e

return "None"

When combined, this results in;

===============================

def is_positive(number):

   if (number > 0):

       return True

   else:

       return "None"

================================

An instance test for the code provided an argument of 6 and -7, resulting in True and None respectively. i.e

print(is_positive(6))   = True

print(is_positive(-7))  = None

8 1
1 month ago
Read 2 more answers
Someone else can drive your car if _____.
8_murik_8 [892]

Answer:

C. you possess insurance documentation

Explanation:

Being a resident does not automatically grant permission to operate a vehicle. For instance, a person might have residency but might also have a suspended license, which means they are unable to drive.

Typically, insurance applies to the CAR rather than the individual. Therefore, the general guideline is:

A different person is permitted to drive your vehicle if you possess proof of insurance.

6 0
27 days ago
Read 2 more answers
Write a function called simulate_several_key_strikes. It should take one argument: an integer specifying the number of key strik
oksian1 [804]

Answer:

The code for the solution is implemented using Python 3.

  1. import random
  2. import string
  3. def simulate_several_key_strikes(l):
  4.    char_set = string.ascii_lowercase
  5.    return ''.join(random.choice(char_set) for i in range(l))
  6. print (simulate_several_key_strikes(10))

Explanation:

This program is designed to create random characters, and the quantity of characters produced is determined by the user's input. Therefore, it is necessary to import the random library (Line 1). Additionally, we incorporate the string module to access its associated method for generating English letters (Line 2).

Then, we define the function simulate_several_key_strikes that accepts one parameter, l. Inside this function, the ascii_lowercase method is utilized to establish the character set of lowercase letters, which is stored in the variable char_set (Line 5). The random.choice method randomly selects a character from char_set, concatenating it with an empty string (Line 6). A for-loop is utilized to produce a total of l characters, generating the final output.

To test the function, we input 10 as an argument, producing a sample output such as:

xuiczuskoj

7 0
1 month ago
Olivia needs to get permission to use a graph of data gathered by a trade association she plans to include the graph in a report
Natasha_Volkova [897]

She can locate the copyright notice on the webpage that features the graph.

Explanation: ~Apex~

3 0
26 days ago
Read 2 more answers
Other questions:
  • When using the Python shell and code block, what triggers the interpreter to begin evaluating a block of code
    14·1 answer
  • 6. Write pseudo code that will perform the following. a) Read in 5 separate numbers. b) Calculate the average of the five number
    6·1 answer
  • What happened if the offshore team members are not able to participate in the iterations demo due to timezone/infrastructure iss
    12·1 answer
  • Sarah works in a coffee house where she is responsible for keying in customer orders. A customer orders snacks and coffee, but l
    13·2 answers
  • Marien is using the Council of Science Editors (CSE) style guidelines to write her research paper. What is her most likely topic
    13·1 answer
  • Tag groups can be nested up to ____ levels deep, with up to _______ tag subgroups under a single parent.
    14·1 answer
  • Write a statement that assigns finalResult with the sum of num1 and num2, divided by 3. Ex: If num1 is 4 and num2 is 5, finalRes
    15·1 answer
  • An array subscript can be an expression, but only as long as the expression evaluates to what type?
    7·1 answer
  • Write a program that prompts the user to enter three cities and displays them in ascending order. Here is a sample run: Enter th
    8·1 answer
  • An application specifies a requirement of 200 GB to host a database and other files. It also specifies that the storage environm
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!