204111:Python missing details

จาก Theory Wiki
ไปยังการนำทาง ไปยังการค้นหา

There are a number of topics left out from the teaching slides, because they are not central in programming concepts. However, these are details that are useful. Many of these are related to Python syntax. Some is related to string formatting.

Naming rules

When you want to use a variable, you have to give it a name. This is also true, again, with functions that you want to create. Providing good names helps people, including yourself, understand your programs faster and better.

In Python, there are rules regarding how to name things. You can choose names like "x", "total", or even "I_love_You_so_Much", but you can't have variables or functions with names like "2things", "x/y", or "sum of numbers". From this example, you can probably guess the reason. These forbidden names confuse the Python interpreter. For example, it would not be able to distinguish between a variable called x/y and an expression x/y

Here are the rules:

String formatting

Full operator precedence list