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

  Write a python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

  Python atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

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