def shipCost(): global ENTERED_VALUE v = int(0) m = int(0) if MATS_NAME: while v < ORES: print("Press", v, "to edit the amount of", MATS_NAME[v], "your ship costs.") v += 1 print("Press", ORES, "to go back to the main menu.") print() print("You current own: ") print() while m < ORES: print(MATS_NAME[m], SHIP_VALUE[m]) m += 1 print() oreUpdate = getInteger("Make your selection: ") if oreUpdate < ORES: SHIP_VALUE[oreUpdate] = getInteger("Input the new value: ") saveData() print() updateAgain = getString( "Do you with to update another value? (y/n) ") if updateAgain == 'y': cls() shipCost() elif updateAgain == 'n': cls() coreFunction() elif oreUpdate == ORES: cls() coreFunction() else: print() print("Please make a valid selection.") time.sleep(2) cls() shipCost() if not MATS_NAME: print("There are no materials for the ship cost to be updated.") time.sleep(2) cls() coreFunction() return
def neemDoel(): while True: cel = getString("Welke cel kies je? ").upper() if len(cel) != 2: print("Geef een cel in als XY,", "met X een letter en Y een cijfer") continue if cel[0] not in "ABCD": print("De letter moet tussen A en", chr(ord("A") + BREEDTE - 1), "liggen") continue if cel[1] not in "123": print("Cijfer moet tussen 1 en", HOOGTE, "liggen") continue return ord(cel[0]) - ord("A"), ord(cel[1]) - ord("1")
from pcinput import getString s = getString("Please enter a string: ") count = 0 if ("a" in s) or ("A" in s): count += 1 if ("e" in s) or ("E" in s): count += 1 if ("i" in s) or ("I" in s): count += 1 if ("o" in s) or ("O" in s): count += 1 if ("u" in s) or ("U" in s): count += 1 if count == 0: print("There are no vowels in the string.") elif count == 1: print("There is only one different vowel in the string.") else: print("There are", count, "different vowels in the string.")
from pcinput import getFloat from pcinput import getInteger from pcinput import getString num = getInteger("Enter a number of students (it has to be at least 2): ") counter = 0 m1 = 0 m2 = 0 n1 = "0" n2 = "0" while counter < 2 or num > counter: name = getString("Enter a student name: ") score = getFloat("Enter a student score: ") if score > m1: m2 = m1 n2 = n1 m1 = score n1 = name if score > m2 and score < m1: m2 = score n2 = name counter += 1 print("Top two students:{}{}{} score is {:.1f}{}{}{} score is {:.1f}".format( "\n", n1, "'s", m1, "\n", n2, "'s", m2))
from pcinput import getString s = getString("Geef een string: ") count = 0 if ("a" in s) or ("A" in s): count += 1 if ("e" in s) or ("E" in s): count += 1 if ("i" in s) or ("I" in s): count += 1 if ("o" in s) or ("O" in s): count += 1 if ("u" in s) or ("U" in s): count += 1 if count == 0: print("Er zitten geen klinkers in de string.") elif count == 1: print("Er zit maar 1 verschillende klinker in de string.") else: print("Er zijn", count, "verschillende klinkers.")
halfbytelist.extend( [ int( c/16 ), c%16 ] ) if halfbytelist[-1] == 0: del halfbytelist[-1] bytelist = [] while len( halfbytelist ) > 0: num = halfbytelist.pop(0) if num > 0: bytelist.append( LETTERS[num-1] ) continue num = 16*halfbytelist.pop(0) + halfbytelist.pop(0) bytelist.append( num ) return bytes( bytelist ) # Vraag om input bestand en lees de inhoud while True: filein = getString( "Geef input bestand: " ) if not exists( filein ): print( filein, "bestaat niet" ) continue try: fp = open( filein, "rb" ) buffer = fp.read() fp.close() except IOError as ex: print( filein, "kan niet verwerkt worden, kies andere" ) print( "Error [{}]: {}".format( ex.args[0], ex.args[1] )) continue break # Vraag om output bestand en creeer het while True:
def materialUpdater(): if MATS_NAME: print("Press '1' to add a material.") print("Press '2' to remove a material.") print("Press '3' to exit to the main menu.") print() selection = getInteger("Please make your selection: ") if selection == 1: print() print("The current materials are: ") print() y = int(0) while y < ORES: print(MATS_NAME[y]) y += 1 print() material_Name = getString("Input name of the new material: ") MATS_NAME.append(material_Name) MATS_VALUE.append(0) SHIP_VALUE.append(0) cls() saveData() coreFunction() elif selection == 2: print() print("The current materials are: ") print() m = int(0) while m < ORES: print(m, MATS_NAME[m]) m += 1 print() if beginChoice == 'y': material_Name2 = getInteger( "Input integer of the material you wish to remove: ") MATS_NAME.pop(material_Name2) MATS_VALUE.pop(material_Name2) SHIP_VALUE.pop(material_Name2) cls() saveData() coreFunction() elif beginChoice == 'n': material_Name2 = getInteger( "Input integer of the material you wish to remove: ") MATS_NAME.pop(material_Name2) MATS_VALUE.pop(material_Name2) SHIP_VALUE.pop(material_Name2) cls() saveData() coreFunction() elif selection == 3: cls() coreFunction() elif not MATS_NAME: print("Press '1' to add a material.") print("Press '2' to exit to the main menu.") print() selection = getInteger("Please make your selection: ") if selection == 1: print() material_Name = getString("Input name of the new material: ") MATS_NAME.append(material_Name) MATS_VALUE.append(0) SHIP_VALUE.append(0) cls() saveData() coreFunction() elif selection == 2: cls() coreFunction() return
from pcinput import getInteger, getLetter, getString bediende = getString("Wat is uw naam? ") in_kassa = getInteger("Wat zit er in uw kassa? (Begingeld): ") loop_antwoord = "N" while loop_antwoord != "J": aantal_mosselen = getInteger("Geef het aantal mosselen-friet in: ") aantal_khapje = getInteger("Geef het aantal koninginnehapjes in: ") aantal_drank = getInteger("Geef het aantal drankjes in: ") aantal_ijsjes = getInteger("Geef het aantal ijsjes in: ") bedrag_mosselen = aantal_mosselen * 20 bedrag_khapje = aantal_khapje * 10 bedrag_drank = aantal_drank * 2 bedrag_ijsjes = aantal_ijsjes * 3 bedrag_totaal = bedrag_mosselen + bedrag_khapje + bedrag_drank + bedrag_ijsjes print("\n") vorm = "{:25}{:>2}{:<6}{:>8.2f} euro" print( vorm.format("Mosselen - friet", aantal_mosselen, " stuks", bedrag_mosselen)) print( vorm.format("Koninginnehapje - friet", aantal_khapje, " stuks", bedrag_khapje)) print(vorm.format("drankjes", aantal_drank, " stuks", bedrag_drank)) print(vorm.format("ijsjes", aantal_ijsjes, " stuks", bedrag_ijsjes)) print("{:25}{:>2}{:<6}{:>8}".format("", "", "", "=============")) # -print(vorm.format("","","________")) print(vorm.format("Totaal te betalen:", "", "", bedrag_totaal))
from pcinput import getString # vraagt of het de eerste keer is eersteKeer = getString("Is dit de eerste keer dat je inlogt? ") #controlleert of het de eerste keer is if eersteKeer == "ja": # vraagt de naam en wachtwoord naam = getString("Wat is uw naam? ") wachtwoord = getString("Wat is uw wachtwoord? ") else: wijzigen = getString("Wens je het wachtwoord te wijzigen? ") #kijken voor het wachtwoor te wijzigen of niet if wijzigen == "ja": wachtwoord = getString("Geef het nieuwe wachtwoord in. ") else: naam = getString("Wat is uw naam? ") wachtwoord = getString("Wat is uw wachtwoord? ") # controlleert of het correct is of niet if naam == "Jolien" and wachtwoord == "knutselKnuts": print("Welkom Jolien") else: print("Ik ken je niet")
from pcinput import getString gebruikersnaam = getString("Geef uw gebruikersnaam op") wachtwoord = getString("Wachtoord ingeven") if gebruikersnaam==str("Jolien") and wachtwoord==str("KnutselKnuts"): print("welkom Jolien") else: print("ik ken je niet.")
from pcinput import getString while True: x = getString("enter a string: ") y = bool(x) if y == True: count = 1 run = 1 run1 = 1 temp = "" temp1 = "" for i in x: if temp == i: if temp1 != i and count != 1: count += 1 count += 1 run += 1 if run > run1: run1 = run temp1 = i else: run = 1 temp = i if count > 1: print("{} {}{}{} {}".format("count", count, "\n", "max", run1)) else: print("{} {}{}{} {}".format("count", "0", "\n", "max", "0")) else: print("{} {}{}{} {}".format("count", "0", "\n", "max", "0")) break
from pcinput import getFloat from pcinput import getString while True: units = getString("Enter units: ") dis = getFloat("Enter a distance: ") if units == 'mi': #print("1") kilo = dis*1.609 print("distance in miles: {:.2f}".format(dis)) print("distance in km is: {:.2f}".format(kilo)) break elif units == "km": #print("2") miles = dis /1.609 print("distance in km: {:.2f}".format(dis)) print("distance in mi is: {:.2f}".format(miles)) break else: #print("3") print("wrong input!") break
from pcinput import getString woord1 = getString("Geef woord 1: ") woord2 = getString("Geef woord 2: ") gemeen = "" for letter in woord1: if (letter in woord2) and (letter not in gemeen): gemeen += letter if gemeen == "": print("De woorden hebben geen tekens gemeen.") else: print("De woorden delen de volgende tekens:", gemeen)
def firstLoading(): global MATS_NAME global MATS_VALUE global SHIP_VALUE global firstLoad global beginChoice beginChoice = "" try: with open("first_load.csv") as first_file: first_reader = csv.reader(first_file, delimiter=',') c = 0 for row3 in first_file: c += 1 if c == 1: firstLoad = int(row3[0]) if c == 2: beginChoice = str(row3[0]) break except Exception: firstLoad = 1 if firstLoad == 1: print( "The standard (pre-loaded) materials are: Silicate, Carbon, Iridium, Adamantite, Palladium, Titanium, Quantium." ) print() userPrompt = getString( "Do you wish for the standard materials to be included? (y/n) ") if userPrompt == 'y': print() MATS_NAME = [ SILICATE_NAME, CARBON_NAME, IRIDIUM_NAME, ADAMANTITE_NAME, PALLADIUM_NAME, TITANIUM_NAME, QUANTIUM_NAME ] MATS_VALUE = [ SILICATE, CARBON, IRIDIUM, ADAMANTITE, PALLADIUM, TITANIUM, QUANTIUM ] SHIP_VALUE = list(MATS_VALUE) firstLoad = 0 beginChoice = 'y' saveData() loadExtraMaterial() elif userPrompt == 'n': MATS_NAME = [] MATS_VALUE = [] SHIP_VALUE = list(MATS_VALUE) firstLoad = 0 beginChoice = 'n' saveData() loadExtraMaterial() else: print() print("Please make a valid selection.") time.sleep(2) cls() coreFunction() elif firstLoad == 0: if beginChoice == 'y': MATS_NAME = [ SILICATE_NAME, CARBON_NAME, IRIDIUM_NAME, ADAMANTITE_NAME, PALLADIUM_NAME, TITANIUM_NAME, QUANTIUM_NAME ] MATS_VALUE = [ SILICATE, CARBON, IRIDIUM, ADAMANTITE, PALLADIUM, TITANIUM, QUANTIUM ] SHIP_VALUE = list(MATS_VALUE) loadExtraMaterial() if beginChoice == 'n': MATS_NAME = [] MATS_VALUE = [] SHIP_VALUE = list(MATS_VALUE) loadExtraMaterial() return
def coreFunction(): global MATS_NAME global MATS_VALUE global SHIP_VALUE global ORES global COST_ENABLED global TOGGLE global ENTERED_VALUE global firstLoad ORES = len(MATS_NAME) if MATS_NAME: mats_string = ', '.join(MATS_NAME) print("The names of the current known materials are:", mats_string) print() v = int(0) print("You currently own: ") print() while v < ORES: print(MATS_NAME[v], MATS_VALUE[v]) v += 1 print() if not MATS_NAME: print("There are no currently known materials.") print() loadData() if COST_ENABLED == True and ENTERED_VALUE == True: x = int(0) if ENTERED_VALUE == True: print("The ship you want costs:") print() while x < ORES: print(MATS_NAME[x], SHIP_VALUE[x]) x += 1 print() y = int(0) if ENTERED_VALUE == True: print("You still need:") print() while y < ORES: if int(SHIP_VALUE[(y)]) - int(MATS_VALUE[y]) <= 0: print(MATS_NAME[y], "0") y += 1 else: print(MATS_NAME[y], int(SHIP_VALUE[y]) - int(MATS_VALUE[y])) y += 1 print() print("Press 'u' to update materials mined.") print("Press 'x' to exit out of the program.") if COST_ENABLED == True: print("Press 'c' to set a shipcost.") print("Press 'h' to see what this program is meant for.") print("Press 'f' to enable/disable ship cost calculation.") print("Press 'm' to update the amount of materials.") print() print("Press 'r' to reset your inventory.") print("Press 'rx' to reset all data.") print() selection = getString("Please make your selection now: ") print() if selection == 'u': cls() updateInventory() elif selection == 'x': saveData() time.sleep(0.1) SystemExit() elif selection == 'h': cls() x = int(0) l = 4 while x < l: print(info[x]) x += 1 print() coreLoop = input("Press Enter to continue.") if coreLoop == "": cls() coreFunction() elif coreLoop != "": cls() coreFunction() elif selection == 'c': if COST_ENABLED == True: cls() shipCost() else: print("You have disabled this feature.") time.sleep(2) cls() coreFunction() elif selection == 'f': if TOGGLE == 0: COST_ENABLED = False print("Ship cost calculation is now disabled.") time.sleep(2) cls() TOGGLE = 1 coreFunction() elif TOGGLE == 1: COST_ENABLED = True print("Ship cost calculation is now enabled.") TOGGLE = 0 time.sleep(2) cls() coreFunction() elif selection == 'r': listlength = len(MATS_VALUE) for i in range(listlength): MATS_VALUE[i] = 0 SHIP_VALUE[i] = 0 print() print("Your inventory has been reset.") saveData() time.sleep(2) cls() coreFunction() elif selection == 'rx': listlength = len(MATS_VALUE) del MATS_NAME[:] del MATS_VALUE[:] del SHIP_VALUE[:] print() print("All data has been reset.") ENTERED_VALUE = False firstLoad = 1 beginChoice = "" saveData() time.sleep(2) cls() firstLoading() elif selection == 'm': cls() materialUpdater() else: print() print("Please make a valid selection.") time.sleep(2) cls() coreFunction() return
import pcinput z = pcinput.getString("Voeg een string in: ") print(z)
from pcinput import getString # vraagt de naam en wachtwoord naam = getString("Wat is uw naam? ") wachtwoord = getString("Wat is uw wachtwoord? ") # controlleert of het correct is of niet if naam == "Jolien" and wachtwoord == "knutselKnuts": print("Welkom Jolien") else: print("Ik ken je niet")
from pcinput import getString woord = getString("geef een woord of zin: ") tell = 0 if "a" in woord or "A" in woord: tell += 1 if "e" in woord or "E" in woord: tell += 1 if "i" in woord or "I" in woord: tell += 1 if "o" in woord or "O" in woord: tell += 1 if "u" in woord or "U" in woord: tell += 1 if tell == 0: print("er zijn geen klinkers") elif tell == 1: print("er is 1 klinker") else: print("er zijn " + str(tell) + " verschillende klinkers")
import pcinput invoerTekst = pcinput.getString('Geef wat tekst: ') print 'Tekst bestaat uit {}'.format(len(invoerTekst))
from pcinput import getString word1 = getString("Give word 1: ") word2 = getString("Give word 2: ") common = "" for letter in word1: if (letter in word2) and (letter not in common): common += letter if common == "": print("The words share no characters.") else: print("The words have the following in common:", common)
from pcinput import getString eerstekeer = getString("Is dit je eerste keer? ja/nee") if eerstekeer == str("ja"): wachtwoordnieuw = getString("Geef een wachtwoord op") gebruikersnaam = getString("Geef uw gebruikersnaam op") wachtwoord = getString("geef uw wachtwoord op") if wachtwoord == wachtwoordnieuw and gebruikersnaam == str("Jolien"): print("welkom Jolien") else: print("ik ken je niet") else: wens = getString("Wens je het wachtwoord te wijzigen? ja/nee") if wens == str("ja"): wachtwoordnieuw = getString("Geef een wachtwoord op") gebruikersnaam = getString("Geef uw gebruikersnaam op") wachtwoord = getString("geef uw wachtwoord op") if wachtwoord == wachtwoordnieuw and gebruikersnaam == str("Jolien"): print("welkom Jolien") else: print("ik ken je niet") else: gebruikersnaam = getString("Geef uw gebruikersnaam op") wachtwoord = getString("Wachtoord ingeven") if gebruikersnaam == str("Jolien") and wachtwoord == str( "KnutselKnuts"): print("welkom Jolien") else: print("ik ken je niet.")