Sasha Palmer
last year
Sashacountry asked

How do you know when to use float or int in a program?

Abhilekh Gautam
Expert
last year

Great question!.

You use int or float based on the type of number you want to work with.

  • Use int when you need to work with whole numbers (without decimals). Eg: 5, -5
  • Use float when you need to work with numbers with decimal points. Eg: 5.0, -5.45
Python
This question was asked as part of the Getting started with Python course.