user = raw_input('user: ') # get user height and weight from db user_list = { 'nlivni': { 'age':32, 'height':67, 'weight':162} } height = user_list[user]['height'] age = user_list[user]['age'] weight = user_list[user]['age'] class User(object): def new_weight(self): """ Water accounts for about 70 percent of the total body weight of an average person. Muscle is roughly 75 percent water, 20 percent protein and 5 percent minerals and other matter. Body fat and bones are roughly 50 percent water. """ total_weight = raw_input('total weight: ') fat_weight = raw_input('fat weight: ') water_weight = raw_input('water weight: ') bone_weight = raw_input('bone_weight: ') return { 'total_weight': total_weight, 'fat_weight': fat_weight, 'water_weight': water_weight, 'bone_weight': bone_weight } def greet(self, user, hieght): print "hi, %s" % user print "height: %s\' %s\"" %(str(height/12), str(height%12)) u = User() u.greet(user, height) u.new_weight()
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question