2.2.2 data types Flashcards
what is a string (str)
sequence of characters eg. str(“hello world”)
what is an integer (int)
a number with normal value of number eg. int(“8”)
- needed for accurate answers in arithmetic operations
what is character
any character that will always be shown as that character
what is a float/real (float) or (real)
a number with a decimal eg. float(“2.2”)
what is boolean (bool)
either true or false eg. bool(true)
what is casting
changing the data type of a value
why is casting used
data types can only operate with same data types
eg. “hello world” + 2 is not possible
but if age = 2
age = str(age)
then (“hello world”+ age) would return hello world2
how to find out what data type a variable is
print(type(VariableName))