⊗pyPmBsMOE 12 of 208 menu

Equal Precedence in Python

Multiplication and division have equal priority and are performed in turn from left to right. Let's look at an example to see what this means. The following code will perform division first, then multiplication:

res = 8 / 2 * 4 print(res) # 16 (result 4 * 4)

If you rearrange the signs, then first multiplication will be performed, and then division:

res = 8 * 2 / 4 print(res) # 4 (result 16 / 4)

In the following example, each new division operation will be applied to the previous one:

res = 16 / 2 / 2 / 2 print(res) # 2

The following code is given:

res = 6 * 2 / 4 print(res)

Tell me what will be output to the console.

The following code is given:

res = 6 / 2 * 3 print(res)

Tell me what will be output to the console.

The following code is given:

res = 18 / 2 / 3 * 2 print(res)

Tell me what will be output to the console.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline