⊗pyPmCdECh 129 of 208 menu

Checking for Equality in Python

To test two values ​​for equality, use the operator ==.

Let there be a variable:

tst = 3

Let's find out if it is equal to 0:

if tst == 0: print('+++') else: print('---') # will this work

Now let's change the value of the variable so that the condition is met:

tst = 0 if tst == 0: print('+++') # this will work else: print('---')

Given a variable:

tst = 25

Check that it is equal to 10.

The following code is given:

tst = '123' if tst == 123: print('+++') else: print('---')

Tell me what will be output to the console.

The following code is given:

tst = ['a', 'b, 'c', 'd'] if len(tst) == 5: print('+++') else: print('---')

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