You are on page 1of 1

Data Type

Data
Description
Type

bool True or False values

int an integer(1,2,3)

str (string) a sequence of Unicode Characters

list an ordered sequence of values of other data types, e.g [1,2,3]

a collection of key: values, e.g {"firstName":"Hafizh",


dict
"LastName":"Hafizh"}

Check Data Type of variable

thisIsNumber = 8
type(thisIsNumber)

To Represent Nothingness in python using None

nullVariable = None

Formatting String using f-string

formatVariable = 11
print(f"there are {formatVariable} players on the field")

We can also do math inside

formatVariable = 11
print(f"one player get injured, only {formatVariable-1} left on the field")

Another Example

print("How many kilometers did you cycle today ?")


kms = input()
miles = float(kms) / 1.60934
miles = round(miles, 2)
print(f"Your {kms} ride was {miles}mi")

You might also like