Question

In: Computer Science

((PYTHON)) Finish the calories_burned_functions.py program that we started in class. Take the original calories_burned program and...

((PYTHON))

Finish the calories_burned_functions.py program that we started in class. Take the original calories_burned program and rework it so that it uses two functions/function calls.

Use the following file to get your program started:

"""

''' Women: Calories = ((Age x 0.074) - (Weight x 0.05741) + (Heart Rate x 0.4472) - 20.4022) x Time / 4.184 '''
''' Men: Calories = ((Age x 0.2017) + (Weight x 0.09036) + (Heart Rate x 0.6309) - 55.0969) x Time / 4.184 '''
"""
#Declare Variable names and types

age_years = int(input())
weight_pounds = int(input())
heart_bpm = int(input())
time_minutes = int(input())

#Performing Calculations

calories_woman = ( (age_years * 0.074) - (weight_pounds * 0.05741) + (heart_bpm * 0.4472) - 20.4022 ) * time_minutes / 4.184

calories_man = ( (age_years * 0.2017) + (weight_pounds * 0.09036) + (heart_bpm * 0.6309) - 55.0969 ) * time_minutes / 4.184

#Print and format results in detail

print('Women: {:.2f} calories'.format(calories_woman))
print('Men: {:.2f} calories'.format(calories_man))

