2 VARIABLE TYPES

 

 

 

 

 

Variables are very important in programming. Before learning about what they are and how to use them, perhaps it would be good to get some intuitive feeling for them. In the following sections, you will play around with all sorts of variable types to get a hang of things.

Numbers

Numbers can be represented in different ways. The most notable difference is between integers and floating points. An integer is a number without a fractional part, for example 10, 0, or ‒5. A floating point, or float, is a number with a fractional part, such as 1.23, ‒99.9, or 1.0.

Intuitively, it would seem floats can be used to be more precise. However, never say this when you are at a mathematician’s house party! Fractions can be ...

Get Python for Experimental Psychologists now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.