English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Tutoriales Básicos de Python

Control de Flujo de Python

Funciones en Python

Tipos de datos en Python

Operaciones de Archivo de Python

Objetos y Clases de Python

Fecha y Hora de Python

Conocimientos Avanzados de Python

Manual de Referencia de Python

Palabras clave y identificadores de Python

En este tutorial, aprenderás sobre palabras clave (palabras reservadas en Python) e identificador (nombres de variables, funciones, etc.).

palabras clave de Python

Las palabras clave son palabras reservadas en Python.

No podemos usar palabras clave como  nombre de variablefunciónnombres o cualquier otro identificador. Se utilizan para definir la sintaxis y estructura del lenguaje Python.

En Python, las palabras clave distinguen entre mayúsculas y minúsculas.

Python 3.7contiene 33 palabras clave. Este número puede cambiar ligeramente en un período de tiempo.

Todas las palabras clave deben estar en minúsculas, excepto True, False y None. A continuación, se muestra una lista completa de todas las palabras clave.

palabras clave en Python
Falseawaitelseimportpass
Nonebreakexceptinraise
Trueclassfinallyisreturn
andcontinueforlambdatry
asdeffromnonlocalwhile
assertdelglobalnotwith
asyncelififoryield

It may be difficult to view all keywords at once and try to understand their meanings.

If you want to view the list of all keywords, here isall keywordscompletelistand examples.

Python identifiers

Identifiers are the names given to entities such as classes, functions, and variables. They help distinguish one entity from another.

rules for writing identifiers

  1. Identifiers can be lowercase letters(a to z)or uppercase letter(A to Z)or number(0 to 9)or the combination of underscore (_). myClass, var_1,var_name_1, print_this_to_screen are valid.

  2. Identifiers cannot start with numbers.1is invalid, but variable1 is valid.

  3. cannot be used as identifiers.

    >>> global = 1
      File "<interactive input>", line 1
        global = 1
               ^
    SyntaxError: invalid syntax
  4. We cannot use keywords like@#$and such special symbols.

    >>> a@ = 0
      File "<interactive input>", line 1
        a@ = 0
         ^
    SyntaxError: invalid syntax
  5. Identifiers can be of any length.

things to remember

Python is Case sensitive language. This means that Variable and variable are two different variables. Also, it is recommended that meaningful identifiers be used in actual programming.

Although, c = 10 is also valid. However, it is recommended to use count = 10 It will be more meaningful, and it will be easier to understand its function and meaning even if you look at the code after a long period of time.

You can use underscores to separate multiple words for naming, for example: this_is_a_long_variable