Within Python there are different data types. Think of data types like different formats within Excel. The
int or integer is a round number without a decimal point. Python Int is similar to float, but floats have decimal points.
x = 5 print (type(x)) >>> <class 'int'>
Python Int: Be Careful
One thing to be careful of are datatypes that look like an
int, but aren’t. For Example if
x = '5' you might think that
x is an integer, but because it is encased in quotes, it’s actually a string. This will cause unexpected results or even errors.
There are different data types in python. One of the major (they are all major) ones is the int or integer.
Simply: Integers are numbers that do not have any decimal points. You can check the type of data you're workingw with via the type operator. Remember that numbers can be strings too. Rule: Ints are not strings.
print ("5") print (5)
print (type("5")) print (type(5))
<class 'str'> <class 'int'>
print ("5" * 5) print (5 * 5)
print (type(20)) print (type(6)) print () print (20 / 6) print (type(20 / 6))
<class 'int'> <class 'int'> 3.3333333333333335 <class 'float'>
Look above, two ints made another data type, the float. This is a number with decimal points.
Check out more Python Vocabulary on our Glossary Page