Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def Input():
- try:
- Weight = float(input("\n[*] Please Enter Weight: "))
- X = float(input("[*] Please Enter Size of X Dimention: "))
- Y = float(input("[*] Please Enter Size of Y Dimention: "))
- Z = float(input("[*] Please Enter Size of Z Dimention: "))
- return(Validation(Weight, X, Y, Z))
- except ValueError:
- print("\n[-] Invalid Data Type Entered, Please Enter A Real Number.")
- print("[-] Retrying...")
- Input()
- def Validation(Weight, XDimention, YDimention, ZDimention):
- Dimentions = [XDimention, YDimention, ZDimention]
- Validations = []
- Validations.append((Weight >= 1) and (Weight <= 10))
- for Dimention in Dimentions:
- Validations.append((Dimention <= 80) and (Dimention > 0))
- Validations.append((sum(Dimentions) <= 200) and (sum(Dimentions) > 0))
- return Validations, Weight
- def Price(Weight):
- if Weight <= 5:
- return 10
- else:
- return (Weight-5) + 10
- def Outputs(Validations, Weight, Accepted, Rejected, Price):
- Messages = [
- "[-] Weight isn't Between 1 and 10 KG.",
- "[-] X Dimention is Greater than 80 CM or Less than 0 CM.",
- "[-] Y Dimention is Greater than 80 CM or Less than 0 CM.",
- "[-] Z Dimention is Greater than 80 CM or Less than 0 CM.",
- "[-] Sum of Dimentions is Greater than 200 CM."
- ]
- for n in Validations:
- print("\n[-] Parcel %s Rejected:" % n[0])
- for x in range(len(n[1])):
- if n[1][x] == False:
- print(Messages[x])
- print("\n[-] Total Parcels Rejected: %s" % Rejected)
- print("[+] Total Parcels Accepted: %s" % Accepted)
- print("[+] Total Weight of Accepted Parcels: %s" % Weight)
- print("[+] Total Price of Accepted Parcels: %s" % Price)
- if __name__ == "__main__":
- Weights, AcceptedParcels, RejectedParcels, Prices = (0, 0, 0, 0)
- Validations = []
- NumParcels = 1
- for Parcel in range(1, NumParcels+1):
- Booleans, Weight = Input()
- if False in Booleans:
- Validations.append([Parcel, Booleans])
- RejectedParcels += 1
- else:
- Prices += Price(Weight)
- Weights += Weight
- AcceptedParcels +=1
- Outputs(Validations, Weights, AcceptedParcels, RejectedParcels, Prices)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement