Coding attempt in PYTHON (bmi_calculator)

This is my first attempt in python coding and tried-out to create a script in python for bmi_calculator.

* create file as bmi_calculator.py
* paste the below code
* # python bmi_calculator.py


#!/usr/bin/env python
name = raw_input('Enter your Name:\t')
height = input('Enter your Height "In Centimeter":\t')
weight = input('shall we know your weight"In Kg":\t')
he = float(height) / 100 # cm to m
suwe = he * he
maa = weight / suwe
#print 'Name:', name
#print 'Height:', height
#print 'Weight:', weight
ma = round(maa)
print 'So, %s your BMI is:\t'  % name, ma
print 'Rount of value:\t', int(ma)
mx = int(ma)
print 'Your Health status is:'
if mx < 19:
        print 'Underweight'
elif mx >= 19 and mx <= 25:
        print 'Normal'
elif mx >= 25 and mx <= 30:
        print 'Overweight'
elif mx >= 30:
        print 'Too Fat, kindly start the workout right now !'
print 'Thank you !'

output:


BMI_CALCULATOR In Python3:

#!/usr/bin/python3
name = input('Enter your Name:\t')
height = input('Enter your Height "In Centimeter":\t')
weight = input('shall we know your weight"In Kg":\t')
he = float(height) / 100 # cm to m
suwe = he * he
maa = float(weight) / float(suwe)
#print 'Name:', name
#print 'Height:', height
#print 'Weight:', weight
ma = round(maa)
print ('So, %s your BMI is:\t'  % name, ma)
print ('Rount of value:\t', int(ma))
mx = int(ma)
print ('Your Health status is:')
if mx < 19:
 print ('Underweight')
elif mx >= 19 and mx <= 25:
 print ('Normal')
elif mx >= 25 and mx <= 30:
 print ('Overweight')
elif mx >= 30:
 print ('Too Fat, kindly start the workout right now !')
 print ('Thank you !')

Simple way to find the year of birth - calculator in python3:

#!/usr/bin/python3
mymsg = input('Enter your name: ')
print ('Okay, Let\'s find ' + mymsg + '\'s year of birth !' )
ga = input('Enter your age(completed age): ')
ag = ( 1330 - int(ga) + 686 )
print ("Thanks", mymsg +', '+  "Your Year of Birth: ", ag)

Comments

Popular posts from this blog

yum failed 6 times. Cannot continue!

Resolved: DOCKER: Error response from daemon: Could not attach to network / rpc error: code = 7 desc = network not manually attachable.

unexpectedly shrunk window (repaired) in dmesg log - TCP Peer