print "Let's practice everything." print 'You\'d need to know \'bout escapes with \\ that do \n newlines and \t tabs.' poem = """ \t The lovely world with logic so firmly planted cannot discern \n the needs of love nor comprehend passion from intuition and requires and explanation \n\t\t where there is none. """ print "-----------" print poem print "-----------" five = 10 - 2 + 3 - 6 print "This should be five: %s" % five def secret_formula(started): jelly_beans = started * 500 jars = jelly_beans / 1000 crates = jars / 100 return jelly_beans, jars, crates start_point = 10000 #Since secret_formula returns three ordered values, it will assign them to the variables specified here in order. #The first variable, bean, receives jelly_beans from secret_formula, and so on. beans, jars, crates = secret_formula(start_point) print "With a starting point of: %d" % start_point print "We'd have %d beans, %d jars, and %d crates." % (beans, jars, crates) #Modifying start_point will update beans, jars, and crates accordingly because they reference it anew each time #they are called. start_point = start_point / 10 print "We can also do that this way:" print "We'd have %d beans, %d jars, and %d crates." % secret_formula(start_point)
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