FREE ONLINE INTERACTIVE COURSE

Python 3

FOR BEGINNERS

THEORY
PAGE 1 / 1
Python 3 vocabulary
Home >>> Free online lessons

What does a language consist of?

The vocabulary of any programming language consists of:
  • character set;
  • identifiers;
  • separators;
  • comments.

Character set

The set of characters you can use to make a program in Python 3:
  • uppercase and lowercase letters of the English alphabet (A - Z, a - z);
  • numbers from 0 to 9;
  • special characters (+, -, *, /, =, ^, <, >, (, ), [, ], {, }, ., ,, :, ;, #, $, @, _ and blank).
Unlike other programming languages, the Python 3 version gives us direct representation of characters using the [Unicode] standard, more precisely in the [UTF-8] format. So, we can also enter characters that are not of course on the keyboard, but we can take them from the Internet. That's why we can enter special characters like [emoji] or [smileys].

Example 1. In Python 3 we can write like this, unlike other programming languages:

greece = "αβγδεζηθικλμνξοπρςστυφχψ"
print(greece)
print("î ă â ş ţ")
print("Hei! 😉")

Identifiers

By identifiers we mean a sequence of letters, numbers, or the special character "_", provided that the first is not a digit. With the help of identifiers, the names of variables, functions, etc. are associated.

Example 2. Look at the statements of the following variables:

var1 = "mom"
var2 = "dad"
a_string = "a family"


As counterexamples, we have "1var", "str&". The first starts with a number, and the second contains a special character.

A special category of identifiers is given by the keywords of the Python 3 language (have a well-defined meaning, are reserved and cannot be used in another context). The complete list is as follows:

False await else import pass
None break except in raise
True class finally is return
and continue for lambda try
as def from nonlocal while
assert del global not with
async elif if or yield


and they must be written exactly as above to be interpreted correctly.

Python distinguishes between uppercase and lowercase letters. priNt("Hello!") gets a syntax error because the interpreter does not know the command priNt, but only print.

Separators

Definition. The simplest elements made up of characters with linguistic significance are called lexical units.

They are separated, as appropriate, by one or more spaces, the end-of-line character, or the ";" character, as already presented.

Example 3. ab may mean the name of a variable, so we have a lexical unit, while a b contains two units...

Comments

Python encourages the introduction of comments in our code, as it is much easier to understand later. As you can see, they can be entered anywhere in the program, starting with the hash character ("#") and continuing to the end of the line.

Example 4. Below is a comment in Python:

#this is a comment

The Python language is very sensitive to syntax and is strongly oriented towards a text arrangement that allows easy understanding of the code.
Remember this important information.
You must also have a language suitable for programming!

 home   list  LESSONS   arrow_upward