print(vorm.format("Terug te geven: ", "", "", bedrag_terug)) # Uitbreiding 2 - terug te geven waarden terug_20 = bedrag_terug // 20 rest = bedrag_terug % 20 terug_10 = rest // 10 rest = rest % 10 terug_5 = rest // 5 rest = rest % 5 terug_2 = rest // 2 rest = rest % 2 terug_1 = rest // 1 # print(terug_20,"x20€, ",terug_10,"x10€, ",terug_5,"x5€, ",terug_2,"x2€, ",terug_1,"x1€") vorm = "{:25}{:>2}{:>17}" print(vorm.format("", "", "20€ x"), terug_20) print(vorm.format("", "", "10€ x"), terug_10) print(vorm.format("", "", "5€ x"), terug_5) print(vorm.format("", "", "2€ x"), terug_2) print(vorm.format("", "", "1€ x"), terug_1) print("\n") if aantal_mosselen > 0 or aantal_khapje > 0 or aantal_ijsjes > 0: print("smakelijk eten !!!") else: print("Gezondheid !!!") in_kassa += bedrag_tebetalen loop_antwoord = getLetter("Wilt u stoppen? (J/N)") print(bediende, "er zit ", in_kassa, "€ in uw kassa")
from pcinput import getLetter from sys import exit count = 0 lowest = 0 highest = 1001 print( "Take a number in mind between 1 and 1000." ) while True: guess = int( (lowest + highest) / 2 ) count += 1 prompt = "I guess "+str( guess )+". Is your number"+\ " (L)ower or (H)igher, or is this (C)orrect? " response = getLetter( prompt ) if response == "C": break elif response == "L": highest = guess elif response =="H": lowest = guess else: print( "Please enter H, L, or C." ) continue if lowest >= highest-1: print( "You must have made a mistake,", "because you said that the answer is higher than", lowest, "but also lower than", highest ) print( "I quit this game" ) exit() if count == 1:
fileout = getString( "Geef output bestand: " ) if exists( fileout ): print( fileout, "bestaat al" ) continue try: fp = open( fileout, "wb" ) except IOError as ex: print( fileout, "kan niet aangemaakt worden,", "kies een andere naam" ) print( "Error [{}]: {}".format( ex.args[0], ex.args[1] )) continue break # Vraag of de gebruiker wil comprimeren of decomprimeren. while True: dc = getLetter( "Wil je (C)omprimeren of (D)ecomprimeren? " ) if dc != 'C' and dc != 'D': print( "Kies C of D" ) continue break # Comprimeer of decomprimeer de buffer. if dc == 'C': buffer = comprimeer( buffer ) else: buffer = decomprimeer( buffer ) # Sla de verwerkte buffer op in het output bestand. try: fp.write( buffer ) fp.close()
from pcinput import getLetter from sys import exit teller = 0 laagste = 0 hoogste = 1001 print( "Denk aan een getal tussen 1 en 1000." ) while True: poging = int( (laagste + hoogste) / 2 ) teller += 1 prompt = "Ik raad "+str( poging )+". Is jouw getal"+\ " (L)ager of (H)oger, of is dit (C)orrect? " antwoord = getLetter( prompt ) if antwoord == "C": break elif antwoord == "L": hoogste = poging elif antwoord =="H": laagste = poging else: print( "Antwoord H, L, of C." ) continue if laagste >= hoogste-1: print( "Je moet een fout gemaakt hebben,", "want je hebt gezegd dat het getal hoger is dan", laagste, "maar ook lager dan", hoogste ) print( "Ik stop ermee" ) exit() if teller == 1:
from pcinput import getLetter doorgaan = True while doorgaan: print("Goed bezig") stop = getLetter("Stoppen? J/N") if stop == "J": doorgaan = False print("Gestopt")