How Can We Help?
< All Topics
Print

Python as a Calculator

Python as a Calculator

A simple, yet powerful attribute of Python is how you can use it to calculate basic numeric operations. This is useful for getting a first introduction to the language. You can type a sequence of numbers and operators into a cell to get a result like a calculator. Parentheses can be used to order operations.

See a list of useful operators here.

3 + 4 will return 7

2 * 4 will return 8

2 ** 4 will return 16

10 / 3 will return 3.33333333333335

10.0 / 3 will return 3.33333333333335

10 % 3 will return 1

250 / (5 + 5) * (7 - 3) will return 100.0

Pressing Return (or Enter) within a cell will create a new line in the cell code. When you run a cell, it will print the last value calculated unless you use Python’s print statement to print earlier values.

Next Python Variables
Table of Contents