1 / 13
🐍

Data Types in Python

Learn how about the different types of data and their uses in python.

💡

What are Data Types?

Data types tell the computer what kind of thing a value is, like a number, a word, or True/False.

🎯

Why do we use data types?

  • So the computer knows how to understand and work with the information we give it, like adding numbers or joining words.
  • To ensure that only the required data type can be inputted into the program
💻 Examples of Different Data Types
name = "Sam"

Word values are known as strings. A string must be enclosed in "".

age = 17

Whole number values are known as integers. Integers must be a number, with no decimal point or ""

height = 5.11

Non-whole number values are known as floats. Floats must be a number with a decimal point, and no ""

male = True

A true or false value is known as a boolean. A boolean must be the words: True or False with no "" and a capital starting letter

Question 1

Which data type is this?

male = True
Question 2

What data type is this?

height = 5.11
Question 3

What is wrong with this code?

name = "Sam"
age = 17
height = 5.11
male = "True"
Question 4

Assign the integer value 4 to a variable named tickets:

Question 5

Which variable holds a string data type here?

name = "Sam"
age = 17
height = 5.11
male = True
Question 6

What is the data type of the value asigned to top_speed?

vehicle = "Car"
top_speed = 70
mot_passed = True
Question 7

How do you differentiate between an Integer & a Float?

Question 8

Is the value a float or an integer?


bank_balance = 5372.34
            
Question 9

Is the value a float or an integer?


petrol_price = 2.0
            
Question 10

Which data type would be suited for a variable that holds a user's name?

Question 11

Match each value with its correct data type:

Drag the values from the left to their corresponding data types on the right

Values

False
45
"Hello World!"
6.9

Data Types

String
Boolean
Float
Integer
🎉

Excellent Work!

You've mastered Python data types!

🏆

Data Types Expert

You can now understand and differentiate different data types in Python

What's Next?

Continue your Python journey with collecting user input!