Fee Delivery Calulator

March 7, 2020

I was applying for different companies to get a job and a company named “JuriTech” accpeted me for an interview and I was so excited. well I saw the ads on their website and i thought this is the company I want to be employed in. long story short, i got there and there were tons of questions also there was an IQ test which I sucked at most of it and there was a question for engineers which they needed to write a code to calculate a fee for delivery(I was applying for DBA position.) but i challenge myself and wrote a piece of code and intrigue them and guess what? I got the job but because of COVID-19 my destiny is unknown.

Below is the code that get me the job besides my working experience.

Question: Question

Answer:

#### based on the below inqiers are rate per KM
min_fee = 2
mid_fee = 3
max_fee = 5
fragile_fee = 10
additional_fee = 5

###### check whether your item is fragile to add on the your deposit 
def bool_validator(isFragile):
    if isFragile == 'y':
        isFragile = True
    if isFragile == 'n':
        isFragile = False
    return isFragile

bool_valRes = bool_validator(input("is your Item Fragile? [y/N]: " ))


#### function to calculate the fee rate
def radius_meter(Shipment_weight,Delivery_radius): 
    if Delivery_radius <= 10 and bool_valRes != True:
        return(Shipment_weight * 2)
    if Delivery_radius <= 10 and bool_valRes == True:
        return(Shipment_weight * 2 +  fragile_fee)
    if 10 < Delivery_radius <= 15 and bool_valRes != True:
        return(Shipment_weight * 3 + additional_fee)
    if 10 < Delivery_radius <= 15 and bool_valRes == True:
        return(Shipment_weight * 3 + additional_fee + fragile_fee)
    if Delivery_radius > 15 and bool_valRes != True:
        return(Shipment_weight * 5 + additional_fee)
    if Delivery_radius > 15 and bool_valRes == True:
        return(Shipment_weight * 5 + additional_fee + fragile_fee)

Delivery_radius = int(input("Enter your Delivery radius: "))
Shipment_weight = int(input("Enter your Shipment weight: "))
Total_Fee = radius_meter(Shipment_weight,Delivery_radius)


### write your output to the file
myFile = open('res.csv','a')
myFile.write(f'{Delivery_radius},{Shipment_weight},{bool_valRes},{Total_Fee}' + '\n')
myFile.close()