Python Forum

Full Version: School assignment
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
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
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
If statements are shows in the python documents tutorial here, and comparisons
thnx seems like ive got some reading to do
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.