Jump to content

IT Fundamentals/Software Development/Data Types

From Wikiversity

Types.py

[edit | edit source]
i = 1234567890
f = 1.234567
d = 1.23456789012345
c = 'c'
s = "string"
b = True

print("Integer:", i)
print("Float:", f)
print("Double:", d)
print("Character:", "'" + c + "'")
print("String:", "\"" + s + "\"")
print("Boolean:", b)

The Python programming language floating point data type is double-precision (15 significant digits). There isn't a technical difference between f and d above as implemented in Python and most other interpreted languages. Compiled languages typically do differentiate between single and double precision floating point values.

There also isn't a technical difference between c and s above as implemented in Python and most other interpreted languages. Compiled languages typically do differentiate between single and double quotes and between one character and a string of characters.

Try It

[edit | edit source]

Copy and paste the code above into one of the following free online development environments or use your own Python compiler / interpreter / IDE.