Erstelle eine Website wie diese mit WordPress.com
Jetzt starten

Strings in Python3

In this post I will talk about Strings in Python3. A string is a list of characters in order and a character is anything you can type on the keyboard in one keystroke, like a letter, a number, or a backslash.Strings can have spaces: Python recognize as strings everything that is delimited by quotation marks …

List and Tuples in Python3

Lists and Tuples store one or more objects or values in a specific order. The objects stored in a list or tuple can be of any type.Lists and Tuples are similar in most context but there are some differences. Here are the syntax differences : Furthermore, in lists you can insert, delete, change values, whatever you want. With tuples …

Recursion in Python3

A function that calls itself is a recursive function. This method is used when a certain problem is defined in terms of itself.The most popular example of recursion is the calculation of the factorial. Mathematically the factorial is defined as: n! = n * (n-1)! Here an example for that. Imagine we want to calculate …

For Loops in Python3

The „For-Loop“ in Python is used to iterate over a sequence (list, tuple, string) or other iterable objects. Iterating over a sequence is called traversal. Syntax for the „For-Loop“: Here, X is the variable that takes the value of the item inside the sequence on each iteration.Loop continues until we reach the last item in the …

While loops in Python3

A While Loop statement in Python programming language repeatedly executes a statement as long as a given condition is true. In this blog post I will show you again a Flow Chart which visualizes While Loops and makes them easier to understand: A While Loop statement looks like this: Let’s show you an example of a program …

Nesting in Python3

Nesting is more or less just putting one or more if statements in another if statement. To visualize is in a more understandable way I found this graphic: https://www.tutorialgateway.org/python-nested-if/ Furthermore I will show you an basic example of nested if statements. The Program wants to find out if the chosen variable, in this case 100, …

Conditionals in Python3

Conditional statements are part of every programming language. With conditional statements, we can have code that sometimes runs and at other times does not run, depending on the conditions of the program at that time. If statement: We will start with the if statement, which will evaluate whether a statement is true or false, and run code …

Creating Modules

We use modules to break down large programs into small manageable and organized files. Furthermore, modules provide reusability of code. We can define our most used functions in a module and import it, instead of copying their definitions into different programs. Let us create a module. Type the following and save it as example.py. And this …

Using Modules

Modules in Python are simply Python files with a .py extension. The name of the module will be the name of the file. A Python module can have a set of functions, classes or variables defined and implemented. Importing modules is similar to importing functions and is done by writing import <name of the module>.  Including …

Creating Functions

Function in Python is defined by the „def “ statement followed by the function name and parentheses ( () ). Let us define a function by using the command „def func1():“ and call the function. The output of the function will be „I created a Python function“. The function print function1() calls our def function1(): and print the command „I …