9th Jul 2017, 4:30 PM
S Seven
S Seven - avatar
3 ответов
+ 1
Looks pretty good! A couple things you could do to tighten it up. Consider revising how you check if the value sex == 'female'. You should consider using sex.lower() == 'female'. That way if the user enters in 'Female' or 'FEMALE' it is all still correct. In the same If statement I might consider using elif sex.lower() == 'male', and then having the else statement return an error or statement that indicates to the user the value entered was incorrect. You could have additional error handling if you were having the user enter values as an input (I know SoloLearn is not great for that), but sometimes to catch if a user accidentally enters a letter in a number field. I might apply the roundup function before you leave the GetBMR Function only cause it makes the final print statement a little easier to read. And you are probably not going to return that value without applying the roundup to it anyway. Lastly, I think this is an ideal situation for using a class, since you may want to add other attributes or get other statistics on this person. Maybe BMI later, and you wouldn't have to keep pushing the values. I don't know anything about BMR, but the value at the end of if female was +655 and only +66 at the end of if male. It looks like a huge difference so it appears like a type error, but you know better. Again, there is nothing wrong with your code, just a couple of optional ways you could add to it. :)
10th Jul 2017, 11:37 AM
Jim Tully
Jim Tully - avatar
0
Looks awesome, great job👍, was that all learned from solo learn?
11th Jul 2017, 2:33 AM
Ali
0
Thank you Jim and Ali. I will make those changes much appreciated! And yes Ali I learned it all on here. I had to google how to round up but I think that was it.
11th Jul 2017, 3:53 AM
S Seven
S Seven - avatar