From the course: Programming Foundations: Fundamentals

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Working with numbers

Working with numbers

And before you start to have flashbacks to high school algebra, I'm not talking about complex mathematical calculations. We use numbers numbers to store a person's high score in a game, or even the number of likes on a picture. Python treats numbers in a few different ways depending on how they're being used and the difference is largely based on whether it's a whole or fractional one. Let's look at a few examples. We can use the command line for this as we just want to do some basic math. So let's go to the command line and start our Python prompt. We'll start out easy, two plus three. Let's try another one. Two, asterisk and then three. When we hit Enter, we get six. An asterisk or star is used for multiplication in Python. Let's go to another one. This is used for exponents. It's exactly the same as two times two, times two. Let's try another one. This is how we do division inside of Python. Now, what if we…

Contents