lehrkraefte:blc:informatik:glf20:programmieren:while

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
lehrkraefte:blc:informatik:glf20:programmieren:while [2020/10/28 11:43]
mirco.triner
lehrkraefte:blc:informatik:glf20:programmieren:while [2020/10/30 13:19]
mirco.triner
Line 18: Line 18:
     print(counter)     print(counter)
     counter += 1     counter += 1
 +</code>
 +</WRAP>
 +
 +<WRAP info>
 +Die folgenden Codeblöcke führen zum gleichen Ergebnis:
 +<code>
 +counter += 1
 +</code>
 +<code>
 +counter = counter + 1
 </code> </code>
 </WRAP> </WRAP>
Line 61: Line 71:
 <hidden Lösungvorschläge> <hidden Lösungvorschläge>
 <code python> <code python>
 +#Bankautomat
 +
 print("Guten Tag") print("Guten Tag")
-= inputInt("Welcher Betrag soll ausbezahlt werden?")+cash = inputInt("Welcher Betrag soll ausbezahlt werden?")
  
-while > 0: +while cash > 0: 
-    if t//1000 > 0: +    if cash//1000 > 0: 
-        print(str(t//1000) + "x 1000.-"+        print("%d x 1000.-" % (cash//1000)
-        t%1000 +        cash cash%1000 
-    elif t//200 > 0: +    elif cash//200 > 0: 
-        print(str(t//200) + "x 200.-"+        print("%d x 200.-" % (cash//200)
-        t%200 +        cash cash%200 
-    elif t//100 > 0: +    elif cash//100 > 0: 
-        print(str(t//100) + "x 100.-"+        print("%d x 100.-" % (cash//100)
-        t%100 +        cash cash%100 
-    elif t//50 > 0: +    elif cash//50 > 0: 
-        print(str(t//50) + "x 50.-"+        print("%d x 50.-" % (cash//50)
-        t%50 +        cash cash%50 
-    elif t//20 > 0: +    elif cash//20 > 0: 
-        print(str(t//20) "20.-") +        print("%d x 20.-" % (cash//20)
-        t%20+        cash = cash%20 
 +    elif cash//10 > 0: 
 +        print("%d 10.-" % (cash//10)
 +        cash cash%10
     else:     else:
-        print(str(t//10) + "x 10.-") +        print("und noch ein wenig Münz") 
-        t%10+        cash 
 </code> </code>
  
Line 104: Line 120:
  
 <code python> <code python>
 +#Zahl zwischen 1-100
 to_be_guessed = input("Neue Zahl: ") to_be_guessed = input("Neue Zahl: ")
 guess = 50 guess = 50
Line 116: Line 133:
         else:         else:
             guess += ((to_be_guessed - guess) // 2)             guess += ((to_be_guessed - guess) // 2)
-    print("Round: "+str(counter)+"Guess: "+str(guess))+    print("Round: %d, Guess %d(counter, guess))
     counter += 1     counter += 1
  
  • lehrkraefte/blc/informatik/glf20/programmieren/while.txt
  • Last modified: 2020/10/30 13:21
  • by mirco.triner