# Numbers And Math in Python

By: Zed A. Shaw Emailed: 1766 times Printed: 2513 times

 By: rohit kumar - how this program is work By: Kirti - Hi..thx for the hadoop in By: Spijker - I have altered the code a By: ali mohammed - why we use the java in ne By: ali mohammed - why we use the java in ne By: mizhelle - when I exported the data By: raul - no output as well, i'm ge By: Rajesh - thanx very much... By: Suindu De - Suppose we are executing

Every programming language has some kind of way of doing numbers and math. Do not worry, programmers lie frequently about being math geniuses when they really aren’t. If they were math geniuses, they would be doing math, not writing ads and social network games to steal people’s money.

This exercise has lots of math symbols. Let’s name them right away so you know what they are called. As you type this one in, say the names. When saying them feels boring you can stop saying them. Here are the names:

• + plus
• - minus
• / slash
• * asterisk
• % percent
• < less-than
• > greater-than
• <= less-than-equal
• >= greater-than-equal

Notice how the operations are missing? After you type in the code for this exercise, go back and figure out what each
of these does and complete the table. For example, + does addition.

``` 1 print "I will now count my chickens:" 2 3 print "Hens", 25 + 30 / 6 4 print "Roosters", 100 - 25 * 3 % 4 5 6 print "Now I will count the eggs:" 7 8 print 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6 9 10 print "Is it true that 3 + 2 < 5 - 7?" 11 12 print 3 + 2 < 5 - 7 13 14 print "What is 3 + 2?", 3 + 2 15 print "What is 5 - 7?", 5 - 7 16 17 print "Oh, that's why it's False." 18 19 print "How about some more." 20 21 print "Is it greater?", 5 > -2 22 print "Is it greater or equal?", 5 >= -2 23 print "Is it less or equal?", 5 <= -2```
What You Should See

``` \$ python ex3.py I will now count my chickens: Hens 30 Roosters 97 Now I will count the eggs: 7 Is it true that 3 + 2 < 5 - 7? False What is 3 + 2? 5 What is 5 - 7? -2 Oh, that's why it's False. How about some more. Is it greater? True Is it greater or equal? True Is it less or equal? False \$```

 Sponsored Links If this tutorial doesn't answer your question, or you have a specific question, just ask an expert here. Post your question to get a direct answer.

Be the first one to add a comment

Your email(required, will not be shown to the public):

Your sites URL (optional):

More Tutorials by Zed A. Shaw
 Formatted printing in Python Printing in Python Strings And Text in Python Variables And Printing in Python Variables And Names in Python Numbers And Math in Python Comments And Pound Characters in Python Your First Program in Python Installing gedit for python programming in Linux Installing gedit for python programming in Mac OS X

More Tutorials in python
 What is the need for Python language? How to compile python script and create .pyc file? How to find the current module name in python How to force rereading of a changed module in python UnboundLocalError in python call by reference in python Callable objects in python Ternary operator in python Hexadecimal and Octal integers in python Convert string to number in python Convert number to string in python Perl's chomp() equivalent for removing trailing newlines from strings in python Convert between tuples and lists in python Iterate over a sequence in reverse order in python Remove duplicates from a list in python

More Latest News
Most Viewed Articles (in python )
 Numbers And Math in Python Variables And Names in Python Iterate over a sequence in reverse order in python Schwartzian Transform in python switch case statement in Python Installing gedit for python programming in Windows Installing gedit for python programming in Linux Your First Program in Python Comments And Pound Characters in Python Variables And Printing in Python Strings And Text in Python Printing in Python Formatted printing in Python Using Unicode Literals in Python Unknown command: 'migrate'
Most Emailed Articles (in python)
 Convert number to string in python How to force rereading of a changed module in python Hexadecimal and Octal integers in python Formatted printing in Python Ternary operator in python Convert string to number in python Remove duplicates from a list in python Your First Program in Python Numbers And Math in Python Variables And Names in Python error: â_mysql_ConnectionObjectâ has no member named call by reference in python Perl's chomp() equivalent for removing trailing newlines from strings in python Iterate over a sequence in reverse order in python Schwartzian Transform in python