Int and float function

Screen Link: Learn data science with Python and R projects

My Code:
gift_apps = 6.99
gift_apps *= 3

`print(int(gift_apps))``

What I expected to happen:

  • gift_apps is a float, but we expected it to be a int.
  • gift_apps is greater than what we expected.

What actually happened:

Replace this line with the output/error

how to use int and float functions? It should be used only with print() or while converting int variable to float variable and vice versa. for eg., gift_apps = int(gift_apps)

This is clarified in the instructions:

Convert gift_apps from a float to an integer using the int() function, and assign the converted value back to gift_apps.

Unless you assign it back, gift_apps value itself is not modified. It still stores the original float value.

1 Like

Thank you for clarifying my doubts.