Skip to main content
  • Python is available now. All other compilers are coming soon.

    Python
  • Popular Tutorials

    • Getting Started With Python
    • Python if Statement
    • while Loop in Python
    • Python Lists
    • Dictionaries in Python
    All Python Tutorials

    Reference Materials

    Built-in FunctionsList MethodsDictionary MethodsString Methods
    View all

Online Compilers

  • Python Compiler
  • Python Playground
  • Python Projects
  • Exercises

Tutorials

  • Learn Python
  • Python for Beginners
  • Variables and Types
  • Python Strings
  • Python Lists
  • Python If Else
  • Python For Loops
  • Python Functions
  • Python Classes

Examples

  • Python Examples
  • Hello World
  • Add Two Numbers
  • Even or Odd
  • Factorial
  • Fibonacci
  • Prime Check
  • Palindrome Check

Company

  • About
  • Contact
  • Privacy Policy
  • Terms of Use
  • Disclaimer

© 2026 ILoveCompiler. All rights reserved.

  1. Home
  2. Python Examples
  3. Variables and Data Types

Variables · Python example

Variables and Data Types

Create strings, integers, floats, and booleans, then inspect each type.

Open the compilerAll examples
beginnertypestype()booleans

Every value in Python has a type. This example creates one value of each common built-in type and prints its name.

example.py
name = "Ada"
age = 36
height = 1.68
is_engineer = True

print(name, type(name).__name__)
print(age, type(age).__name__)
print(height, type(height).__name__)
print(is_engineer, type(is_engineer).__name__)

How the code works

  • Four variables are bound to values of different types.
  • print() receives the value and its type name as two arguments.
  • Python inserts a single space between arguments by default.

Key ideas

  • str holds text, int holds whole numbers, and float holds decimal numbers.
  • bool holds exactly two values: True and False.
  • type(value).__name__ returns a readable type name.

Try changing it

  • Add a list, tuple, and dictionary to see their type names.
  • Use isinstance(age, int) to test a type directly.
  • Reassign age to a string and inspect the new type.

Related examples

beginner

Hello World in Python

The classic first program: print a greeting and a second line of text.

beginner

Capitalize Each Word

Transform a sentence with the title() string method.

Previous exampleAdd Two NumbersNext exampleCalculate Simple Interest

Expected output

Ada str
36 int
1.68 float
True bool

Output is compared after trimming trailing whitespace on each line. Run the code to see it produced by CPython in your browser.

Practice next

Apply the same idea with automatic tests or browse a guided project.

ExercisesProjects