このページには最新のブラウザ(SharedArrayBuffer対応)が必要です。Chrome、Edge、Firefox、Safariを最新バージョンに更新してください。
English
Two kinds of number
- An integer (
int) is a whole number, like7or-3. - A float is a number with a decimal point, like
2.5. - Division with
/always gives a float, even4 / 2→2.0.
English
Add, subtract, multiply, divide
+adds,-subtracts,*multiplies,/divides.- You can use them with variables or with plain numbers.
- Spaces around operators are optional but make code easier to read.

English
print(7 + 2)
print(7 - 2)
print(7 * 2)
print(7 / 2)
English
Whole-number division, remainder, powers
//divides and rounds down to a whole number (floor division):7 // 2is3, and-7 // 2is-4.%gives the remainder (called modulo).**raises to a power:2 ** 3is 2×2×2.
English
print(7 // 2)
print(7 % 2)
print(2 ** 5)
English
Order of operations
- Python does
**first, then*///%, then+-. - This is the same order you use in maths.
- Use parentheses
(...)to change the order.
English
print(2 + 3 * 4)
print((2 + 3) * 4)
English
Common mistakes
/always gives a float (4 / 2is2.0); use//when you want a whole number.- Power is
**, not^. "3" + "4"joins text into"34"— it does not add to7.
English
Now you try
- Store each answer in the variable named in the task.
- Press Check answer to test your code.
探索
演算の優先順位
Python は左から右へ × と ÷ を + と − より先に評価します。
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
length を 8 に、width を 5 に設定してください。その後、それらの積を area という変数に格納してください。
実行ボタンをクリックして出力を確認してください。
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
17 個のキャンディを 5 人の子供たちに分けましょう。各子供が何個受け取るかをeach に格納し(// を使用)、残りをleft に格納してください(% を使用)。
実行ボタンをクリックして出力を確認してください。
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
3 ** 2 + 1 をresult に格納してください。その後、括弧を使って(3 + 1) ** 2 をgrouped に格納してください。
実行ボタンをクリックして出力を確認してください。
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
celsius は 37 です。ファレンハイトでの温度をfahrenheit に格納してください。公式 celsius × 9 ÷ 5 + 32 を使用します。
実行ボタンをクリックして出力を確認してください。