06: Python: Data Types

Try it:

Convert and use different types of data
Python Data types: Convert and use different types of data

Below you’ll see some example python code that asks the user how many hours per day they spend on their phone.

It will then calculate and display some (pretty scary) stats of how much of their life they’re arguably wasting away.

Press Ctrl + Enter  to run the code.

Click on your score in the top right corner of the code editor to see what your code needs to do.

Any line of code that starts with a #  is a comment: it doesn’t affect how the program runs, it’s just there to help explain what the code does.


  1. Change the percentage to show 2 decimal places instead of 1

    Line 11 uses a function called round() which is currently set to round to 1 decimal places. Try changing the number inside the brackets.

  2. Create a variable called hours_per_year and set the value to how many hours the user will spend on their phone in a year (365 days).

    You’ll need to multiply hours by 365.
    In python you can use the  * operator to multiply two numbers.

  3. Add a line that displays: “In one year, you will spend ... hours on your phone” where ... is rounded to a whole number

    You’ll need to use the round() function to round to 1 decimal place
    You’ll also need to use the str() function so that you can include your number inside print()

One thought on “06: Python: Data Types

Leave a Reply

Your email address will not be published. Required fields are marked *