After a hard quarter in the office you decide to get some rest on a vacation. So you will book a flight for you and your girlfriend and try to leave all the mess behind you.

You will need a rental car in order for you to get around in your vacation. The manager of the car rental makes you some good offers.

Every day you rent the car costs $40. If you rent the car for 7 or more days, you get $50 off your total. Alternatively, if you rent the car for 3 or more days, you get $20 off your total.

Write a code that gives out the total amount for different days(d).

Difficulty: introductory

Starter code:

def rental_car_cost(d):
	

Solutions:
def rental_car_cost(d):
    result = d * 40
    if d >= 7:
        result -= 50
    elif d >= 3:
        result -= 20
    return result

def rental_car_cost(d):
  return d * 40 - (d > 2) * 20 - (d > 6) * 30

def rental_car_cost(d):
    discount = 0
    if d >= 7:
        discount = 50
    elif d >= 3:
        discount = 20
    return d * 40 - discount

def rental_car_cost(d):
    if d >= 7: return d * 40 - 50
    elif d >= 3: return d * 40 - 20
    return d * 40

def rental_car_cost(d):
    return 40 * d - ((50, 20)[d < 7], 0)[d < 3]

def rental_car_cost(d):
    return d * 40 - 20 * (d >= 3) - 30 * (d >= 7)

def rental_car_cost(d):
    total = d*40
    if d >= 7:
        total -= 50
    else:
        if d >= 3:
            total -= 20
    
    return total

def rental_car_cost(d):
    total_cost = d * 40
    if d >= 7:
        total_cost -= 50
    elif d >= 3:
        total_cost -= 20
    return total_cost

def rental_car_cost(d):
    discount = 50 if d > 6 else 20 if d > 2 else 0 
    return d * 40 - discount

def rental_car_cost(d):
    return d*40 - 50 if d >= 7 else d*40 -20 if d >= 3 else d*40  

def rental_car_cost(d):
    return 40*d - 20*(2<d<7) - 50*(d>6) 

def rental_car_cost(d):
    return 40*d - (50 if d >= 7 else 20 if d >= 3 else 0)

def rental_car_cost(d):
    x = d * 40
    if d >= 7: return x - 50
    return x - 20 if d >= 3 else x

def rental_car_cost(d):
    # your code
    total = d * 40
    if d >= 3 and d < 7:
        total -= 20
    if d >= 7:
        total -= 50
    return total

def rental_car_cost(d):
    total = 40*d
    return total if d < 3 else total-20 if d < 7 else total-50

def rental_car_cost(d):
    r = 50 if d >= 7 else 20 if d >= 3 else 0
    return d * 40 - r

def rental_car_cost(d):
    # your code
    if d >= 7:
        return d * 40 - 50
    elif d >= 3:
        return d * 40 - 20
    else:
        return d * 40

def rental_car_cost(d):
    return d * 40 - (50 if d > 6 else 20 if d > 2 else 0) 

rental_car_cost = lambda d: d * 40 - (50 if d > 6 else 20 if d > 2 else 0)

def rental_car_cost(d):
    x = 40
    if d < 3: 
        return d * x
    elif d < 7: 
        return (x * d) - 20
    else: 
        return (x * d) - 50 

def rental_car_cost(d):
    total = 40 * d
    if d > 6:
        total = total - 50
    if d > 2 and d < 7:
        total = total - 20
    return total

rental_car_cost = lambda d: 40*d-[0,20,50][(d>=3)+(d>=7)]

def rental_car_cost(d):
    return 40*d-20*(7>d>=3)-50*(d>=7)

def rental_car_cost(d):
    return d * 40 - (d >= 3) * 20 - (d >= 7) * 30

rental_car_cost=lambda d: 40*d - (50 if d>6 else 20 if d>2 else 0)

def rental_car_cost(d):
    return d * 40 - (d > 6) * 50 - (7 > d > 2) * 20

def rental_car_cost(d):
    cost = 40
    if int(d)<3:
        cost = cost * d
    elif int(d)>=3 and int(d)<7:
        cost = cost * d 
        cost = cost - 20
    elif int(d)>=7:
        cost = cost * d
        cost = cost -50
    return cost

