print "I will now count my chickens:" print "Hens", 25 + 30 / 6 # + = addition print "Roosters", 100 - 25 * 3 % 4 # - = subtraction and * = multiplication; % gives the remainder after division print "Now I will count the eggs:" print 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6 #the percent symbol gives the remainder of an operation #when whole numbers are used in division, the answer is rounded; this doesn't happen when decimals are used though print 34.25 / 42.1 #as shown here print "Is it true that 3 + 2 < 5 - 7?" print 3 + 2 < 5 - 7 # less than/greater sign/ other inequalities produce # either true or false as output; can be used to compare # two different quantities print "What is 3 + 2?", 3 + 2 print "What is 5 - 7?", 5 - 7 print "Oh, that's why it's False." print "How about some more." print "Is it greater?", 5 > -2 print "Is it greater or equal?", 5 >= -2 print "Is it less or equal?", 5 <= -2
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