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

book
Math expressions: Familiar operators

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

lucky_number = 3 + 4
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.

loss = 30 - 45
1
loss = 30 - 45
copy

This one assigns the product of 5 times 4 — the result is 20 — to the variable.

dozens = 5 * 4
1
dozens = 5 * 4
copy

This one assigns 36 divided by 9 — the result is 4 — to the variable.

number = 36 / 9
1
number = 36 / 9
copy
Tâche

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

total = 33
result = total/3
print(total, result)

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 2. Chapitre 4
total = 33
result =
print(___, ___)

Demandez à l'IA

expand
ChatGPT

Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion

some-alt