def rental_car_cost(d):
    return d * 40 - (d >= 7) * 50 - (3 <= d < 7) * 20

def rental_car_cost(d):
    return d * 40 - (20 if d >= 3 else 0) - (30 if d >= 7 else 0)

def rental_car_cost(d):
    # your code
    return 40*d-20*(d<7 and d>=3)-50*(d>=7)

def rental_car_cost(d):
    return (d * 40 - 50)*(d>=7) or (d * 40 - 20)*(d>=3) or d * 40

rental_car_cost=lambda d: d*40 if d < 3 else d*40-20 if d < 7 else d*40-50

def rental_car_cost(d):
    return 40 * d - 20 * (d >= 3) - 30 * (d >= 7)

def rental_car_cost(days: int) -> int:
    """
     Get the total amount for different days(d) according to the rules:
     - every day you rent the car costs $40
     - 7 or more days, you get $50 off your total
     - 3 or more days, you get $20 off your total
    """
    return days * 40 - {days >= 3: 20, days >= 7: 50}.get(True, 0)

def rental_car_cost(d):
    return d * 40 if d < 3 else d * 40 - 20 if 2 < d < 7 else d * 40 - 50

def rental_car_cost(d):
    if d < 3:
        x = 0
    elif d < 7:
        x = 20
    else:
        x = 50
    return d*40-x

def rental_car_cost(d):
    return 40 * d - 50 if d > 6 else 40 * d - 20 if 3 <= d <= 6 else 40 * d

def rental_car_cost(d):
    return d * 40 if d <= 2 else d * 40 -20 if d <= 6 else d * 40 - 50

def rental_car_cost(d):
    price = d * 40
    if d >= 7:
        price -= 50
    elif d >= 3 and d < 7:
        price -= 20
    return price

def rental_car_cost(d):
    # your code
    if(d==1):
        return 40
    elif(d>=7):
        a=d*40
        return a-50
    elif(3<=d<7):
        a=d*40
        return a-20
    else:
        return d*40

def rental_car_cost(d):
    
    if d >= 1 and d < 3:
        return 40 * d
    
    if d >= 3 and d < 7:
        return 40 * d - 20
    
    else:
        return 40 * d - 50
    


def rental_car_cost(days):
    if days >= 7:
        discount = 50
    elif days >= 3:
        discount = 20
    else:
        discount = 0
    return days * 40 - discount

def rental_car_cost(d):
    rent_cost = d*40
    if d >= 7:
        rent_cost-=50
    elif d >= 3:
        rent_cost-=20
    return rent_cost     



def rental_car_cost(d):
    count =40
    if d >= 1 and d<3:
        count = count*d
    elif d>=3 and d<7:
        count = count*d - 20
    elif d >=7:
        count = count*d - 50
    return count

def rental_car_cost(d):
    
    if d >= 7:
        tot = 40 * d - 50
    elif d >= 3:
        tot = 40 * d - 20
    else:
        tot = 40 * d
    return tot

def rental_car_cost(d):

    sum = 40*d
    
    if d >= 7:
        sum = sum - 50
        
    elif d >= 3:
        sum = sum - 20
        
    return sum

def rental_car_cost(d):
    suma = d * 40
    if d < 3:
        return suma
    elif d >= 3 and d < 7:
        return suma - 20
    elif d >= 7:
        return suma - 50

def rental_car_cost(d):
    _1_day = d*40
    if d >= 7:
        _1_day -=50
    elif d >= 3:
        _1_day -=20
    return _1_day

def rental_car_cost(d):
    result = 40 * d
    if 3 <= d < 7:
        result -= 20
    elif d >= 7:
        result -= 50
    return result


def rental_car_cost(d):
    print(d)
    if d == 1 or d == 2:
         return 40 * d
    elif 3<= d < 7:
         return d * 40- 20 
    else:
        return d * 40 - 50

def rental_car_cost(d):
    return (d * 40) - (0 if d < 3 or d > 6 else 20) - (0 if d < 7 else 50)

def rental_car_cost(d):
    r = d * 40
    if d>= 7:
        r -= 50
    elif d >=3:
        r -= 20
    return r

