Advertisement
veronikaaa86

Nested Conditional Statements - Python

May 22nd, 2022
157
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.90 KB | None | 1 0
  1. 01. Cinema
  2.  
  3. type_tickets = input()
  4. rows = int(input())
  5. cols = int(input())
  6.  
  7. all_seats = rows * cols
  8.  
  9. price = 0
  10. if type_tickets == "Premiere":
  11. price = 12
  12. elif type_tickets == "Normal":
  13. price = 7.5
  14. elif type_tickets == "Discount":
  15. price = 5
  16.  
  17. sum = price * all_seats
  18.  
  19. print(f"{sum:.2f} leva")
  20.  
  21. ================================================
  22. 02. Summer Outfit
  23.  
  24. degrees = int(input())
  25. time_of_day = input()
  26.  
  27. outfit = ""
  28. shoes = ""
  29. if time_of_day == "Morning":
  30. if degrees >= 10 and degrees <= 18:
  31. outfit = "Sweatshirt"
  32. shoes = "Sneakers"
  33. elif degrees > 18 and degrees <= 24:
  34. outfit = "Shirt"
  35. shoes = "Moccasins"
  36. elif degrees > 24:
  37. outfit = "T-Shirt"
  38. shoes = "Sandals"
  39. elif time_of_day == "Afternoon":
  40. if degrees >= 10 and degrees <= 18:
  41. outfit = "Shirt"
  42. shoes = "Moccasins"
  43. elif degrees > 18 and degrees <= 24:
  44. outfit = "T-Shirt"
  45. shoes = "Sandals"
  46. elif degrees > 24:
  47. outfit = "Swim Suit"
  48. shoes = "Barefoot"
  49. elif time_of_day == "Evening":
  50. if degrees >= 10 and degrees <= 18:
  51. outfit = "Shirt"
  52. shoes = "Moccasins"
  53. elif degrees > 18 and degrees <= 24:
  54. outfit = "Shirt"
  55. shoes = "Moccasins"
  56. elif degrees > 24:
  57. outfit = "Shirt"
  58. shoes = "Moccasins"
  59.  
  60. print(f"It's {degrees} degrees, get your {outfit} and {shoes}.")
  61. ================================================================
  62. 03. New House
  63.  
  64. type_flower = input()
  65. count_flowers = int(input())
  66. budget = int(input())
  67.  
  68. sum = 0
  69. if type_flower == "Roses":
  70. sum = 5 * count_flowers
  71. if count_flowers > 80:
  72. sum = sum * 0.90
  73. elif type_flower == "Dahlias":
  74. sum = 3.80 * count_flowers
  75. if count_flowers > 90:
  76. sum = sum * 0.85
  77. elif type_flower == "Tulips":
  78. sum = 2.80 * count_flowers
  79. if count_flowers > 80:
  80. sum = sum * 0.85
  81. elif type_flower == "Narcissus":
  82. sum = 3 * count_flowers
  83. if count_flowers < 120:
  84. sum = sum * 1.15
  85. elif type_flower == "Gladiolus":
  86. sum = 2.5 * count_flowers
  87. if count_flowers < 80:
  88. sum = sum * 1.20
  89.  
  90. diff = abs(budget - sum)
  91. if budget >= sum:
  92. print(f"Hey, you have a great garden with {count_flowers} {type_flower} and {diff:.2f} leva left.")
  93. else:
  94. print(f"Not enough money, you need {diff:.2f} leva more.")
  95.  
  96. ================================================================
  97. 04. Fishing Boat
  98.  
  99. budget = int(input())
  100. season = input()
  101. count_people = int(input())
  102.  
  103. price_boat = 0
  104. if season == "Spring":
  105. price_boat = 3000
  106. elif season == "Summer" or season == "Autumn":
  107. price_boat = 4200
  108. elif season == "Winter":
  109. price_boat = 2600
  110.  
  111. if count_people <= 6:
  112. price_boat = price_boat * 0.90
  113. elif count_people <= 11:
  114. price_boat = price_boat * 0.85
  115. elif count_people > 11:
  116. price_boat = price_boat * 0.75
  117.  
  118.  
  119. if count_people % 2 == 0:
  120. if season != "Autumn":
  121. price_boat = price_boat * 0.95
  122.  
  123. diff = abs(budget - price_boat)
  124. if budget >= price_boat:
  125. print(f"Yes! You have {diff:.2f} leva left.")
  126. else:
  127. print(f"Not enough money! You need {diff:.2f} leva.")
  128. ================================================================
  129. 05. Journey
  130.  
  131. budget = float(input())
  132. season = input()
  133.  
  134. destination = ""
  135. place = ""
  136. expenses = 0
  137. if budget <= 100:
  138. destination = "Bulgaria"
  139. if season == "summer":
  140. place = "Camp"
  141. expenses = budget * 0.3
  142. elif season == "winter":
  143. place = "Hotel"
  144. expenses = budget * 0.7
  145. elif budget <= 1000:
  146. destination = "Balkans"
  147. if season == "summer":
  148. place = "Camp"
  149. expenses = budget * 0.4
  150. elif season == "winter":
  151. place = "Hotel"
  152. expenses = budget * 0.8
  153. elif budget > 1000:
  154. destination = "Europe"
  155. place = "Hotel"
  156. expenses = budget * 0.9
  157.  
  158. print(f"Somewhere in {destination}")
  159. print(f"{place} - {expenses:.2f}")
  160. ================================================================
  161. 06. Operations Between Numbers
  162.  
  163. n1 = int(input())
  164. n2 = int(input())
  165. operator = input()
  166. result = 0
  167.  
  168. if operator == "+":
  169. result = n1+n2
  170. if result % 2 == 0:
  171. print(f'{n1} {operator} {n2} = {result:.0f} - even')
  172. else:
  173. print(f'{n1} {operator} {n2} = {result:.0f} - odd')
  174. elif operator == "-":
  175. result = n1-n2
  176. if result % 2 == 0:
  177. print(f'{n1} {operator} {n2} = {result:.0f} - even')
  178. else:
  179. print(f'{n1} {operator} {n2} = {result:.0f} - odd')
  180. if operator == "*":
  181. result = n1*n2
  182. if result % 2 == 0:
  183. print(f'{n1} {operator} {n2} = {result:.0f} - even')
  184. else:
  185. print(f'{n1} {operator} {n2} = {result:.0f} - odd')
  186. elif operator == "/" and n2 != 0:
  187. result = n1/n2
  188. print(f'{n1} {operator} {n2} = {result:.2f}')
  189. elif operator == "%" and n2 != 0:
  190. result = n1%n2
  191. print(f'{n1} {operator} {n2} = {result:.0f}')
  192. elif n2 == 0 and operator == '/' or n2 == 0 and operator == '%':
  193. print(f"Cannot divide {n1} by zero")
  194. ================================================================
  195. 07. Hotel Room
  196.  
  197. month = input()
  198. nightsCount = int(input())
  199.  
  200. apartmentPrice = 0
  201. studioPrice = 0
  202.  
  203. if month == "May" or month == "October":
  204. apartmentPrice = nightsCount * 65
  205. studioPrice = nightsCount * 50
  206. elif month == "June" or month == "September":
  207. apartmentPrice = nightsCount * 68.70
  208. studioPrice = nightsCount * 75.20
  209. elif month == "July" or month == "August":
  210. apartmentPrice = nightsCount * 77
  211. studioPrice = nightsCount * 76
  212.  
  213. if nightsCount > 14 and (month == "May" or month == "October"):
  214. studioPrice *= 0.70
  215. elif nightsCount > 7 and (month == "May" or month == "October"):
  216. studioPrice *= 0.95
  217. elif nightsCount > 14 and (month == "June" or month == "September"):
  218. studioPrice *= 0.80
  219.  
  220. if nightsCount > 14:
  221. apartmentPrice *= 0.90
  222.  
  223. print(f"Apartment: {apartmentPrice:.2f} lv.")
  224. print(f"Studio: {studioPrice:.2f} lv.")
  225. ================================================================
  226. 08. On Time for the Exam
  227.  
  228. exam_hour = int(input())
  229. exam_min = int(input())
  230. hour_of_arrival = int(input())
  231. min_of_arrival = int(input())
  232.  
  233. # 10:00 - 10:00
  234. # 600 - 600 = 0
  235. exam_time_min = (exam_hour * 60) + exam_min
  236. arrival_time_min = (hour_of_arrival * 60) + min_of_arrival
  237.  
  238. diff_min = abs(exam_time_min - arrival_time_min)
  239.  
  240. if exam_time_min < arrival_time_min:
  241. print("Late")
  242. if diff_min >= 60:
  243. hour = diff_min // 60
  244. minutes = diff_min % 60
  245. if minutes < 10:
  246. print(f"{hour}:0{minutes} hours after the start")
  247. else:
  248. print(f"{hour}:{minutes} hours after the start")
  249. else:
  250. print(f"{diff_min} minutes after the start")
  251. elif exam_time_min == arrival_time_min or diff_min <= 30:
  252. print("On time")
  253. if diff_min >= 1 and diff_min <= 30:
  254. print(f"{diff_min} minutes before the start")
  255. else:
  256. print("Early")
  257. if diff_min >= 60:
  258. hour = diff_min // 60
  259. minutes = diff_min % 60
  260. if minutes < 10:
  261. print(f"{hour}:0{minutes} hours before the start")
  262. else:
  263. print(f"{hour}:{minutes} hours before the start")
  264. else:
  265. print(f"{diff_min} minutes before the start")
  266. ================================================================
  267. 09. Ski Trip
  268.  
  269. ays = int(input())
  270. room = input()
  271. assessment = input()
  272.  
  273. price = 0
  274.  
  275. if room == 'room for one person':
  276. price = (days - 1) * 18
  277. elif room == 'apartment':
  278. if days < 10:
  279. price = (days - 1) * 25 * 0.7
  280. elif 10 <= days <= 15:
  281. price = (days - 1) * 25 * 0.65
  282. else:
  283. price = (days - 1) * 25 * 0.5
  284. else:
  285. if days < 10:
  286. price = (days - 1) * 35 * 0.9
  287. elif 10 <= days <= 15:
  288. price = (days - 1) * 35 * 0.85
  289. else:
  290. price = (days - 1) * 35 * 0.8
  291.  
  292. if assessment == 'positive':
  293. price *= 1.25
  294. else:
  295. price *= 0.9
  296.  
  297. print(f'{price:.2f}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement