tmp.py
#Variable
s = "str..."
l = ["1", "2", "3", "3", "4"]
t = ("A", "B", "C")
d = {"key": "value"}
s_ = str("str")
i_ = int("99")
f_ = float("100.0")
l_ = list((1,2,3))
d_ = dict([["key, "value"]])
e = set("0123456789")
ss = '''
dup
dup
dup
'''
#Syntax drucken
print(s, end="")
#Scheibe
s[0:1]
s[-1]
s[::1]
#Eingebaute Funktionen
len(s)
s.split()
",".join(l)
s.strip(".")
s.capitalize()
s.title()
s.upper()
s.lower()
s.swapcase()
s.replace(".", "!")
l.append("5")
l.insert(0, "10")
del l[0]
l.remove("10")
l.pop()
l.index("1")
l.count("3")
l.sort()
c = l.copy()
d.keys()
d.values()
d.items()
#für Schleife
for val in l:
print(val)
#Berechnung
False | True
True & True
1 > 0
0 >= 0
#if-Anweisung
if s == "s":
print("s!")
elif s == "str":
print("str!")
else:
print("!!!")
#while-Schleife
count = 0
while count < 3:
print(count)
count += 1
while True:
print(count)
if count == 5:
break
count += 1
#Listeneinschlussnotation
ll = [v for v in range(10)]
#Funktion
def f(a,b):
return a+b
#Klasse
class S():
def __init__(self, a, b):
self.a = a
self.b = b
def rep():
print(self.a + " " + self.b)
ss = S("Thank", "you")
ss.rep()
Recommended Posts