Notizen: Unterschied zwischen den Versionen
Flinh1 (Diskussion | Beiträge) (→Python) |
Flinh1 (Diskussion | Beiträge) (→Python) |
||
| Zeile 2: | Zeile 2: | ||
== Python == | == Python == | ||
| + | === Rekursion === | ||
| + | <nowiki> | ||
| + | def rebours(wert): | ||
| + | print(wert) | ||
| + | if wert > 0: | ||
| + | rebours(wert - 1) | ||
| + | rebours(9) | ||
| + | </nowiki> | ||
| + | |||
| + | ---- | ||
=== Umrechnung in hex-Code === | === Umrechnung in hex-Code === | ||
Version vom 21. Juli 2019, 10:07 Uhr
Inhaltsverzeichnis
Python
Rekursion
def rebours(wert):
print(wert)
if wert > 0:
rebours(wert - 1)
rebours(9)
Umrechnung in hex-Code
>>> print('%x' % 15)
f
>>> print('%02x' % 15)
0f
Listen
Kopie einer Liste erstellen:
vorlage = ["aaa","vfg","grt"] vorlageKopie = vorlage[:]
a = [a + b for a in 'list' if a != 's' for b in 'soup' if 'b' != 'u'] print(a) ['ls', 'lo', 'lu', 'lp', 'is', 'io', 'iu', 'ip', 'ts','to', 'tu', 'tp']
Zeit ausgeben:
import time print(time.asctime())
Text einlesen:
import sys >>> x = sys.stdin.readline() Hier der Text. >>> x 'Hier der Text.\n'
Visual Studio Code für Python einrichten
Installation in Ubuntu:
Für komfortables Arbeiten mit Python empfiehlt sich die Aktivierung von Python extension for Visual Studio Code[1] und Python for VSCode.[2] Zusätzlich installiert man dazu pylint.[3]
sudo -H pip3 install pylint
Visual Studio Code Keyboard Shortcuts:
Auskommentieren: Str-K, Str-C
Einkommentieren: Str-K, Str-U