Advertisement
SimeonTs

SUPyF2 P.-Mid-Exam/2 November 2019/1. - Biscuits Factory

Nov 5th, 2019
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.90 KB | None | 0 0
  1. """
  2. Programming Fundamentals Mid Exam - 2 November 2019 Group 1
  3. Check your code: https://judge.softuni.bg/Contests/1859/Programming-Fundamentals-Mid-Exam-2-November-2019-Group-1
  4.  
  5. SUPyF2 P.-Mid-Exam/2 November 2019/1. - Biscuits Factory
  6.  
  7. Problem:
  8. Create a program that calculates how many biscuits your factory can make for a month (30 days) and the percentage
  9. of production compared to another factory production.
  10. First, you will receive the biscuits produced per day (per worker). After that, you will receive the count of the
  11. workers in your factory. Last, you will receive the number of biscuits that the competing factory produces for 30 days.
  12. You need to calculate the production of your factory for 30 days.
  13. Then you have to calculate how much more or fewer biscuits you produce compared to the other factory (in percentage).
  14. There will be no case where the factories will produce the same amount of biscuits.
  15. Every third day the workers produce only 75% of the usual production.
  16. Keep in mind that there can be only a whole biscuit after making calculations for each day –
  17. format them to the lower number.
  18. In the end, print the amount of biscuits produced for 30 days in the following format:
  19. "You have produced {countBiscuits} biscuits for the past month."
  20. Then print the percentage of the difference, formatted to the 2nd decimal place, in the following format:
  21. If your production is bigger than the other factory:
  22. "You produce {percentage} percent more biscuits."
  23. If not:
  24. "You produce {percentage} percent less biscuits."
  25.  
  26. Input:
  27. • On the first line you will receive the amount of biscuits a worker produce a day –
  28.    an integer number in the range [1…200]
  29. • On the second line you will receive the count of the workers in your factory –
  30.    an integer number in the range [1…1000]
  31. • On the third line you will receive the amount of biscuits that the competing factory produces for 30 days –
  32.    an integer number in the range[1…2000]
  33. NOTE: The input will always be in the right format.
  34.  
  35. Output:
  36. • In the end print the amount of biscuits produced for 30 days and the percentage of the difference formatted
  37.    to the 2nd decimal place in the format described above.
  38.  
  39. Constraints:
  40. • Percentage can be over 100%.
  41. • There will be no case where the factories will produce the same amount of biscuits.
  42.  
  43. Examples:
  44.  
  45. Input:      Output:
  46. 78          You have produced 17160 biscuits for the past month.
  47. 8           You produce 7.25 percent more biscuits.
  48. 16000
  49.  
  50. Comments:
  51. -78 biscuits a day
  52. -8 employees
  53. -17160 biscuit production your factory
  54.    (keep in mind every third day the workers produce only 75% of the usual production)
  55. -17160 – 16000 = 1160 - difference between your and the other factory production
  56. -1160/16000 * 100 = 7.25% more biscuits.
  57.  
  58. Input:      Output:
  59. 65          You have produced 21450 biscuits for the past month.
  60. 12          You produce 17.50 percent less biscuits.
  61. 26000
  62.  
  63. Comments:
  64. -65 biscuits a day
  65. -12 employees
  66. -21450 biscuit production your factory
  67. -26000 – 21450 = 4550 - difference between your and the other factory production
  68. -4550/26000 * 100 = 17.50% more biscuits.
  69. """
  70. import math
  71. biscuits_per_day = int(input()) * int(input())
  72. other_factory_production = int(input())
  73. our_factory_production = 0
  74.  
  75.  
  76. def percentage(part, whole):
  77.     return f'{abs((100 * float(part)/float(whole))- 100):.2f}'
  78.  
  79.  
  80. for day in range(1, 31):
  81.     if day % 3 == 0:
  82.         our_factory_production += math.floor(biscuits_per_day * 0.75)
  83.     else:
  84.         our_factory_production += biscuits_per_day
  85.  
  86. print(f"You have produced {our_factory_production} biscuits for the past month.")
  87. if our_factory_production > other_factory_production:
  88.     print(f"You produce {percentage(our_factory_production, other_factory_production)} percent more biscuits.")
  89. else:
  90.     print(f"You produce {percentage(our_factory_production, other_factory_production)} percent less biscuits.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement