Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen der Seite angezeigt.
Beide Seiten, vorherige Überarbeitung Vorherige Überarbeitung Nächste Überarbeitung | Vorherige Überarbeitung | ||
talit:python_basics [2020-02-09 21:39] – sca | talit:python_basics [2020-02-09 21:42] (aktuell) – sca | ||
---|---|---|---|
Zeile 93: | Zeile 93: | ||
1. Can you use numbers or special characters like `?, | 1. Can you use numbers or special characters like `?, | ||
- | <!-- You can even use numbers in variable names, as long as they are not in the beginning, e.g., `mystring13 = "Hello World" | ||
- | But you can NOT use special characters in variable names | ||
- | --> | ||
2. How can you add a line break to a string? | 2. How can you add a line break to a string? | ||
- | <!-- % mystring = " | ||
3. Is Python case-sensitive? | 3. Is Python case-sensitive? | ||
4. Given a (long enough) string `s`, what do the commands | 4. Given a (long enough) string `s`, what do the commands | ||
Zeile 106: | Zeile 102: | ||
## Integers & floats | ## Integers & floats | ||
- | \label{sec integers and floats} | ||
Next, let's have a look at numbers, in particular integers and floats. | Next, let's have a look at numbers, in particular integers and floats. | ||
Zeile 295: | Zeile 290: | ||
- | # Conditions | + | # Conditions & Booleans |
We can check if one or multiple conditions are satisfied. | We can check if one or multiple conditions are satisfied. | ||
Zeile 414: | Zeile 409: | ||
Second, we discuss the **while-loop**. It repeats a piece of code as long as a condition is satisfied. | Second, we discuss the **while-loop**. It repeats a piece of code as long as a condition is satisfied. | ||
- | Careful: If you have a bug in your code and the condition is always true, you have an `infinite loop': the code will never stop running and you will have to kill the process manually. | + | Careful: If you have a bug in your code and the condition is always true, you have an **infinite loop**: the code will never stop running and you will have to kill the process manually. |
A simple example of a while-loop is: | A simple example of a while-loop is: | ||
Zeile 463: | Zeile 458: | ||
# Elapsed time | # Elapsed time | ||
- | \label{sec elapsed time} | ||
If you want to test the efficiency of your code, it is useful to measure the time needed for the calculation: | If you want to test the efficiency of your code, it is useful to measure the time needed for the calculation: |