/media/sda-magnetic/david/Dokumente-15/informatik/python/erste-uebung-in-python-2023-10-01-steht-auch-so-im-lernskript/dasallgemeineamamanfang.py


x = True
if x:
    print("Hallo")
    
# Kommentare 

# Zahlen 

4 + 5
3 + 3
(50 * 2 + 1) * 100

x = 20
y = 10
x * y

4.12 * 3.37

# Zeichenketten 

"Hallo"
"Hallo Welt"
"\"Hallo Welt\""


s = "Hallo Welt"
print(s)

s2 = s + " ! Hallo Welt!"
print(s2)

s[0]
'H'

s[2:4]
'll'

# Listen:

lst = ['hallo', 'welt', 'sagt', 'jemand']

a = 0
while a < 10:
    print(a)
    a=a+1
    
x = 5
if x < 0:
    print("Kleiner")
elif x == 0:
    print("Gleich")
elif x == 1:
    print("Bisschen groesser")
else:
    print("Groesser")
    
a = ['Hallo', 'Welt', 'ist', 'Std', 'Spruch']
for x in a:
    print(a)
    
# Iteration:

for i in range (10):
    print(i)

for i in range (10):   
    if i == 5:
        break
    print i
    
def func(n):
    if n < 0:
        n = n*(-1)
    for i in range (n):
        print (i)
        
func(6)

# Module 

# import <MODULNAME>

# Lesen und Schreiben von Dateien:


# w schreiben 
# r lesen 
# a anhaengen
# r+ lesen und schreiben 

f = open ('/home/david/test.txt','r')
s=f.read()
s+=f.readline()
print(s)
f.close()
f = open ('/home/david/test.txt','a')
f.write('Hallo')
f.close()