Get startedGet started for free

Other variable types

In the previous exercise, you worked with the integer Python data type:

  • int, or integer: a number without a fractional part. savings, with the value 100, is an example of an integer.

Next to numerical data types, there are three other very common data types:

  • float, or floating point: a number that has both an integer and fractional part, separated by a point. 1.1, is an example of a float.
  • str, or string: a type to represent text. You can use single or double quotes to build a string.
  • bool, or boolean: a type to represent logical values. It can only be True or False (the capitalization is important!).

This exercise is part of the course

Introduction to Python

View Course

Exercise instructions

  • Create a new float, half, with the value 0.5.
  • Create a new string, intro, with the value "Hello! How are you?".
  • Create a new boolean, is_good, with the value True.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Create a variable half


# Create a variable intro


# Create a variable is_good
Edit and Run Code