Advertisement
Alexplazz

Untitled

Oct 27th, 2024
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.26 KB | None | 0 0
  1. # Answers
  2.  
  3. # 1. Book Purchase Program
  4. bookA_price = 15.00
  5. bookB_price = 12.50
  6. bookC_price = 9.75
  7.  
  8. num_bookA = int(input("How many of Book A? "))
  9. num_bookB = int(input("How many of Book B? "))
  10. num_bookC = int(input("How many of Book C? "))
  11.  
  12. total_bookA_price = num_bookA * bookA_price
  13. total_bookB_price = num_bookB * bookB_price
  14. total_bookC_price = num_bookC * bookC_price
  15.  
  16. total_price = total_bookA_price + total_bookB_price + total_bookC_price
  17.  
  18. print("Total price:", total_price)
  19.  
  20. # 2. Movie Ticket Counter
  21. adult_ticket_price = 10.00
  22. child_ticket_price = 6.00
  23.  
  24. num_adult_tickets = int(input("How many adult tickets? "))
  25. num_child_tickets = int(input("How many child tickets? "))
  26.  
  27. total_adult_price = num_adult_tickets * adult_ticket_price
  28. total_child_price = num_child_tickets * child_ticket_price
  29.  
  30. total_price = total_adult_price + total_child_price
  31.  
  32. print("Total cost:", total_price)
  33.  
  34. # 3. Fruit Purchase Calculator
  35. apple_price = 0.50
  36. banana_price = 0.30
  37. orange_price = 0.60
  38.  
  39. num_apples = int(input("How many apples? "))
  40. num_bananas = int(input("How many bananas? "))
  41. num_oranges = int(input("How many oranges? "))
  42.  
  43. total_apple_price = num_apples * apple_price
  44. total_banana_price = num_bananas * banana_price
  45. total_orange_price = num_oranges * orange_price
  46.  
  47. total_price = total_apple_price + total_banana_price + total_orange_price
  48.  
  49. print("Total price:", total_price)
  50.  
  51. # 4. Grocery Shopping
  52. bread_price = 2.00
  53. milk_price = 1.50
  54. egg_price = 0.20
  55.  
  56. num_breads = int(input("How many bread loaves? "))
  57. num_milk = int(input("How many bottles of milk? "))
  58. num_eggs = int(input("How many eggs? "))
  59.  
  60. total_bread_price = num_breads * bread_price
  61. total_milk_price = num_milk * milk_price
  62. total_egg_price = num_eggs * egg_price
  63.  
  64. total_price = total_bread_price + total_milk_price + total_egg_price
  65.  
  66. if total_price > 10.00:
  67.     total_price = total_price - 1.00
  68.  
  69. print("Total cost after discount (if applicable):", total_price)
  70.  
  71. # 5. Stationery Purchase
  72. pen_price = 1.20
  73. notebook_price = 3.00
  74. eraser_price = 0.50
  75.  
  76. num_pens = int(input("How many pens? "))
  77. num_notebooks = int(input("How many notebooks? "))
  78. num_erasers = int(input("How many erasers? "))
  79.  
  80. total_pen_price = num_pens * pen_price
  81. total_notebook_price = num_notebooks * notebook_price
  82. total_eraser_price = num_erasers * eraser_price
  83.  
  84. total_price = total_pen_price + total_notebook_price + total_eraser_price
  85.  
  86. print("Total price:", total_price)
  87.  
  88. # 6. Snack Order Calculator
  89. chips_price = 1.50
  90. chocolate_price = 2.00
  91. soda_price = 1.00
  92.  
  93. num_chips = int(input("How many packs of chips? "))
  94. num_chocolate = int(input("How many chocolate bars? "))
  95. num_soda = int(input("How many bottles of soda? "))
  96.  
  97. if num_chips >= 3:
  98.     chips_price = chips_price - 0.25
  99. if num_chocolate >= 3:
  100.     chocolate_price = chocolate_price - 0.25
  101. if num_soda >= 3:
  102.     soda_price = soda_price - 0.25
  103.  
  104. total_chips_price = num_chips * chips_price
  105. total_chocolate_price = num_chocolate * chocolate_price
  106. total_soda_price = num_soda * soda_price
  107.  
  108. total_price = total_chips_price + total_chocolate_price + total_soda_price
  109.  
  110. print("Total price:", total_price)
  111.  
  112. # 7. Toy Shop Program
  113. doll_price = 8.00
  114. car_price = 6.50
  115. action_figure_price = 7.75
  116.  
  117. num_dolls = int(input("How many dolls? "))
  118. num_cars = int(input("How many cars? "))
  119. num_action_figures = int(input("How many action figures? "))
  120.  
  121. total_doll_price = num_dolls * doll_price
  122. total_car_price = num_cars * car_price
  123. total_action_figure_price = num_action_figures * action_figure_price
  124.  
  125. total_price = total_doll_price + total_car_price + total_action_figure_price
  126.  
  127. print("Total price:", total_price)
  128.  
  129. # 8. Coffee Shop Order
  130. espresso_price = 2.50
  131. latte_price = 3.50
  132. cappuccino_price = 4.00
  133.  
  134. num_espresso = int(input("How many espressos? "))
  135. num_latte = int(input("How many lattes? "))
  136. num_cappuccino = int(input("How many cappuccinos? "))
  137.  
  138. total_espresso_price = num_espresso * espresso_price
  139. total_latte_price = num_latte * latte_price
  140. total_cappuccino_price = num_cappuccino * cappuccino_price
  141.  
  142. total_price = total_espresso_price + total_latte_price + total_cappuccino_price
  143.  
  144. print("Total price:", total_price)
  145.  
  146. # 9. Pizza Order
  147. small_price = 8.00
  148. medium_price = 12.00
  149. large_price = 15.00
  150.  
  151. num_small = int(input("How many small pizzas? "))
  152. num_medium = int(input("How many medium pizzas? "))
  153. num_large = int(input("How many large pizzas? "))
  154.  
  155. total_small_price = num_small * small_price
  156. total_medium_price = num_medium * medium_price
  157. total_large_price = num_large * large_price
  158.  
  159. total_price = total_small_price + total_medium_price + total_large_price
  160.  
  161. print("Total price:", total_price)
  162.  
  163. # 10. Concert Ticket Sales
  164. regular_ticket_price = 20.00
  165. vip_ticket_price = 50.00
  166. student_ticket_price = 15.00
  167.  
  168. num_regular = int(input("How many regular tickets? "))
  169. num_vip = int(input("How many VIP tickets? "))
  170. num_student = int(input("How many student tickets? "))
  171.  
  172. total_regular_price = num_regular * regular_ticket_price
  173. total_vip_price = num_vip * vip_ticket_price
  174. total_student_price = num_student * student_ticket_price
  175.  
  176. total_price = total_regular_price + total_vip_price + total_student_price
  177.  
  178. group_size = num_regular + num_vip + num_student
  179. if group_size >= 5:
  180.     total_price = total_price * 0.80
  181.  
  182. print("Total price:", total_price)
  183.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement