Calculate target heart rate during fitness training

Assignment Help Python Programming
Reference no: EM132356701

LAB - FUNCTIONS

OBJECTIVES

In this lab assignment, students will learn:

- How to write functions that multiple parameters

- How to write code to pass multiple arguments to a called function

- How to write code to generate random numbers

- How to use math functions

GOALS

In this lab assignment, students will demonstrate the abilities to:

- Write functions that multiple parameters

- Write code to pass multiple arguments to a called function

- Write code to generate random numbers

- Use math functions

INSTRUCTION AND PROBLEMS

Write a Python program for each of the problems in this lab. The following is an example.

Lunch combos in the cafeteria of a community college include an entrée and a beverage. Write a program for customers to enter their choices.

Define and use the following two functions:

chooseEntree : handle choice of entrée
chooseBeverage: handle choice of beverage

Also write and use a main function to implement the mainline logic of the program.

Python program:

__author__ = 'Man-Chi Leung'

defmain():
chooseEntree()
print()
chooseBeverage()

defchooseEntree():
print('Entree:')
print('Enter 1 for fish and chips')
print('Enter 2 for burger and fries')
print('Enter 3 for fried chicken and smashed potato')
print('Enter 4 for barbecue pork')
entree = int(input('Please enter your choice: '))
if entree == 1:
print('You have chosen fish and chips')
elifentree == 2:
print('You have chosen burger and fries')
elifentree == 3:
print('You have chosen fried chicken and smashed potato')
elifentree == 4:
print('You have chosen barbecue pork')

defchooseBeverage():
print('Beverage:')
print('Enter 1 for iced tea')
print('Enter 2 for soda')
print('Enter 3 for coffee')
beverage = int(input('Please enter your choice: '))
if beverage == 1:
print('You have chosen iced tea')
elifbeverage == 2:
print('You have chosen soda')
elifbeverage == 3:
print('You have chosen coffee')

main()

Please use PyCharm to type and test your programs. Submit the Python files to Blackboard for credit. In this lab, you should submit 4 Python files, one for each problem.

PROBLEM 1

Write a program to convert US dollar to Japanese yen. This program has two functions: main and convert_to_yen. Please do the following:

(a) In the main function, ask the user to enter amount in US dollar and conversion rate.

(b) In the main function, call the convert_to_yen function. Pass the amount in US dollar and conversion rate as arguments.

(c) In the convert_to_yen function, write code to convert US dollar to Japanese yen and display the amount in Japanese yen.

The following is an example.

Enter amount in US dollar: 100

Enter conversion rate: 124.21

Equivalent amount in Japanese Yen: 12421.0

Save your Python program in a file named Lab09P1.py. Submit the file to Blackboard for credit.

PROBLEM 2

Write a program to calculate target heart rate during fitness training. This program has two functions: main and heart_rate_calculator. Please do the following:

(a) In the main function, ask the user to enter age and resting heart rate.
(b) In the main function, call the heart_rate_calculator function. Pass the ageand resting heart rate as arguments.
(c) In the heart_rate_calculator function, write code to calculate target heart rate during fitness training with the following formula:

Target hart rate = (220 - age - resting heart rate) * 0.4 + resting heart rate

Display target heart rate.

The following is an example.

Enter age: 40
Enter resting heart rate: 70
Your target heart rate is 114.0

Save your Python program in a file named Lab09P2.py. Submit the file to Blackboard for credit.

PROBLEM 3

Write a program to play the rock-paper-scissors game. A single player is playing against the computer. In the main function, ask the user to choose rock, paper or scissors. Then randomly pick a choice for the computer. Pass the choices of the player and the computer to a find_winner function, which determines and displays the outcome of the game.

The following are three examples.

Enter 1 for rock, 2 for paper or 3 for scissors: 1
You chose rock. The computer chose scissors. You won.

Enter 1 for rock, 2 for paper or 3 for scissors: 3
You chose scissors. The computer chose rock. The computer won.

Enter 1 for rock, 2 for paper or 3 for scissors: 1
Both you and the computer chose rock. Tie.

Save your Python program in a file named Lab09P3.py. Submit the file to Blackboard for credit.

PROBLEM 4

Write a program to do the following. Generate a random floating number between 12.5 and 17.5. Calculate the square root of the random number. Display both the random number and its square root.

The following is an example.

The square root of 17.325617070542933 is 4.162405202589356

Reference no: EM132356701

Questions Cloud

Ecplain christian perspective of the nature of spirituality : In 250-300 words, explain the Christian perspective of the nature of spirituality and ethics in contrast to the perspective of postmodern relativism.
Describe posts or conversations in which you have engaged : In 500-750 words, summarize the findings of your review. Include the following: Describe the posts or conversations in which you have engaged that might.
Design a cooling system for semiconductor laser array : Design a cooling system for semiconductor laser array Literature review needs to be based on ANSYS finite element analysis and modeling
Describe scope and role of nursing in current interventions : Describe the scope and role of nursing in current interventions that target a critical health care issue. Recommend evidence-based ways to expand the scope.
Calculate target heart rate during fitness training : CIS115-INTRODUCTION TO PROGRAMMING AND LOGIC-Write a program to calculate target heart rate during fitness training. This program has two functions.
Data analytics capabilities for health care organization : Why would you invest in enterprise data warehousing, data mining, and data analytics capabilities for your health care organization?
Explain the influence of altruistic organizations on health : Explain the influence of altruistic organizations on health and health care practices associated with a global health care issue. Explain how health care.
Trends and predicted trends in e-business and e-commerce : There are many trends and predicted trends in e-business and e-commerce, including (but not limited to!):
Provide name of company and company website : Question 1: Provide the name of the company and the company's website.

Reviews

Write a Review

Python Programming Questions & Answers

  Modify the merge sort algorithm to sort a list of integers

Modify the merge sort algorithm to sort a list of integers in descending order by using the following list. Your code with comments.

  Compute the tax withholding for the employee

Compute the tax withholding for the employee by multiplying the total pay by the tax rate divided by 100. Store withholding in an appropriately-named variable.

  Develop python script that will implement the given command

Write a python script that will implement the following command: merge sourcedirectory1 sourcedirectory2 destinationdirectory

  What is complexity in asymptotic notation of your solution

Write a program in Python to draw the following figure: What is the complexity in asymptotic notation of your solution? Return the "centered" average of an array of ints, which we'll say is the mean average of the values.

  Write a python program that will ask the user for a string

Write a Python program that will ask the user for a string and then use the number of characters in the string to print out whether that value is odd or even.

  Develop a script containing three new methods

"Object-Oriented Programming," of Introduction to Computing and Programming in Python, a Turtle is an object from the class Turtle with the following features.

  Display all pays in proper currency format with the dollar

Your program should prompt for the weekly hours worked and the regular hourly pay rate. Output should display the regular pay, overtime pay.

  Write the new methods you would have to implement in class

Write the class Box3D that inherits from Rectangle2D and uses the additional public attribute d. Every methods should use the super operator.

  Write a string expression whose value is the string

Write a string expression whose value is the string equivalent of each these variables joined by a single period .

  Write code to show the usage of all of the function you have

This function accepts a string of characters and displays it 5 times on the screen. In your main function, you will show its usage.

  Write a python script that reads and analyses the data

ICT702 Task 2 - Apply relevant Python programming concepts to a data analysis challenge - Read data from real sources and wrangle it into the form you need

  Determine which are missing from the input parameter

Your implementation should use a histogram from the histogram function. It should also use the global variable alphabet.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd