Begrippenlijst
Begrippenlijst
This page contains an overview of all the concepts/terms in the Scripting course. Everything found on this page can also be found in the lecture texts, this page is intended for quickly looking up important concepts as a review for exams and not as exclusive study material. We councel everyone to attend the lectures and read the full lecture texts.
Filters
Begrippen
Concept: Initializing Variables
Creating a variable or initializing it, is one of the most fundamental concepts in programming. In Python, you can initialize a variable by simply writing down a name and assigning a value to it using the assignment operator =.
The assignment operator = expects a variable name on the left side and a value on the right side.
my_first_variable = "Hello World"Concept: Variables
A variable contains data, it can be visualized as a "box" that holds data. While this isn't entirely correct, it is a valuable abstraction to familiarize ourselves with the concept. The "box" can contain data of any sort, e.g. strings (text such as an IP address), an integer (a number such as a port), a boolean (a true/false value such as a variable that indications which server are healthy), ...
Concept: Naming Variables
When naming variables in Python, there are some important rules you should keep in mind:
- Variable names can only start with a letter or an underscore (
_), not a number. - Variable names can only contain alphanumeric characters (
a-z,A-Z,0-9) and underscores (_). - Variable names are case-sensitive —
age,Age, andAGEare all considered unique. - Variable names cannot be one of Python's reserved keywords such as
if,class, or `def.
While the following are the hard rules, there are also some soft rules that are widely accepted in the Python community:
- Variables names should be in lowercase, with separate words separated by an underscore. This is called snake case.
- Use descriptive names for variables. For example, if you want to save a user's age as a variable,
user_ageis better thanageor an abbreviation likeua. - Avoid using single-character variable names except for iteration variables of the parameter of simple labmda functions.