[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Python Program
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /wsr/ - Worksafe Requests

Thread replies: 5
Thread images: 1
File: 4chan.png (73 KB, 828x461) Image search: [Google]
4chan.png
73 KB, 828x461
Any python programmers out there wanna take a look at my code and see why it isn't working

def vo2max_resting(age, resting_pulse):
""" takes age in years and resting pulse in beats per minute"""
return 15.3 * (208 - 0.7 * age) / resting_pulse
def vo2max_step_3min(gender, pulse):
"""returns pulse according to the 3 minute step test"""
if gender is "m":
return 111.33 - (0.42 * pulse)

elif gender is "f":
return 65.81 - (0.1847 * pulse)

else:
return -1
"""program that returns vo2max after input from users"""
def main():
"""returns vo2max after user input"""
name_string = input("Enter given name: ")
name = str(name_string.capitalize())

family_name_string = input("Enter family name: ")
family_name = str(family_name_string.upper())

gender_string = input("Enter gender (m/f): ")
gender = str(gender_string)

age_string = input("Enter age (in years): ")
age = int(age_string)

resting_string = input("Enter resting heart rate (bpm): ")
resting = int(resting_string)


step_test_string = input("Enter pulse after 3min step test: ")
step_test = int(step_test_string)

if gender is "m":
print("----------------------------------------")
print("Results for: " + family_name + "," + " " + name)
print('vo2max from resting pulse =')

main()

test_age = 29
test_pulse = 100
result = vo2max_resting(test_age, test_pulse)
print('{:.2f}'.format(result))
>>
to many spaces bro
>>
>>81416
Python's syntax relies heavily on its indentation. If you're getting any errors from the code you just posted, fix the indentation because It ran just fine for me after manually indenting it.
>>
>>81416
Seems to be working fine here after I finished writing your main(). I added a few comments for you.
http://pastie.org/private/2qh8ic8x2pwrjsf4q8dw

Next time use pastebin or pastie like I did above so we can get the correct indentation. Also, next time post any error messages or describe what you mean by "isn't working." If you meant that the program isn't giving the correct result, I'd guess your formulas are wrong, because the code itself seems fine.
>>
>>81416
Holy shit, I did the first part of this a few days ago.

Why don't you post your whole course, so we can do the whole thing for you?
Thread replies: 5
Thread images: 1

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.