⊗pyPmBsCTF 35 of 208 menu

Converting to Floating Point in Python

To convert to a floating point number, use the float function.

Let's apply this function to a string:

txt = '12.1' print(float(txt)) # 12.0

Now to the whole number:

num = 12 print(float(num)) # 12.0

After the transformation, we can perform mathematical operations on our variables:

test1 = '1.1' test2 = '2.1' test3 = float(test1) + float(test2) print(test3) # 3.2

Given variables:

tst1 = '1.1' tst2 = '1.2'

Find the sum of the values ​​of these variables.

Given variables:

tst1 = 2 tst2 = 4

Convert them to floating point numbers and find their difference.

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