krangelov2004

CHOPOV2025-fund-python-basic_syntax.py

May 19th, 2025
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.75 KB | Fixit | 0 0
  1. #1
  2.  
  3. name = input()
  4. if name == "Johnny":
  5.     print("Hello, my love!")
  6. else:
  7.     print(f"Hello, {name}!")
  8.  
  9.  
  10. #2
  11.  
  12. ages = int(input())
  13. drink = ""
  14. if ages <= 14:
  15.     drink = "toddy"
  16. elif ages <= 18:
  17.     drink = "coke"
  18. elif ages <= 21:
  19.     drink = "beer"
  20. else:
  21.     drink = "whisky"
  22. print(f"drink {drink}")
  23.  
  24.  
  25. #3
  26.  
  27. number_of_messages = int(input())
  28. for message in range(number_of_messages):
  29.     current_number = int(input())
  30.     current_message = ""
  31.     if current_number == 88:
  32.         current_message = "Hello"
  33.     elif current_number == 86:
  34.         current_message = "How are you?"
  35.     elif current_number < 88:
  36.         current_message = "GREAT!"
  37.     else: # elif current_number > 88
  38.         current_message = "Bye."
  39.     print(current_message)
  40.  
  41. #4
  42.  
  43. divisor = int(input())
  44. boundary = int(input())
  45. for current_number in range(boundary, divisor -1, -1):
  46.     if current_number % divisor == 0:
  47.         break
  48. print(current_number)
  49.  
  50. #5
  51.  
  52. number_of_orders = int(input())
  53. total_price = 0
  54. for order in range(number_of_orders):
  55.     price_per_capsule = float(input())
  56.     days = int(input())
  57.     capsules_per_day = int(input())
  58.     if price_per_capsule < 0.01 or price_per_capsule > 100.00:
  59.         continue
  60.     elif days < 1 or days > 31: # if days not in range(1, 31+1)
  61.         continue
  62.     elif capsules_per_day < 1 or capsules_per_day > 2000:
  63.         continue
  64.     price = price_per_capsule * days * capsules_per_day
  65.     total_price += price
  66.     print(f"The price for the coffee is: ${price:.2f}")
  67.  
  68. print(f"Total: ${total_price:.2f}")
  69.  
  70. #6
  71.  
  72. number_of_strings = int(input())
  73. for current_strings in range(number_of_strings):
  74.     current_string = input()
  75.     if "," in current_string \
  76.             or "." in current_string \
  77.             or "_" in current_string:
  78.         print(f"{current_string} is not pure!")
  79.     else:
  80.         print(f"{current_string} is pure.")
  81.  
  82.  
  83. #7
  84.  
  85. current_string = input()
  86. while current_string != "End":
  87.     if current_string != "SoftUni":
  88.         new_string = ""
  89.         for character in current_string:
  90.             new_string += character * 2
  91.         print(new_string)
  92.     current_string = input()
  93.  
  94.  
  95.  
  96.  
  97.  
  98. #10
  99. first_string = input()
  100. second_string = input()
  101. last_printed_string = first_string
  102. for character_index in range(len(first_string)):
  103.     left_part = second_string[:character_index + 1]
  104.     right_part = first_string[character_index + 1:]
  105.     new_string = left_part + right_part
  106.     if new_string != last_printed_string:
  107.         print(new_string)
  108.         last_printed_string = new_string
  109.  
  110.  
  111.  
  112. # print(my_string[start:end:step])
  113. # print(my_string[start:end])
  114. # print(my_string[start:])
  115. # print(my_string[:end])
  116. # print(my_string[::step])
  117.  
  118.  
  119.  
  120.  
  121. #12
  122.  
  123.  
  124. quantity_of_decorations = int(input())
  125. remaining_days = int(input())
  126. total_cost = 0
  127. total_spirit = 0
  128. ornament_set_price = 2
  129. tree_skirt_price = 5
  130. tree_garland_price = 3
  131. tree_lights_price = 15
  132. for current_day in range(1, remaining_days + 1):
  133.     if current_day % 11 == 0:
  134.         quantity_of_decorations += 2
  135.     if current_day % 2 ==0:
  136.         total_cost += ornament_set_price * quantity_of_decorations
  137.         total_spirit += 5
  138.     if current_day % 3 ==0:
  139.         total_cost += (tree_skirt_price + tree_garland_price) * quantity_of_decorations
  140.         total_spirit += 3 + 10
  141.     if current_day % 5 ==0:
  142.         total_cost += tree_lights_price * quantity_of_decorations
  143.         total_spirit += 17
  144.         if current_day % 3 == 0:
  145.             total_spirit += 30
  146.     if current_day % 10 == 0:
  147.         total_spirit -= 20
  148.         total_cost += tree_skirt_price + tree_garland_price + tree_lights_price
  149. if remaining_days % 10 == 0:
  150.     total_spirit -= 30
  151. print(f"Total cost: {total_cost}")
  152. print(f"Total spirit: {total_spirit}")
  153.  
  154.  
  155.  
  156.  
  157.  
Tags: pythons
Add Comment
Please, Sign In to add comment