Книга: Automate the Boring Stuff with Python: Practical Programming for Total Beginners
Назад: Introduction
Дальше: II. Automating Tasks

to see a list of common Python error messages and their meanings.

lists all the math operators in Python.

.

. The values -2 and 30, for example, are said to be integer values. The integer (or int) data type indicates values that are whole numbers. Numbers with a decimal point, such as 3.14, are called floating-point numbers (or floats). Note that even though the value 42 is an integer, the value 42.0 would be a floating-point number.

.

If you ever see the error message SyntaxError: EOL while scanning string literal, you probably forgot the final single quote character at the end of the string, such as in this example:

when talking about the str(), int(), and float() functions.)

The * operator is used for multiplication when it operates on two integer or floating-point values. But when the * operator is used on one string value and one integer value, it becomes the string replication operator. Enter a string multiplied by a number into the interactive shell to see this in action.

.

, the spam variable in this example stores 'Hello' until you replace it with 'Goodbye'.

has examples of legal variable names. You can name a variable anything as long as it obeys the following three rules:

  1. It can be only one word.

  2. It can use only letters, numbers, and the underscore (_) character.

  3. It can’t begin with a number.

describes functions in more detail.

© RuTLib.com 2015-2018