Python supports various different data types, such as integers for whole‐number values, Booleans for True/False values, and strings for words or other sequences of text characters. After creating a variable, you can assign any type of data to it that Python uses.
So What Is a Variable?
A variable is an area of memory in which you can store data. When you create a variable, you give it a name that enables you to access it to retrieve or change its contents. When your code runs, Python allocates a space in memory for each variable.
For example, you might create a variable called name to store an employee’s name (A). The name would normally be a string of text characters, such as Anna Connor or Bill Ramirez, so the value would receive the str data type, which Python uses for strings. Similarly, you might create a variable called age to store the employee’s age in years as a whole number (B). That value would be an integer, so Python would assign the value the int data type that it uses for integers. Or you might create a variable called isOnProbation to store the employee’s probation status (C). This variable would store the value True or the value False, and Python would assign the value the bool data type that it uses for Boolean values.
0 comments:
Post a Comment