Читать книгу Introduction to Python Programming for Business and Social Science Applications - Frederick Kaefer - Страница 42

Variables

Оглавление

We use variables to store and access values that we are working with. The values of variables can change, or vary, as a program executes. There are some restrictions with naming of variables, including (1) they cannot have the same name as a Python keyword, (2) they cannot have any spaces or operators or delimiters within them, and (3) they cannot begin with a number.

You do not formally define variables in Python (which most programming languages require). In Python, you create a variable when you first use it. The variable name that you use when something is created refers to an object that is constructed for the purpose that you are specifying. The value that you store in a variable determines the variable’s data type and the actions that can be performed to or with the corresponding object that it refers to.

Lessons learned: In this section, we learned about basic elements of Python code, including Python keywords, objects and classes, variables and data types, and operators and delimiters. From this point onward, we will combine these basic elements into various statements that make up our code.

Introduction to Python Programming for Business and Social Science Applications

Подняться наверх