Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Math expressions: Familiar operators | Variables in Python
Python Tutorial for Beginners

Swipe to show menu

book
Math expressions: Familiar operators

You can assign the result of a math expression to the variable.

1
lucky_number = 3 + 4
copy

This displays 7 on the screen.

Here is a statement that subtracts 45 from 30, assigning the result, -15, to the variable.

1
loss = 30 - 45
copy

This one assigns the product of 5 times 4 β€” the result is 20 β€” to the variable.

1
dozens = 5 * 4
copy

This one assigns 36 divided by 9 β€” the result is 4 β€” to the variable.

1
number = 36 / 9
copy
Task

Swipe to start coding

Divide the variable total by 3 and assign the result to the variable result. Display these 2 variables(total, result) on the screen.

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 2. ChapterΒ 4

Ask AI

expand
ChatGPT

Ask anything or try one of the suggested questions to begin our chat

book
Math expressions: Familiar operators

You can assign the result of a math expression to the variable.

1
lucky_number = 3 + 4
copy

This displays 7 on the screen.

Here is a statement that subtracts 45 from 30, assigning the result, -15, to the variable.

1
loss = 30 - 45
copy

This one assigns the product of 5 times 4 β€” the result is 20 β€” to the variable.

1
dozens = 5 * 4
copy

This one assigns 36 divided by 9 β€” the result is 4 β€” to the variable.

1
number = 36 / 9
copy
Task

Swipe to start coding

Divide the variable total by 3 and assign the result to the variable result. Display these 2 variables(total, result) on the screen.

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 2. ChapterΒ 4
Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
We're sorry to hear that something went wrong. What happened?
some-alt