Start learning free

LESSON 13 OF 673 · VARIABLES

Changing Variable Data Type in Python

Lesson

Note that a variable can store values of different types throught a program. It is not constrained to the data type of the initial value we give it at creation:

a = "peanut"
type(a) # Output: <class 'str'>

a = False
type(a) # Output: <class 'bool'>

a = 13.7
type(a) # Output: <class 'float'>

Assignment
Follow the Coding Tutorial and let's practice with data types!


Hint
Look at the examples above if you get stuck.


STEP 1 OF 2
    Ctrl + Enter to check