Flash Sale: Flat 70% + Addl. 25% Off on all Courses | Use Coupon DS25 in Checkout | Offer Expires In

  Enroll Now

Types of Variables in Python

In the previous exercise, we worked with two types of variables

  • integer, or int: a number without decimal part. bmi with the value 25 is an example of an integer. height with the value of 40 (in rectangle example) is also an integer.

  • float, or floating point: a number that has both integer and decimal parts. weight with the value of 72.25 is an example of a float.

Other common data types in Python are

  • str, or string: Represents sequences of characters such as a message or text. Variable my_name = "John" is an example of a string

    Pro Tip - We can use either single or double quotes to represent strings.

    Example - "John" (notice double quotes) and 'John' (notice single quotes) both are same strings

  • bool, or boolean: Represents logical values such as True and False.Variable is_great = True is an example of a boolean

    Pro Tip - Notice capitalization in True and False. Capitalization is important for boolean variables in Python

  • Create a new string, gender, with the value "male"
  • Create a new boolean, is_obese, with the value False

No hints are availble for this assesment

Answer is not availble for this assesment

Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...