INFO
This commit is contained in:
12
2.Erste Programme/14. While-Schleife/beispiel.py
Normal file
12
2.Erste Programme/14. While-Schleife/beispiel.py
Normal file
@ -0,0 +1,12 @@
|
||||
# Programm, welches wiederholend dividiert (bis zu Untergrenze)
|
||||
|
||||
x = round((float(input("Gebe x ein:"))),2)
|
||||
|
||||
# Verarbeitung mittels while
|
||||
untergrenze=1
|
||||
index=0
|
||||
while x>untergrenze:
|
||||
x=x/2
|
||||
index=index+1
|
||||
print(x)
|
||||
print("Es wurde %smal durch 2 geteilt"%(index))
|
43
2.Erste Programme/14. While-Schleife/while-schleife.py
Normal file
43
2.Erste Programme/14. While-Schleife/while-schleife.py
Normal file
@ -0,0 +1,43 @@
|
||||
# Programm, welches die While-Schleife einführt
|
||||
|
||||
'''
|
||||
# Standard
|
||||
i=1
|
||||
|
||||
while i<=6:
|
||||
print(i)
|
||||
i=i+1
|
||||
'''
|
||||
|
||||
''''
|
||||
# Zusatz1: break
|
||||
i=1
|
||||
|
||||
while i<=6:
|
||||
print(i)
|
||||
if i==3:
|
||||
print("Herr Kaiser macht %s Sachen"%(i))
|
||||
break
|
||||
i=i+1
|
||||
'''
|
||||
|
||||
'''
|
||||
i=0
|
||||
# Zusatz2: continue (anfang der While-Schleife)
|
||||
while i<=6:
|
||||
i=i+1
|
||||
if i==3:
|
||||
print("Herr Kaiser macht %s Sachen"%(i))
|
||||
continue
|
||||
print(i)
|
||||
'''
|
||||
|
||||
'''
|
||||
i=1
|
||||
# Fallunterscheidung innerhalb einer While-Schleife
|
||||
while i<=6:
|
||||
print(i)
|
||||
i=i+1
|
||||
else:
|
||||
print("Robin ist ein Hurensohn\r\ni ist nicht mehr kleiner als 6.")
|
||||
'''
|
Reference in New Issue
Block a user