0
0
Data Analysis Pythondata~15 mins

Checking data types in Data Analysis Python - Mini Project: Build & Apply

Choose your learning style9 modes available
Checking data types
📖 Scenario: You are working with a small dataset of different types of information collected from a survey. You want to check the type of each data item to understand what kind of data you have.
🎯 Goal: Build a simple Python program that stores different data items in a dictionary and then checks the data type of each item.
📋 What You'll Learn
Create a dictionary with exact keys and values as specified
Create a variable to hold the keys of the dictionary
Use a for loop to iterate over the keys and check the type of each value
Print the key and its data type in each iteration
💡 Why This Matters
🌍 Real World
Checking data types is important when cleaning and preparing data for analysis to avoid errors and understand the data better.
💼 Career
Data scientists and analysts often need to verify data types to ensure correct processing and analysis in their projects.
Progress0 / 4 steps
1
Create the data dictionary
Create a dictionary called survey_data with these exact entries: 'age': 30, 'name': 'Alice', 'height': 5.5, 'is_student': False
Data Analysis Python
Need a hint?

Use curly braces {} to create a dictionary. Separate keys and values with a colon, and separate items with commas.

2
Create a list of keys
Create a variable called keys that stores the list of keys from the survey_data dictionary using the keys() method.
Data Analysis Python
Need a hint?

Use list() to convert the keys view to a list.

3
Check data types with a loop
Use a for loop with variable key to iterate over keys. Inside the loop, get the value from survey_data using key and create a variable value_type that stores the type of this value using the type() function.
Data Analysis Python
Need a hint?

Use for key in keys: to loop. Use type() to find the data type.

4
Print the key and its data type
Inside the for loop, add a print() statement that shows the key and the value_type separated by a colon and a space. For example: age: <class 'int'>
Data Analysis Python
Need a hint?

Use an f-string in print() to format the output as key: value_type.