def rental_car_cost(d):
    if 0 < d < 3: return 40*d
    if 2 < d < 7: return 40*d - 20
    if d > 6: return 40*d - 50
    
    
    
# Every day you rent the car costs $40.
# If you rent the car for 7 or more days,
# you get $50 off your total. 
# Alternatively, if you rent the car for 3 or more days,
# you get $20 off your total.

# Write a code that gives out the total amount for different days(d).



def rental_car_cost(days):
    return days * 40 - (20 * (days >= 3 and days < 7)) - (50 * (days >= 7))

def rental_car_cost(d):
    amount = 40 * d
    if d >= 7:
        amount -= 50
    elif d >= 3:
        amount -= 20
    return amount

def rental_car_cost(d):
    print(d)
    total = 40*d
    if d >= 7:
        return total - 50
    elif d < 3:
        return total
    return total - 20


def rental_car_cost(d):
    return 40 * d - [0, 20, 50][(d > 2) + (d > 6)]

def rental_car_cost(d):
    if 0 < d < 3:
        return d * 40
    elif 2 < d < 7:
        return d * 40 - 20
    else:
        return 40 * d -50

def rental_car_cost(d):
    daily_cost = 40 * d
    if d >= 7:
        daily_cost -= 50
    elif d >= 3:
        daily_cost -= 20
    else:
        daily_cost -= 0
    return daily_cost

def rental_car_cost(d):
    price = d * 40
    
    return price if d < 3 else price - 50 if d >= 7 else price - 20

def rental_car_cost(d):
    rent = d*40
    if d>=7:
        rent-=50
    elif d>=3 and d<7:
        rent-=20
    return rent

def rental_car_cost(d):
    days = d * 40
    if d >= 7:
        days -= 50
    if d >= 3 and d < 7:
        days -= 20
    return days

def rental_car_cost(d):
    print(d)
    if d<3:
        return d*40
    if  3<=d<7:
        return d*40-20
    return d*40-50

def rental_car_cost(d):
    base = d * 40
    if d >= 7:
        return base - 50
    elif d >= 3:
        return base - 20
    else:
        return base



def rental_car_cost(d):
    if 3<=d<7: return 40*d-20
    if d >= 7: return 40*d-50
    else:
        return 40*d

def rental_car_cost(d):
    if d < 3:
        return 40 * d
    elif d >= 7:
        return 40 * d - 50
    else:
        return 40 * d - 20

def rental_car_cost(d):
    total = d * 40
    if 3 <= d < 7: total -= 20
    if 7 <= d: total -= 50
    return total

def rental_car_cost(d):
    cpd = 40
    if d < 3:
        return d * cpd
    elif d < 7:
        return (d * cpd) - 20
    else:
        return (d * cpd) - 50

def rental_car_cost(d):
    return (d*40)-50 if d >= 7 else (d*40)-20 if d < 7 and d >= 3 else d*40

def rental_car_cost(d):
    print(d,"days",d*40)
    return (d*40)-50 if d >= 7 else (d*40)-20 if d < 7 and d >= 3 else (d*40)

def rental_car_cost(d):
    x=40*d
    if d>=3:
        if d>=7:return x-50
        return x-20
    return x


def rental_car_cost(d):
    if d < 3:
        return d * 40
    elif 7 > d >= 3:
        return (d * 40) - 20
    elif d >= 7:
        return (d*40) - 50

def rental_car_cost(d):
    t = d * 40
    if d >= 3 and d < 7:
        t = t - 20
    if d >= 7:
        t = t - 50
    return t

def rental_car_cost(d):
    if d <7:
        if d >= 3:
            return d*40-20
        return d*40    
    return d*40-50

def rental_car_cost(d):
    cost = 40 * d
    print(d)
    if d >= 3 and not 7 <= d:
        cost -= 20
    if d >= 7:
        cost  -= 50
        
    return cost    
    


def rental_car_cost(d):
    p = d*40
    if d<3:
        return p
    elif d <7:
        return p-20
    else:
        return p-50

def rental_car_cost(d):
    return 40 * d - (d > 6) * 30 - (d > 2) * 20

def rental_car_cost(d):
    if d>=7:
        return (d*40)-50
    if 6 <= d or d >=3:
        return (d*40)-20
    else:
        return (d*40)

def rental_car_cost(d):
    prod = d * 40
    return prod - 30 * (d >= 7) - 20 * (d >= 3)

def rental_car_cost(d):
    if 7>d>=3:
        return 40*d-20
    elif d>=7:
        return 40*d-50
    else:
        return 40*d
        


def rental_car_cost(d):
    #TRUMP SUCKS
    return d*40 if d<3 else (d*40)-20 if 3<=d<7 else (d*40)-50

def rental_car_cost(d):
    car = 40
    if d < 3:
        return car * d
    if 3 <= d < 7:
        return car * d - 20
    if 7 <= d:
        return car * d - 50

def rental_car_cost(d):
    print(d)
    if d <= 2:
        return 40 * d
    if 2 < d < 7:
        return 40 * d - 20
    if d >= 7:
        return d * 40 -50# your code

def rental_car_cost(d):
    if d >= 3 and d<7:
        total = d * 40 - 20
        return total
    elif d >= 7:
        total = d * 40 - 50
        return total
    else:
        total = d * 40
        return d * 40
    # your code


rental_car_cost = lambda d: d*40 - (d > 6 and 50 or d > 2 and 20 or 0)

def rental_car_cost(d):
    if d < 3:
        return 40 * d
    else:
        return 40 * d - 20 if d < 7 else 40 * d - 50


def rental_car_cost(d):
    daily = d * 40
    if d < 7 and d > 2:
        return daily - 20
    elif d > 6:
        return daily - 50
    else:
        return daily


def rental_car_cost(d):
    if d < 3:
        a = d * 40
        return a
    elif d >= 3 and d < 7:
        b = d * 40 - 20
        return b
    elif d >= 7:
        c = d * 40 - 50
        return c

def rental_car_cost(d):
    return (40 * d) - 50 * (d > 6) if d > 6 else (40 * d) - 20 * (d > 2)

def rental_car_cost(d):
    if d > 2 and d <7:
        return(40*d-20)
    if d >6:
        return(40*d-50)
    else:
        return 40*d

def rental_car_cost(d):
    off = 50 if d > 6 else 20 if d > 2 else 0
    return 40 * d - off

def rental_car_cost(d):
    dayCost = 40;
        
    if d >= 3 and d < 7:
        return (dayCost * d) - 20;
    elif d >= 7:
        return (dayCost * d) - 50;
    return d * dayCost;

def rental_car_cost(d):
    if d >= 7:
        return (d*40) - 50
    elif 3 <= d <= 6:
        return (d*40) - 20
    return d*40

def rental_car_cost(d):
    daily_cost = (d * 40)
    if d >= 3 and d < 7:
        #three_day_reduced_cost = daily_cost - 20
        return daily_cost - 20
    elif d >= 7:
       # seven_day_reduced_cost = daily_cost - 50
        return daily_cost - 50 
    else:
        return daily_cost

def rental_car_cost(d):
    fuckthis = 40*d
    if 3 <= d < 7:
        return fuckthis - 20
    elif d >= 7:
        return fuckthis - 50
    else:
        return fuckthis

def rental_car_cost(d):
    if d < 3:
        return d * 40
    elif d < 7 and d >= 3:
        return (d * 40) - 20
    elif d >= 7:
        return (d * 40) - 50

def rental_car_cost(d: int) -> int:
    """Gives out the total amount for different count days of rent car"""
    cost = d * 40
    if d >= 7:
        return cost - 50
    elif d >= 3:
        return cost - 20
    else:
        return cost

def discount(d):
    if d >= 7:
        return 50
    elif d >= 3:
        return 20
    return 0


def rental_car_cost(d):
    return d*40 - discount(d)


def rental_car_cost(d):
    if d<3:
        return 40*d
    elif d in range(3,7):
        return 40*d-20
    else:
        return 40*d-50

def rental_car_cost(d):
    x = d * 40
    if d >= 7:
        x = x - 50
    elif d in range(3,7):
        x = x - 20
    return x