Lesson guide
What this Python exercise practices
Check Variable Types is a beginner practice lesson that focuses on functions, parameters, return values. It is designed to be solved in about 8 minutes with examples, starter code, and test feedback.
Prerequisites
- Python variables
- Function parameters
- Return values
Difficulty and time
- Level
- Beginner
- Estimated time
- 8 minutes
Related public exercises
Summary
Return the runtime type name of a value as a string.
Problem statement
Write a function check_type(value) that returns the name of the runtime type of value as a string. Use Python's built-in type system to inspect the value. Examples of expected outputs: int, float, str, bool, list, dict, NoneType, etc.
Task
Understand how Python represents the type of a value and return its type name.
Examples
Integer example
Input
check_type(5)
Output
int
Explanation
The value 5 is an integer, so the function returns 'int'.
Input format
A single Python value passed as the function argument.
Output format
A string with the type name, e.g. 'int' or 'str'.
Constraints
Do not use any external libraries. Use Python's built-in type introspection.
Samples
Sample input 0
check_type([1, 2, 3])
Sample output 0
list
Explanation 0
A Python list has the type name 'list'.
AI assistant
Ask me anything!
Need help? I can explain the core idea behind this problem, review your current code, and give targeted hints. Use “Teach Theory” for the concept, “Get AI hint” for a quick scaffold nudge, or ask a specific question below.
Chat history is temporary and will not be saved.
Free preview includes 1 Teach Theory response and 1 AI hint per unlocked preview lesson.