⊗pyPmCdEI 140 of 208 menu

The elif construct in Python

The elif construct allows you to specify an additional comparison before the else block.

Let us have a variable tst:

tst = 3

Let's compare its value with the numbers 1 and 5. We'll also write different messages for each of them to output to the console:

if tst == 1: print('the num is 1') elif tst == 5: print('the num is 5') else: print('the num is unknown') # will this work

Two variables are given:

tst1 = 5 tst2 = 8

Check which of these variables has the greater value and display the appropriate message.

Given a variable age, which contains the user's age. Write a condition when the variable is less than 18 and greater than 10. Then a condition if the number is in the range from 18 to 60. Also write a message to output to the console when the number does not fall into any of the previous conditions.

The variable day contains some number from the interval from 1 to 31. Determine which decade of the month this number falls in (first, second or third).

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