Exercise:06 Python variable and Its types

 

Other variable types

In the previous exercise, you worked with two Python data types:

  • int, or integer: a number without a fractional part. savings, with the value 100, is an example of an integer.
  • float, or floating point: a number that has both an integer and fractional part, separated by a point. growth_multiplier, with the value 1.1, is an example of a float.

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

  • 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. Can only be True or False (the capitalization is important!).

Instructions
100 XP
  • Create a new string, desc, with the value "compound interest".
  • Create a new boolean, profitable, with the value True.

Question:01:

Guess the type

To find out the type of a value or a variable that refers to that value, you can use the type() function. Suppose you've defined a variable a, but you forgot the type of this variable. To determine the type of a, simply execute:

type(a)

We already went ahead and created three variables: ab and c. You can use the IPython shell to discover their type. Which of the following options is correct?

Possible Answers
  • this answer is not correct chose your own answer

Comments