示例#1
0
def main():
    # 1. Welcome
    f.say_hello("Welkom bij het 'Guess the Secret Number' spel")

    # 2. Naam van de speler inlezen
    boodschap = "Wat is Uw naam? "
    naam = f.lees_str(boodschap)
    print("Welkom, " + naam + "!")

    # 3. Main loop
    while True:
        boodschap = "\nWould you like to A) play a new game, B) see the best scores, or C) quit? "
        selection = f.lees_letter(boodschap, ["A", "B", "C"])

        if selection == "A":
            # Een spel spelen
            boodschap = "\nWil U het (E)asy of (H)ard level? "
            level = f.lees_letter(boodschap, ["E", "H"])
            if level == "E":
                f.play_game(naam, "easy")
            elif level == "H":
                f.play_game(naam, "hard")

        elif selection == "B":
            # De huidige topscores afdrukken
            f.druk_records("results.txt")

        elif selection == "C":
            # Stoppen
            break

    # 4. Afscheid
    print("\nBedankt voor het spelen. Hope to see you soon...")
示例#2
0
def main():

    # 1. Welcome
    f.say_hello("Welkom bij het Spelers Management programma")

    # 2. Hoofd loop
    while True:
        boodschap = '\nWil U A) een speler toevoegen, B) de geregistreerde spelers bekijken of C) stoppen? '
        selection = f.lees_letter(boodschap, ["A", "B", "C"])

        if selection == "A":
            # Een speler toevoegen
            boodschap = "\nWil U een (B)asketbal speler of een (V)oetbal speler toevoegen? "
            keuze = f.lees_letter(boodschap, ["B", "V"])
            nieuwe_speler = f.create_speler(keuze)

            # Opslaan?
            print("\nU hebt de volgende speler gedefinieerd: ")
            print(nieuwe_speler.__dict__)
            boodschap = "\nWil U deze speler opslaan? (J/N) "
            keuze = f.lees_letter(boodschap, ["J", "N"])
            if keuze == "J":
                # De speler opslaan in de database
                f.schrijf_db("spelers.txt", nieuwe_speler.__dict__)
            elif keuze == "N":
                print("De gegevens van de speler worden niet opgeslagen!")

        elif selection == "B":
            # Bestaande spelers afdrukken
            f.druk_records("spelers.txt")

        elif selection == "C":
            # Stoppen
            break

    # 3. Afscheid
    print(
        "\nBedankt voor het gebruik van onze service. Hope to see you soon...")
示例#3
0
## Importieren von einzelnen Funktionen aus der functions Bibliothek

#from functions import say_hello - diese variante braucht weniger Rechenleistung - ist also bei großen Programmen mit vielen Bibliotheken zu bevorzugen
#from functions import say_goodbye

#say_hello()
#say_goodbye()

## alternative variante (gesamte Bibliothek functions importieren, dann einzelne funktionen anwenden)

import functions
functions.say_hello()
functions.say_goodbye()
functions.say_hello()
示例#4
0
from functions import say_hello
say_hello()
say_hello()
say_hello()
say_hello()

val = addition(2, 3)
示例#5
0
 def test_say_hello(self):
     name = "Marcus"
     expected_result = "Hello, Marcus!"
     actual_result = functions.say_hello(name)
     self.assertEqual(expected_result, actual_result)
from functions import say_hello

text = say_hello(name="Ninja")
print(text)
from functions import say_hello

say_hello(name="Ninja")
示例#8
0
from functions import say_hello

say_hello("Mirko")
示例#9
0
from functions import say_hello

text = say_hello(name="Basti")

print(text)
示例#10
0
from functions import say_hello, check_if_prime

print(say_hello('Andis'))
# print(say_hello(name='Peteris'))
# print(say_hello('Anna'))
#
# title = say_hello('Olegs')
# print('<b>{}</b>'.format(title))


for i in range(1, 51):
    if check_if_prime(i):
        print(i, end=', ')
print('\n')

while True:
    number = input('Ludzu ievadiet skaitli vai X lai izietu: ')
    if number.lower() == 'x':
        break
    is_prime = check_if_prime(int(number))
    if is_prime:
        print('Jūsu ievadītais skaitlis {} ir pirmskaitlis'.format(number))
    else:
        print('Jūsu ievadītais skaitlis {} NAV pirmskaitlis'.format(number))