Need help with my homework. It's apparent to me that I don't fully understand how to pass information to a function. I'm following examples the professor has provided and I've googled a bunch of stuff about functions. I just don't know why it's not clicking. Can someone please explain this to me like I'm a 2-year-old?
Here's what I need to do:
Here's what it should look like (THIS DOESN'T DISPLAY CORRECTLY - PLEASE SEE ATTACHMENT AT THE BOTTOM OF THIS POST):
Here's my code:

Here's what I need to do:
Quote:When getting into a fitness program, you may want to figure out your target heart rate so you don’t overexert yourself. The Karvonen heart rate formula is one method you can use to determine your rate. Create a program that prompts for your age and your resting heart rate. Use the Karvonen formula to determine the target heart rate based on a range of intensities from 55% to 95%. Generate a table with the results as shown in the example output (format matters). The formula is
TargetHR = (((220 - age) - restingHR) * intensity) + restingHR
Here's what it should look like (THIS DOESN'T DISPLAY CORRECTLY - PLEASE SEE ATTACHMENT AT THE BOTTOM OF THIS POST):
Quote:Resting Pulse: 65 Age: 22
Intensity | Rate
----------|--------
55% | 138 bpm
60% | 145 bpm
65% | 151 bpm
: : (extra lines omitted)
85% | 178 bpm
90% | 185 bpm
95% | 191 bpm
Here's my code:
def problem6_1(): table_width = 10 table_height = .95 def user_input(): age = int(input("What is your age?")) restingHR = int(input("What is your resting pulse?")) return(age,restingHR) def print_header(table_width): print("Intensity | Rate".format(''), end="") #print("{:10}|".format('-')) def print_table(table_width, table_height, age, restingHR): for i in range(.55, table_height+.5): print("{:10}|".format(i), end="") for j in range(1, table_width+1): print("{:10}".format((((220 - age) - restingHR) * i) + restingHR), end="") print() user_input() print_header(table_width) print_table(table_width, table_height) problem6_1()Here's my error:
Error:---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-2-49e95b7c904f> in <module>()
24 print_table(table_width, table_height, age, restingHR)
25
---> 26 problem6_1()
27
28
<ipython-input-2-49e95b7c904f> in problem6_1()
22 user_input()
23 print_header(table_width)
---> 24 print_table(table_width, table_height, age, restingHR)
25
26 problem6_1()
NameError: name 'age' is not defined
What am I doing wrong? Additionally, how do I add the underscores beneath Intensity and Rate? They're not the same length and he says formatting counts.Quote:Intensity | Rate
----------|--------