my_name = 'Zed A. Shaw' my_age = 35 # not a lie my_height = 74 #inches my_weight = 180 #lbs my_eyes = 'Blue' my_teeth = 'White' my_hair = 'Brown' whatever = 'Brown' print "Let's talk about %s." % my_name print "He's %d inches tall." % my_height print "He's %d pounds heavy." % my_weight print "Actually, that's not too heavy." print "He's got %s eyes and %s hair." % (my_eyes, my_hair) print "His teeth are usually %s depending on the coffee." % my_teeth # this line is tricky, try to get it exactly right print "If i add %d, %d, and %d I get %d." % (my_age, my_height, my_weight, my_age + my_height + my_weight) # %s refers to following defined strings, %d refers to following defined doubles # %r says "print this no matter what" # %s/d/r are formatters, telling python to take the variable on the right and # put it in to replace the %s/d/r with its value. # can use round() function # try making the numbers in the script your measurements. It's weird, but talking about yourself will make it seem more real. print "What is str(%r)" % whatever print "what is print(str(whatever))" print (str(whatever))
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