Monday, May 24, 2021

4- Use Python as calculator

Python is a Calculator

I can hear you say, "All programming languages can calculate". But python does it in easy syntax.

5 plus 7 is 12, 13 times 15 is 195, 1 divided by 5 is 0.2. Easy. Repeating or periodic numbers are printed in a longer format. Let's try minus 2 divided by 3. In math theory, when 2 is divided by 3, the digit 3 repeats forever after the decimal point.  

πŸ‘‡πŸ‘‡πŸ‘‡Click Read more

>>> print (5+7)

12

>>> print (13*15)

195

>>> print (-2/3)

-0.6666666666666666

>>> print (1/5)

0.2


You can also use Python to get squares, cubes, or any power of n of a number. For example, let's say we want to find out what 2 to the power of 10 is.

>>> print (2**10)

1024


You should try yourself and see how it is easy to calculate. 

No comments:

Post a Comment

Your comment will taken into consideration.