Facebook
From Andrea Nagy, 3 Months ago, written in Python.
Embed
Download Paste or View Raw
Hits: 487
  1. import random
  2.  
  3.  
  4. def calculator():
  5.     num1 = int(input("Add a number:\n"))
  6.     num2 = int(input("Add a second number:\n"))
  7.     operations = input("Choose an operation (Addition: +, subtraction: -, multiplication: *, division: / ):\n")
  8.     if operations == "addition" or operations == "+":
  9.         return num1 + num2
  10.     elif operations == "subtraction" or operations == "-":
  11.         return num1 - num2
  12.     elif operations == "multiplication" or operations == "*":
  13.         return num1 * num2
  14.     elif operations == "division" or operations == "/":
  15.         return num1 / num2
  16.     else:
  17.         return (f"Error, this is no operation.:\n"
  18.                 f"Addition =          {num1 + num2}:\n"
  19.                 f"Subtraction =       {num1 - num2}:\n"
  20.                 f"Multiplication =    {num1 * num2}:\n"
  21.                 f"Division =          {num1 / num2}")
  22.  
  23.  
  24. def check(prompt, different_check):
  25.     while True:
  26.         user_input = input(prompt)
  27.         if user_input.isdigit():
  28.             num = int(user_input)
  29.             if 1 <= num <= 90 and num not in different_check:
  30.                 return num
  31.             else:
  32.                 print("You have match, please try another number 1-90")
  33.         else:
  34.             print("Error, please enter Valid Number to 1 - 90")
  35.  
  36.  
  37. def lotto():
  38.     different_check = set()
  39.     user_num1 = check("Please choose numbers 1-90. First:\n", different_check)
  40.     different_check.add(user_num1)
  41.     user_num2 = check("Please choose numbers 1-90. Second:\n", different_check)
  42.     different_check.add(user_num2)
  43.     user_num3 = check("Please choose numbers 1-90. Third:\n", different_check)
  44.     different_check.add(user_num3)
  45.     user_num4 = check("Please choose numbers 1-90. Fourth:\n", different_check)
  46.     different_check.add(user_num4)
  47.     user_num5 = check("Please choose numbers 1-90. Fifth:\n", different_check)
  48.     different_check.add(user_num1)
  49.  
  50.     print(f"Your number is = {user_num1},{user_num2},{user_num3},{user_num4},{user_num5}")
  51.     numbers = {user_num1, user_num2, user_num3, user_num4, user_num5}
  52.     win_num = set(random.sample(range(1, 91), 5))
  53.     print(f"The winner numbers is: {win_num}")
  54.     nums_match = numbers.intersection(win_num)
  55.     match_number = len(nums_match)
  56.  
  57.     if numbers == win_num:
  58.         print("You WIN!!!")
  59.     elif match_number == 4:
  60.         print(f"Amazing. You have 4 match: {match_number}")
  61.     elif match_number == 3:
  62.         print(f"Oh...just a little..Try now!. You have 3 match: {match_number}")
  63.     elif match_number == 2:
  64.         print(f"Hmm...maybe next time. You have 2 match: {match_number}")
  65.     elif match_number == 1:
  66.         print(f"It is bad luck. You have 1 match: {match_number}")
  67.  
  68.     else:
  69.         print("you lose! Try again!")
  70.  
  71.     return numbers
  72.  
  73.  
  74. def shopping():
  75.     my_list = []
  76.     while True:
  77.         items = input("Add your items to your list or:\n "
  78.                       "To print please press : p \n "
  79.                       "To delete items press: D:\n"
  80.                       "To exit press: exit:\n").lower()
  81.  
  82.         if items == "exit":
  83.             return f"Your list is: {my_list}"
  84.         elif items == "P".lower():
  85.             print(my_list)
  86.         elif items == "D".lower():
  87.             delete = my_list.remove(input(f"Which items delete?:\n Your list is: {my_list}"))
  88.             if delete not in my_list:
  89.                 print(f"Please select valid items from your list: {my_list}")
  90.                 print(items)
  91.             else:
  92.                 print(delete)
  93.         else:
  94.             my_list.append(items)
  95.  
  96.  
  97. def game():
  98.     valaszt = ["kő", "papír", "olló"]
  99.     gep_v = random.choice(valaszt)
  100.     jatekos_v = input("Kő, papír, vagy olló? Kilépéshez írd: >>> exit<<<:\n").lower()
  101.     print("a te választásod: ", jatekos_v)
  102.     print("a gép választása", gep_v)
  103.  
  104.     if gep_v == jatekos_v:
  105.         return "döntetlen"
  106.     elif jatekos_v == "kő" and gep_v == "olló" or \
  107.             jatekos_v == "olló" and gep_v == "papír" or \
  108.             jatekos_v == "papír" and gep_v == "kő":
  109.         return "Nyertél"
  110.     else:
  111.         return "Vesztettél"
  112.