Advertisement
Guest User

Computer Science IGCSE Pre-Release Task 2016

a guest
Feb 24th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. def Input():
  2.  
  3. try:
  4.  
  5. Weight = float(input("\n[*] Please Enter Weight: "))
  6. X = float(input("[*] Please Enter Size of X Dimention: "))
  7. Y = float(input("[*] Please Enter Size of Y Dimention: "))
  8. Z = float(input("[*] Please Enter Size of Z Dimention: "))
  9. return(Validation(Weight, X, Y, Z))
  10.  
  11. except ValueError:
  12. print("\n[-] Invalid Data Type Entered, Please Enter A Real Number.")
  13. print("[-] Retrying...")
  14. Input()
  15.  
  16. def Validation(Weight, XDimention, YDimention, ZDimention):
  17.  
  18. Dimentions = [XDimention, YDimention, ZDimention]
  19. Validations = []
  20.  
  21. Validations.append((Weight >= 1) and (Weight <= 10))
  22. for Dimention in Dimentions:
  23. Validations.append((Dimention <= 80) and (Dimention > 0))
  24. Validations.append((sum(Dimentions) <= 200) and (sum(Dimentions) > 0))
  25. return Validations, Weight
  26.  
  27. def Price(Weight):
  28. if Weight <= 5:
  29. return 10
  30. else:
  31. return (Weight-5) + 10
  32.  
  33.  
  34. def Outputs(Validations, Weight, Accepted, Rejected, Price):
  35. Messages = [
  36. "[-] Weight isn't Between 1 and 10 KG.",
  37. "[-] X Dimention is Greater than 80 CM or Less than 0 CM.",
  38. "[-] Y Dimention is Greater than 80 CM or Less than 0 CM.",
  39. "[-] Z Dimention is Greater than 80 CM or Less than 0 CM.",
  40. "[-] Sum of Dimentions is Greater than 200 CM."
  41. ]
  42.  
  43. for n in Validations:
  44. print("\n[-] Parcel %s Rejected:" % n[0])
  45. for x in range(len(n[1])):
  46. if n[1][x] == False:
  47. print(Messages[x])
  48.  
  49. print("\n[-] Total Parcels Rejected: %s" % Rejected)
  50. print("[+] Total Parcels Accepted: %s" % Accepted)
  51. print("[+] Total Weight of Accepted Parcels: %s" % Weight)
  52. print("[+] Total Price of Accepted Parcels: %s" % Price)
  53.  
  54.  
  55. if __name__ == "__main__":
  56.  
  57. Weights, AcceptedParcels, RejectedParcels, Prices = (0, 0, 0, 0)
  58. Validations = []
  59. NumParcels = 1
  60. for Parcel in range(1, NumParcels+1):
  61. Booleans, Weight = Input()
  62. if False in Booleans:
  63. Validations.append([Parcel, Booleans])
  64. RejectedParcels += 1
  65. else:
  66. Prices += Price(Weight)
  67. Weights += Weight
  68. AcceptedParcels +=1
  69.  
  70. Outputs(Validations, Weights, AcceptedParcels, RejectedParcels, Prices)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement