Python files have the extension .py
In Python, the print function is used to output text to the console.
The str data type is used to store text in Python
In Python, comments are started with the # symbol.
Variable names in Python must start with a letter or underscore and cannot contain spaces or hyphens.
The ** operator in Python is used for exponentiation. 2 ** 3 equals 8.
The def keyword is used to define a function in Python.
Advertisement
The + operator concatenates strings in Python, and adding " " between x and y results in "Hello World".
The == operator is used to check equality, and the correct syntax for an if statement in Python ends with a colon.
Lists in Python are created using square brackets, with elements separated by commas.
The range(3) function generates numbers from 0 to 2, and the for loop prints each number in this range.