Menu

Sign in to track your progress and unlock all features.

Theme style

Log in

Problem No 7

Check Variable Types

Easy

8 minute session

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'.

Code editor
Loading editor…

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.

03:38 AM

Free preview includes 1 Teach Theory response and 1 AI hint per unlocked preview lesson.