Python Forum
School assignment - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: School assignment (/thread-1482.html)



School assignment - Ronaldo - Jan-06-2017

Hi guys,

I need to develop the following.

A program that prompts the user for their age, on basis of their age the program needs to calculate how many "breaths" and how many "heartbeats"the person has had in their life.

This is the data i have to work with

Breaths per minute

Infant ~ 30–60
1–4 years ~ 20–30
5–14 years ~ 15–25
adults ~ 12–20

Average heart rate 67.5 beats per second

Appreciate any help i can get


RE: School assignment - nilamo - Jan-06-2017

Have you written anything yet? Show us some code, and we can help nudge you in the right direction, but we won't write it for you :p


RE: School assignment - Ronaldo - Jan-06-2017

Hi,

Yes

# Program greeting
Print("This program calculates how many breaths and heartbeats u have had in your lifetime")

# get age
age = int(input('Enter age'))

i know i need to work with the if, if else commands, but i dont know how exactly pls i need help

# Program greeting
Print("This program calculates how many breaths and heartbeats u have had in your lifetime")

# get age
age = int(input('Enter age: '))

bpm_infant = (30 + 20) / 2
bpm_1_to_4 = (20 + 30) / 2
bpm_5_to_14 = (15 + 25) / 2
bpm_adults = (12 + 20) / 2

num_min_day = 24 * 60
num_min_year = 365 * num_min_day
heart_rate_day = 67,5 * 24 * 60
heart_rate_year = 365 * heart_rate_day
This is how far I am right now Angel


RE: School assignment - Yoriz - Jan-06-2017

If statements are shows in the python documents tutorial here, and comparisons


RE: School assignment - Ronaldo - Jan-06-2017

thnx seems like ive got some reading to do


RE: School assignment - Ofnuts - Jan-08-2017

One possible way:
  1. Pre-compute how much heartbeats/breaths you have at the age limits given
  2. Given an age:
  • find the age category,
  • add the pre-computed data for the lower bound of the category to heartbeats/breaths between that lower bound and the actual age.