[&]
18.220.163.91
workshop: #lesson-3.html
AD
mod2
py
app-2-1.py
app-2-2.py
# Chapter: 2.1 [8] # Subject: calculations # Time: 3 minutes # Go! num1 = input("Enter A: ") num2 = input("Enter B: ") result = float(num1) + float(num2) # int() # float() print("Calculations") print("Result "+str(result))
# Chapter: 2.2 [9] # Subject: conditions # Time: 3 minutes # Go! key = input("Press ANY key to continue...") if key=="": print("Nothing pressed") else: print("You entered: "+key) print(ord(key)) print("Now the world will end!")
# Chapter: 2.3 [10] # Subject: multi-conditions # Time: 8 minutes # Go! print("Welcome in MILIONERZY") print("Q1: What means GUI?") print("A: Graphical User Intuition?") print("B: Graphical Used Interface?") print("C: Generic User Interface?") print("D: Graphical User Interface?") key = input("Press answer key to choose: ") key = key.lower() if key=="": print("\nNothing pressed") elif key=="a": print("Are you sure?") elif key=="b": print("Almoste") elif key=="c": print("Right!") elif key=="d": print("Really, Really") print("Your answear is: "+key) print("QUIZ ended for you!")
# Chapter: 2.4 [11] # Subject: switch # Time: 1 minutes # Go! print("Welcome in MILIONERZY") print("Q1: What means GUI?") print("A: Graphical User Intuition?") print("B: Graphical Used Interface?") print("C: Generic User Interface?") print("D: Graphical User Interface?") key = input("Press answer key to choose: ") key = key.lower() if key=="": print("Nothing pressed") elif key=="a": print("Are you sure?") elif key=="b": print("Almoste") elif key=="c": print("Right!") elif key=="d": print("Really, Really") print("Your answear is: "+key) print("QUIZ ended for you!")
# Chapter: 2.5 [12] # Subject: inner IFs # Time: 12 minutes # Go! print("Operator") print("1 Informacje o produktach") print("2 Zgłoszenie techniczne") print("3 Płatności i faktury") print("4 Klienci korporacyjni") print("0 Powtórz menu") a = input("Choose: ") if a=="1": print("Informacje o produktach") print("1 Domeny") print("2 Hosting") print("3 Poczta e-mail") print("4 Serwery dedykowane i VPS") print("9 Powrót do menu") a = input("Choose: ") if a=="1": print("Wybrałeś informacje o Domenach") elif a=="2": print("Dostępne oferty Hostingu") elif a=="3": print("Usługi pocztowe") elif a=="4": print("Wykup serwer") elif a=="2": print("Zgłoszenie techniczne") print("1 Poczta") print("2 Domeny i WWW") a = input("Choose: ") if a=="1": print("Łączę ze specjalistą Gołębiem pocztowym") elif a=="2": print("Łączę ze specjalistycznymi Małpami naprawczymi") else: print("Niezgodny wybór")
# Chapter: 2.6 [13] # Subject: switch imitation # Time: 6 minutes # Go! def switch(args): switcher = { 0: "zero", 1: "one", 2: "two" } return switcher.get(args,"default") #return "Jestem Switchem #"+str(args) print("#1 switch") print(switch(1)) def two(): return "TWO" def apok(args=2): return { 0: "zero", 1: "one", 2: two() }.get(args) # .get(args,"default") print("#2 switch #1 run") print(apok()) print("#2 switch #2 run") print(apok(1))
# Chapter: 2.7 [14] # Subject: multi IFs # Time: 8 minutes # Go! public = True close = False form = None if public==True and close!=False and form!=None: print("Formularz rejestracji") else: if form==None: print("Brak formularza") if close==True: print("Rejestracja zamknięta") if public==False: print("Formularz nieopublikowany")