Lesson 4Working with Basic Python Data Types

Python supports a variety of basic data types that determine how content in a program will work and interact. This lesson covers variables typed as numbers and Booleans. The lesson also introduces operators and how to use them to change the value of a variable to produce an updated output.

REVIEW OF DATA TYPES

Every modern programming language uses data types to determine what actions are possible for specific values in a program. For example, numbers can be used in mathematical calculations while Boolean values can be used to create conditional activities within a program.

In programming languages like Java and C#, programmers must explicitly define the variable's type when they declare a variable. Python, however, automatically types variables, which means that it logically assigns a data type to the value of a variable based on the value itself. In other words, if we define a variable using just a number, Python treats it as a number. If we put the value in quotation marks, Python treats it as a string.

Within this lesson, we will review the concept of variables, and then explore how Python processes numbers that are stored in numerically typed variables. There are a few key terms ...

Get Job Ready Python 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.