"""

#Here are the functions to this program

def calc_calories_woman(years, pounds, heartrate, minutes):
  
return ( (age_years * 0.074) - (weight_pounds * 0.05741) + (heart_bpm * 0.4472) - 20.4022 ) * time_minutes / 4.184

#This is the main part of the program

#------------------------------------------------------------------------------

#Prompt the user at the keyboard for the necessary information

age_years = int(input("Please enter your age: "))
weight_pounds = int(input("Please enter your weight: "))
heart_bpm = int(input("Please enter your heart rate: "))
time_minutes = int(input("Please enter the time: "))

#Calculate the calories

calories_woman = ( (age_years * 0.074) - (weight_pounds * 0.05741) + (heart_bpm * 0.4472) - 20.4022 ) * time_minutes / 4.184

calories_man = ( (age_years * 0.2017) + (weight_pounds * 0.09036) + (heart_bpm * 0.6309) - 55.0969 ) * time_minutes / 4.184

#Print the results

print('Women: {:.2f} calories'.format(calories_woman))
print('Men: {:.2f} calories'.format(calories_man))

Solutions

Expert Solution

Python code pasted below.

#Function 1 for calculating the calories of women
def calc_calories_woman(years, pounds, heartrate, minutes):
return ( (age_years * 0.074) - (weight_pounds * 0.05741) + (heart_bpm * 0.4472) - 20.4022 ) * time_minutes / 4.184
#Function 1 for calculating the calories of men
def calc_calories_man(years, pounds, heartrate, minutes):
return ( (age_years * 0.2017) - (weight_pounds * 0.057419036) + (heart_bpm * 0.6309) - 55.0969) * time_minutes / 4.184
#main program
#Prompt the user at the keyboard for the necessary information
age_years = int(input("Please enter your age: "))
weight_pounds = int(input("Please enter your weight: "))
heart_bpm = int(input("Please enter your heart rate: "))
time_minutes = int(input("Please enter the time: "))
#Function call 1 and print the results
print('Women: {:.2f} calories'.format(calc_calories_woman(age_years,weight_pounds,heart_bpm,time_minutes)))
#Function call 2 and print the results
print('Men: {:.2f} calories'.format(calc_calories_man(age_years,weight_pounds,heart_bpm,time_minutes)))

Python code in IDLE pasted for better understanding of the indent.

Output Screen


Related Solutions

Finish the calories_burned_functions.py program that we started in class. Take the original calories_burned program and rework...
Finish the calories_burned_functions.py program that we started in class. Take the original calories_burned program and rework it so that it uses two functions/function calls. Use the following file to get your program started: """ ''' Women: Calories = ((Age x 0.074) - (Weight x 0.05741) + (Heart Rate x 0.4472) - 20.4022) x Time / 4.184 ''' ''' Men: Calories = ((Age x 0.2017) + (Weight x 0.09036) + (Heart Rate x 0.6309) - 55.0969) x Time / 4.184 '''...
PYTHON - please finish the methods below that are apart of a linkedlist class #return the...
PYTHON - please finish the methods below that are apart of a linkedlist class #return the data value at index(position) in the list. values remain unchanged def __getpos__(self, position): #do not change, checks for valid index if self.size == 0: raise IndexError elif position is None: return self.pop(self.size - 1) elif type(position) != int: raise TypeError elif position < 0 or position >= self.size: raise IndexError #replace the data value at requested position(index). return nothing def __setpos__(self,position,value): #do not change,...
JAVA PROGRAM: FINISH THE FOLLOWING METHOD IN THE CLASS BasicBioinformatics. public class BasicBioinformatics { /** *...
JAVA PROGRAM: FINISH THE FOLLOWING METHOD IN THE CLASS BasicBioinformatics. public class BasicBioinformatics { /** * Calculates and returns the reverse complement of a DNA sequence. In DNA sequences, 'A' and 'T' * are complements of each other, as are 'C' and 'G'. The reverse complement is formed by * reversing the symbols of a sequence, then taking the complement of each symbol (e.g., the * reverse complement of "GTCA" is "TGAC"). * * @param dna a char array representing...
Python Explain Code #Python program class TreeNode:
Python Explain Code   #Python program class TreeNode:    def __init__(self, key):        self.key = key        self.left = None        self.right = Nonedef findMaxDifference(root, diff=float('-inf')):    if root is None:        return float('inf'), diff    leftVal, diff = findMaxDifference(root.left, diff)    rightVal, diff = findMaxDifference(root.right, diff)    currentDiff = root.key - min(leftVal, rightVal)    diff = max(diff, currentDiff)     return min(min(leftVal, rightVal), root.key), diff root = TreeNode(6)root.left = TreeNode(3)root.right = TreeNode(8)root.right.left = TreeNode(2)root.right.right = TreeNode(4)root.right.left.left = TreeNode(1)root.right.left.right = TreeNode(7)print(findMaxDifference(root)[1])
A student is considering whether to finish their university program in four​ consecutive​ years, or take...
A student is considering whether to finish their university program in four​ consecutive​ years, or take a year off and work for some extra​ cash.​ ​​Required: ​​a. Identify at least two revenues or costs that are relevant to making this decision. Explain why each is relevant. ​​b. Identify at least two costs that would be considered sunk costs for this decision. ​​c. Comment on at least two qualitative consideration for this decision.
Fill in needed code to finish Mastermind program in Python 3.7 syntax Plays the game of...
Fill in needed code to finish Mastermind program in Python 3.7 syntax Plays the game of Mastermind. The computer chooses 4 colored pegs (the code) from the colors Red, Green, Blue, Yellow, Turquoise, Magenta. There can be more than one of each color, and order is important. The player guesses a series of 4 colors (the guess). The computer compares the guess to the code, and tells the player how many colors in the guess are correct, and how many...
Write a Python 3 program called “parse.py” using the template for a Python program that we...
Write a Python 3 program called “parse.py” using the template for a Python program that we covered in this module. Note: Use this mod7.txt input file. Name your output file “output.txt”. Build your program using a main function and at least one other function. Give your input and output file names as command line arguments. Your program will read the input file, and will output the following information to the output file as well as printing it to the screen:...
Write a python program that will take in the number of call minutes used. Your program...
Write a python program that will take in the number of call minutes used. Your program will calculate the amount of charge for the first 200 minutes with a rate of $0.25; the remaining minutes with a rate of $0.35. The tax amount is calculated as 13% on top of the total. The customer could have a credit that also has to be considered in the calculation process. Finally, the program displays all this information. Below is a sample run:...
We started creating a Java class for Car. In this lab we are going to complete...
We started creating a Java class for Car. In this lab we are going to complete it in the following steps: 1- First create the Car class with some required instance variables, such make, model, year, price, speed, maxSpeed, isOn, isMoving, and any other properties you like to add. 2- Provide couple of constructors for initializing different set of important properties, such as make, model, year, and price. Make sure that you do not repeat initialization of instance variables in...
We started class with an overview of ancient schools of Greek thought, and we are finishing...
We started class with an overview of ancient schools of Greek thought, and we are finishing with the branching out of psychological science from the basic schools of thought that it had established by 1970 or so (Humanistic, Behavioral, Psychoanalytical, and Cognitive). Please match these major areas of psychology to the early Greek thinkers (Plato, Homer, Aristotle, and Heraclitus). Include in your response the ideas of personality differences, cognitive processing, etc.... how did each of the major schools of thought...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT