Advertisement
Guest User

<3

a guest
Mar 31st, 2020
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.86 KB | None | 0 0
  1. import time
  2. input_leader = ""
  3. total_donation = 0
  4.  
  5. #Login Dictionary
  6. Teams = {
  7. "Leo Nardo":"LN1435",
  8. "Michael Angelo":"MA3756",
  9. "Steve Billy":"SB1337",
  10. "Raf Phael":"RP7611",
  11. "Yoshi Hamato":"YH4337",
  12. "u":"u"}
  13.  
  14.  
  15. def print_receipt(receipt):
  16. receipt_array = receipt.split("-")
  17. #print(receipt_array)
  18.  
  19. donor_number = 1
  20. array_index = 0
  21. print("\n-----------------------------------")
  22. print("--- Team Leader A: " + input_leader + " ---")
  23. print("-----------------------------------\n")
  24. print("How much is the Total Donation? " +str(total_donation))
  25. print("How many customers are there? "+str((len(receipt_array)-1))+"\n\n")
  26. print("--- Printing Total Donation ---")
  27.  
  28. while array_index < (len(receipt_array)-1):
  29. print("Donor "+str(donor_number)+" paid £"+str(receipt_array[array_index])+".0")
  30. array_index +=1
  31. donor_number +=1
  32. print("\nYour Team Leader was: " + input_leader)
  33. print("\nThank you for your Donation!")
  34.  
  35. def get_donor_amount(total_donors):
  36.  
  37. print("wow we made it")
  38. global total_donation
  39.  
  40. total_donor_amount = 0
  41. total_donors_copy = total_donors
  42. receipt = ""
  43.  
  44. while total_donor_amount < total_donation:
  45. donor_number = 1
  46. total_donors = total_donors_copy
  47.  
  48. while total_donors > 0:
  49. try:
  50. donor_amount = int(input("donor "+str(donor_number)+" : "))
  51. if donor_amount != "" and donor_amount >= 0:
  52. donor_number = donor_number + 1
  53. total_donors = total_donors - 1
  54. total_donor_amount = total_donor_amount + donor_amount
  55. receipt = receipt + str(donor_amount) + "-"
  56. else:
  57. print("Enter a valid donation.\n")
  58. except ValueError:
  59. print("Enter a donation.\n")
  60.  
  61. def More_Donation(total_donor_amount):
  62. if total_donor_amount > total_donation:
  63. print("you have donated more than needed.")
  64. ask = input("would you like to donate all? y/n")
  65. if ask == 'n':
  66. print('re enter all donor amounts please\n ')
  67. total_donor_amount=0
  68. elif ask == "":
  69. print("Enter a valid option.\n")
  70. More_Donation(total_donor_amount)
  71. elif total_donor_amount == total_donation:
  72. print("Wow sir exact donation\n")
  73.  
  74. else:
  75. print("paise khape ho\n")
  76. More_Donation(total_donor_amount)
  77. print_receipt(receipt);
  78. exit()
  79.  
  80. def get_num_donors():
  81.  
  82. while True:
  83. try:
  84. total_donors = int(input("Number of Donors? "))
  85. except ValueError:
  86. print("Enter a valid number.\n")
  87. else:
  88. if total_donors <=0:
  89. print("Enter a valid number.\n")
  90. elif total_donors == "":
  91. print("Enter a valid number.\n")
  92. else:
  93. get_donor_amount(total_donors)
  94.  
  95. def get_total_donation():
  96. print("\n-----------------------------------")
  97. print("--- Team Leader A: " + input_leader + " ---")
  98. print("-----------------------------------\n")
  99.  
  100. global total_donation
  101.  
  102. while True:
  103. try:
  104. total_donation = int(input("How much is the total donation?: £"))
  105. except ValueError:
  106. print("Enter a valid donation.\n")
  107. else:
  108. if total_donation <= 0:
  109. print("Enter a valid donation.\n")
  110. elif total_donation == "":
  111. print("Please enter a donation.\n")
  112. get_total_donation()
  113. else:
  114. get_num_donors()
  115.  
  116.  
  117. #Team number validation
  118. def Team_number():
  119. team_number=input("Enter team number: ")
  120.  
  121. if team_number == Teams[input_leader]:
  122. get_total_donation()
  123. elif team_number == "":
  124. print("Please enter a team number.\n")
  125. Team_number()
  126. else:
  127. print("Invalid team number\nPlease try again\n")
  128. Team_number()
  129.  
  130. #Leader name validation
  131. def Team_Leader():
  132.  
  133. #asking for input
  134. global input_leader
  135. input_leader=input("Enter name: ")
  136.  
  137. #checking in dict
  138. for leader in Teams:
  139. if input_leader == leader:
  140. Team_number()
  141. if input_leader == "":
  142. print("Please enter a team leader.\n")
  143. Team_Leader()
  144.  
  145. print("Invalid login.\nPlease try again\n")
  146. Team_Leader()
  147.  
  148. Team_Leader()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement