Posted on by

Jan 02, 2010 BMI calculator. Python Forums on Bytes. The body mass index. Write a program that calculates a personâ€™s BMI and prints a. BMI calculator in Python. But overall, good job on writing your first program! Body mass index calculator in Swift.

Files32.com collects software information directly from original developers using software submission form. Sometimes it can happen that software data are not complete or are outdated. You should confirm all information before relying on it. Using crack, serial number, registration code, keygen and other warez or nulled soft is illegal (even downloading from torrent network) and could be considered as theft in your area. Files32 does not provide download link from Rapidshare, Yousendit, Mediafire, Filefactory and other Free file hosting service also. The software has been submitted by its publisher directly, not obtained from any Peer to Peer file sharing applications such as Shareaza, Limewire, Kazaa, Imesh, BearShare, Overnet, Morpheus, eDonkey, eMule, Ares, BitTorrent Azureus etc.

This is my first attempt at writing a programme: a BMI calculator written in Python. Please give me feedback on the programme overall, as well as how easy the code is to interpret and adapt. From sys import exit bmi = ['what is bmi?' , 'what is bmi', 'bmi', 'bmi?' ] male=['male','m'] female=['female', 'f'] def bmi_q(): print 'Very good! Let's start with your age.' Age= float(raw_input('How old are you%s?

>'%name)) height= float(raw_input('How tall are you, in m? >')) weight=float(raw_input('What do you weigh in kg? >')) Gender=raw_input('Finally, are you male or female? (No offense.) >') result = bmi_c(weight,height) analysis(result) def analysis(result): if result 25: print 'Your BMI is%d.' % round(result,2), 'You are far too fat, please eat less.'

Print 'A healthy BMI is between 18.5 and 25.' Exit(0) else: print 'Your BMI is%d.' % round(result,2), 'Congratulations! You're well fit.' Print 'A healthy BMI is between 18.5 and 25.'

Exit(0) def bmi_c(weight,height): return weight / (height**2) def consent_q(): unsure = True while True: print 'Would you like to calculate your BMI?' Consent = raw_input('>Answer: 'Yes ', 'No ', or 'What is BMI? ' >') if consent.lower() == 'no': print ('What did you open a script called 'BMI ' for then??? This is all I can do!' ) elif consent.lower() in bmi: print ''Wise man at CDC say: 'Body Mass Index (BMI) is a person's weight in kilograms divided by the square of height in meters.

A high BMI can be an indicator of high body fatness. BMI can be used to screen for weight categories that may lead to health problems but it is not diagnostic of the body fatness or health of an individual. ' '' elif consent.lower() == 'yes': unsure = False bmi_q() else: print 'Sorry, me no hablo ingles so good. Print 'Thank you for running the BMI script.' Print 'Before we begin, please tell me your name:' name=raw_input('>') print 'Hello%s, nice to meet you.' % (name) consent_q().

The main issue I see is inconsistent style. Sometimes you put spaces around certain operators, sometimes you don't. You want your code to be consistently formatted. Generally, it's best to always put a space before and after an operator, especially the assignment operator. It's even more strange to put a space before an operator, but not after (or vice versa).

This line, for example: age= float(raw_input('How old are you%s? >'%name)) would look much better like this: age = float(raw_input('How old are you%s?

>'% name)) You also switch between putting a space after commas in lists, and not doing so. I would change these lines: male=['male','m'] female=['female', 'f'] to look like this (notice the space after the first comma): male = ['male', 'm'] female = ['female', 'f'] Variables should always begin with a lowercase letter. Classes and constants can and should be capitalized, but not normal variables. So the Gender variable should be renamed to gender.

You should consider not asking for the user's gender and age unless you actually do something with that data, or at least don't assign it to variables because it'll go unused. I would also rename bmi_q, bmi_c, and consent_q to something more clear, so other people reading your code can immediately know what those function are supposed to do. Unit Operations Of Chemical Engineering Solutions Manual 7th Edition. Bmi_c could definitely be renamed to something like calculate_bmi, or even calc_bmi. And lastly, I'd always make sure your indention doesn't get messed up when pasting your code into a site like this. There's a few problems with invalid indention, but I'd imaging that happened when you put it in this question. (the indention in the question has been fixed now though) But overall, good job on writing your first program! Congrats, keep it up, and remember this quote from Phil Karlton: There are only two hard things in Computer Science: cache invalidation and naming things.