Complete the function, which calculates how much you need to tip based on the total amount of the bill and the service. 

You need to consider the following ratings:

- Terrible: tip 0%
- Poor: tip 5%
- Good: tip 10%
- Great: tip 15%
- Excellent: tip 20%

The rating is **case insensitive** (so "great" = "GREAT"). If an unrecognised rating is received, then you need to return:

* `"Rating not recognised"` in Javascript, Python and Ruby...
* ...or `null` in Java
* ...or `-1` in C#

Because you're a nice person, you **always round up** the tip, regardless of the service.

Difficulty: introductory

Starter code:

def calculate_tip(amount, rating):
	

Solutions:
from math import ceil
def calculate_tip(amount, rating):
    tips = {
        'terrible': 0,
        'poor' : .05,
        'good' : .1,
        'great' : .15,
        'excellent' : .2
    }
    if rating.lower() in tips:
        return ceil(amount * tips[rating.lower()])
    else:
        return 'Rating not recognised'

import math

def calculate_tip(amount, rating):
    tip_table = {'terrible'     : 0,
                 'poor'         : 0.05,
                 'good'         : 0.10,
                 'great'        : 0.15,
                 'excellent'    : 0.20}
    rating = rating.lower()
    if rating in tip_table:
        return math.ceil(amount * tip_table[rating.lower()])
    else:
        return "Rating not recognised"


import math

def calculate_tip(amount, rating):
    rating = rating.lower()
    tip = {
        "terrible": 0,
        "poor": 0.05,
        "good": 0.1,
        "great": 0.15,
        "excellent": 0.2
    }.get(rating)
    if (tip == None):
        return "Rating not recognised"
    
    return int(math.ceil(amount * tip))

import math
def calculate_tip(a, r):
    return {"terrible":0*a,"poor":math.ceil(0.05*a),"good":math.ceil(0.1*a),"great":math.ceil(0.15*a),"excellent":math.ceil(0.2*a)}.get(r.lower(), "Rating not recognised")

def calculate_tip(a, r):
    d = {'terrible': 0,'poor': .05,'good': .10,'great': .15,'excellent': .20}
    return int(d[r.lower()] * a + .99) if r.lower() in d else 'Rating not recognised'

from math import ceil
D = {"terrible":0, "poor":0.05, "good":0.1, "great":0.15, "excellent":0.2}

def calculate_tip(amount, rating):
    rating = D.get(rating.lower(), None)
    return "Rating not recognised" if rating is None else ceil(amount * rating)

dict ={
    "terrible": 0,
    "poor": 5,
    "good": 10,
    "great": 15,
    "excellent": 20
}
import math
def calculate_tip(amount, rating):
    return "Rating not recognised" if dict.get(rating.lower(),"null") =="null" else math.ceil(dict.get(rating.lower(),"null")/100*amount)


from math import ceil
def calculate_tip(amount, rating):
    service = {"terrible": 0.00, "poor": 0.05, "good":0.10, "great": 0.15, "excellent": 0.20}
    return(ceil(amount*service[rating.lower()]) if rating.lower() in service.keys() else "Rating not recognised")

from math import ceil
def calculate_tip(a, r):
    d = dict(zip(['terrible', 'poor','good','great','excellent'], [0, 5, 10, 15, 20]))
    r = r.lower()
    if r in d:
        return (ceil(d[r]*a/100))
    else:
        return 'Rating not recognised'

from math import ceil

def calculate_tip(amount, rating):
    tip = {'terrible': 0, 'poor': 0.05, 'good': 0.1, 'great': 0.15, 'excellent': 0.2}
    return ceil(amount * tip[rating.lower()]) if rating.lower() in tip else 'Rating not recognised'

d={'terrible':0,'poor':0.05, 'good':0.1, 'great':0.15, 'excellent':0.2}
def calculate_tip(amount, rating):
    rating = rating.lower()
    if rating not in d: return 'Rating not recognised'
    return __import__('math').ceil(amount*(d[rating]))

import math

def calculate_tip(amount, rating):
    tip = {'terrible': 0, 'poor': 0.05, 'good': 0.10, 'great': 0.15, 'excellent': 0.2}
    return 'Rating not recognised' if rating.lower() not in tip else math.ceil(amount * tip[rating.lower()])

from collections import defaultdict
from math import ceil

SERVICE = defaultdict(lambda: -1,
    {'terrible' : 0.00,
     'poor'     : 0.05,
     'good'     : 0.10,
     'great'    : 0.15,
     'excellent': 0.20 })

def calculate_tip(amount, rating):
    value = SERVICE[rating.lower()]
    return ceil(amount * value) if value >= 0 else 'Rating not recognised'

def calculate_tip(amount, rating):
    dict = {"terrible": 0,
    "poor": 5,
    "good": 10,
    "great": 15,
    "excellent": 20}
    try:
        result = float(amount) / float(100) * dict[rating.lower()]
        if result != int(str(result).split(".")[0]):
            return int(str(result).split(".")[0]) + 1
        return int(result)
    except KeyError:
        return 'Rating not recognised'

from math import ceil

RATES = {"terrible": 0, "poor": 5, "good": 10, "great": 15, "excellent": 20}

def calculate_tip(amount, rating):
    r = rating.lower()
    return 'Rating not recognised'if r not in RATES else ceil(RATES[r]/100.0*amount)

import math
def calculate_tip(amount, rating):
    rates = {'terrible': 0, 'poor': 0.05, 'good': 0.1, 'great': 0.15, 'excellent':0.2}
    if rating.lower() not in rates:
        return "Rating not recognised"
    else:
        return math.ceil(amount * rates[rating.lower()])

def calculate_tip(amount, rating):
    import math
    r = {'terrible': 0, 'poor': 5, 'good': 10, 'great': 15, 'excellent': 20}
    if not rating or rating.lower() not in r:
        return 'Rating not recognised'
    else:
        return math.ceil(amount * r[rating.lower()] / 100.0)

def calculate_tip(amount, rating):
  from math import ceil

  # Rating is case insensitive
  rating = rating.lower()

  ratingMap = {
    'terrible'  : 0.0,
    'poor'      : 0.05,
    'good'      : 0.10,
    'great'     : 0.15,
    'excellent' : 0.20
  }

  return ceil(amount * ratingMap[rating]) if rating in ratingMap else 'Rating not recognised'

import math
def calculate_tip(amount, rating):
    tipTypes = ["terrible","poor","good","great","excellent"]
    if rating.lower() in tipTypes:
        return math.ceil(amount * tipTypes.index(rating.lower())*0.05)
    else: return "Rating not recognised"

from math import ceil

def calculate_tip(amount, rating):
  tips, rating = 'terrible poor good great excellent'.split(), rating.lower()
  return ceil(amount * tips.index(rating) * .05) if rating in tips else 'Rating not recognised'

calculate_tip = lambda a,r, p=["terrible","poor","good","great","excellent"]: int(a*p.index(r.lower())*0.05+0.99) if r.lower() in p else "Rating not recognised"

import math
def calculate_tip(amount, rating):
    ratings = {
        "Terrible": 0,
        "Poor": .05,
        "Good": .10,
        "Great": .15,
        "Excellent":.20
    }
    
    try:
        return math.ceil(amount * ratings.get(rating.title()))
    except:
        return "Rating not recognised"

import math

def calculate_tip(amount, rating):
    rating = rating.lower()
    if (rating == 'terrible'):
        terrible = int(amount)*0
        terrible = math.ceil(terrible)
        return (terrible)
    elif (rating =='poor'):
        poor = int(amount)*0.05
        poor = math.ceil(poor)
        return (poor)
    elif (rating =='good'):
        good = int(amount)*0.1
        good = math.ceil(good)
        return (good)
    elif (rating =='great'):
        great = int(amount)*0.15
        great = math.ceil(great)
        return (great)
    elif (rating =='excellent'):
        excellent = int(amount)*0.20
        excellent = math.ceil(excellent)
        return (excellent)
    else:
        return("Rating not recognised")

import math

def calculate_tip(amount, rating):
    rating = rating.lower()
    tip = {
            "terrible": 0,
            "poor": 0.05,
            "good": 0.10,
            "great":0.15,
            "excellent": 0.20
          }
    return math.ceil(amount * tip[rating]) if rating in tip else "Rating not recognised"
        


import math

def calculate_tip(amount, rating):
    service_perc = {
        "terrible": 0,
        "poor": 0.05,
        "good": 0.1,
        "great": 0.15,
        "excellent": 0.2
    }
    try:
        return math.ceil(amount * service_perc[rating.lower()])
    except KeyError:
        return "Rating not recognised"

import math 

def calculate_tip(amount, rating):
    rating = rating.lower()
    
    if rating == "terrible":
        return 0
    if rating == "poor":
        return int(math.ceil(amount*.05))
    if rating == "good":
        return int(math.ceil(amount*.1))
    if rating == "great":
        return int(math.ceil(amount*.15))
    if rating == "excellent":
        return int(math.ceil(amount*.2))
    else:
        return "Rating not recognised"

from math import ceil
from typing import Union

def calculate_tip(amount: int, rating: str) -> Union[int, str]:
    """ Calculates how much you need to tip based on the total amount of the bill and the service. """
    tips = {
        "terrible": 0,
        "poor": 5,
        "good": 10,
        "great": 15,
        "excellent": 20
    }
    tip = tips.get(rating.lower())
    if tip is None:
        return "Rating not recognised"
    return ceil(amount * (tip / 100))

def calculate_tip(amount, rating):
    d = {'terrible':0,'poor':0.05,'good':0.1,'great':0.15,'excellent':0.2}
    try:
        return -(-amount * d[rating.lower()] // 1)
    except KeyError:
        return 'Rating not recognised'

from math import ceil
def calculate_tip(amount, rating):
    return {
        'terrible': 0,
        'poor': ceil(amount * 0.05),
        'good': ceil(amount * 0.1),
        'great': ceil(amount * 0.15),
        'excellent': ceil(amount * 0.2)}.get(rating.lower(), 'Rating not recognised')

calculate_tip=lambda a,r,R="terrible poor good great excellent".split():int(
R.index(r.lower())*a*.05+1-1e-9)if r.lower()in R else"Rating not recognised"

import math

def calculate_tip(amount, rating):
    try:
        return math.ceil(["terrible", "poor", "good", "great", "excellent"].index(rating.lower()) * 0.05 * amount)
    except:
        return "Rating not recognised"

from math import ceil; calculate_tip = lambda amount, rating: ceil(amount*["terrible", "poor", "good", "great", "excellent"].index(rating.lower())*0.05) if rating.lower() in ["terrible", "poor", "good", "great", "excellent"] else "Rating not recognised"

import math
def calculate_tip(amount, rating):
    bruh = {
        'terrible': 0,
        'poor': math.ceil(amount*.05),
        'good': math.ceil(amount*.1),
        'great': math.ceil(amount*.15),
        'excellent': math.ceil(amount*.2)
    }
    sobaka = rating.lower()
    return bruh.get(sobaka) if sobaka in bruh.keys() else 'Rating not recognised'

import math
def calculate_tip(amount, rating):
    ratings = ["terrible", "poor", "good", "great", "excellent"]
    index = ratings.index(rating.lower()) if rating.lower() in ratings else -1
    return math.ceil(amount * index * 0.05) if index != -1 else "Rating not recognised"

def calculate_tip(amount, rating):
    import math
    tips = {'terrible': 1.0, 'poor': 1.05, 'good': 1.10, 'great': 1.15, 'excellent': 1.20}
    if rating.lower() in tips:
        return math.ceil(tips[rating.lower()] * amount - amount)
    else:
        return 'Rating not recognised'


import math
def calculate_tip(amount, rating):
    r = {'terrible':0, 'poor':0.05, 'good':0.1, 'great': 0.15, 'excellent':0.2}.get(rating.lower(), -1)
    return 'Rating not recognised' if r == -1 else math.ceil(amount*r) 

from math import ceil

RATES = ('terrible', 'poor', 'good', 'great', 'excellent')

def calculate_tip(amount, rating):
    return {name: ceil(rate * amount * .05) for rate, name in enumerate(RATES)}.get(rating.lower(), "Rating not recognised")


from math import ceil

RATES = (('terrible', 0), ('poor', .05), ('good', .1), ('great', .15), ('excellent', .2))

def calculate_tip(amount, rating):
    return {name: ceil(rate * amount) for name, rate in RATES}.get(rating.lower(), "Rating not recognised")

from math import ceil


def calculate_tip(amount, rating):
    service = {'terrible': 0, 'poor': .05, 'good': .10, 'great': .15, 'excellent': .20}
    tip = service.get(rating.lower(), 'Rating not recognised')
    return tip if isinstance(tip, str) else ceil(tip*amount)

calculate_tip = lambda a, r, t={'excellent': .20, 'great': .15, 'good': .10, 'poor': .05, 'terrible': 0}, m=__import__('math'): m.ceil(a * t[r.lower()]) if r.lower() in t.keys() else 'Rating not recognised'

import math

def calculate_tip(amount, rating):
    ratings = {"terrible": 0, "poor": 0.05, "good": 0.1, "great": 0.15, "excellent": 0.2}
    return math.ceil(amount * ratings.get(rating.lower())) if rating.lower() in ratings else "Rating not recognised"

from math import ceil
def calculate_tip(amount, rating):
    tips = {'terrible' : 0, 'poor' : 5, 'good' : 10, 'great' : 15, 'excellent' : 20}
    return ceil(amount*tips[rating.lower()]/100) if rating.lower() in tips else "Rating not recognised"

import math

def calculate_tip(amount, rating):
    tips = {'terrible': 0, 'poor': 5, 'good': 10, 'great': 15, 'excellent': 20}
    return math.ceil(tips[rating.lower()] / 100.0 * amount) if rating.lower() in tips else 'Rating not recognised'

import math
def calculate_tip(amount, rating):
    str_rating = rating.lower()
    
    
    dict = {
        'terrible': 0,
        'poor': 5,
        'good': 10,
        'great': 15,
        'excellent': 20
        
    }
    if str_rating in dict:   
        result = ((amount * dict[str_rating]) / 100)
        return math.ceil(result)
    else:
        return "Rating not recognised"

import math
def calculate_tip(amount, rating):
    ratings_dict = {"terrible": 0, "poor": 0.05, "good": 0.10, "great":0.15, "excellent":0.20}
    if rating.lower() not in ratings_dict.keys():
        return "Rating not recognised"
    else:
        return math.ceil(ratings_dict.get(rating.lower())*amount)

import math
d = {
    
    'terrible': 0,
    'poor': 5,
    'good': 10,
    'great': 15,
    'excellent': 20,
    'bla': 'Rating not recognised'
}

def calculate_tip(amount, rating):
    rating = rating.lower()
    if rating in d.keys():
        return math.ceil((amount * d.get(rating)) / 100)
    else:
        return 'Rating not recognised'

def calculate_tip(amount, rating):
    ratings_dict = {
        'terrible': 0,
        'poor': 5,
        'good': 10,
        'great': 15,
        'excellent': 20
    }
    return int((amount / 100) * ratings_dict[rating.lower()] + 0.99) if rating.lower() in ratings_dict.keys() else 'Rating not recognised'

def calculate_tip(amount, rating):
    from math import ceil
    if rating.lower() == "terrible":
        return 0
    if rating.lower() == "poor":
        return ceil(int(amount)/100*5)
    if rating.lower() == "good":
        return ceil(int(amount)/100*10)
    if rating.lower() == "great":
        return ceil(int(amount)/100*15)
    if rating.lower() == "excellent":
        return ceil(int(amount)/100*20)
    else:
        return "Rating not recognised"

import math

def calculate_tip(amount, rating):
    case = {
        'terrible' : 0,
        'poor' : .05,
        'good' : .1,
        'great' : .15,
        'excellent' : .2,
    }    
    return 'Rating not recognised' if rating.lower() not in case else math.ceil(amount * case.get(rating.lower()))

import math

def calculate_tip(amount, rating):
    d = {
        'terrible' : 0.0,
        'poor' : 0.05,
        'good' : 0.10,
        'great' : 0.15,
        'excellent' : 0.20
    }
    return 'Rating not recognised' if rating.lower() not in d.keys() else math.ceil(amount * d.get(rating.lower()))

import math

def calculate_tip(amount, rating):
    factor = 0
    rating = rating.lower()
    if (rating == "terrible"):
        pass
    elif (rating == "poor"):
        factor = 0.05
    elif (rating == "good"):
        factor = 0.1
    elif (rating == "great"):
        factor = 0.15
    elif (rating == "excellent"):
        factor = 0.2
    else:
        return 'Rating not recognised'
    return math.ceil(amount * factor)

import math
def calculate_tip(amount, rating):
    #your code here
    c=rating.capitalize()
    if(c=="Poor" or "Terrible" or "Good" or "Great" or "Excellent" ):
        if(c=="Poor"):
            return math.ceil(amount*(5/100))
        elif(c=="Excellent"):
            return math.ceil(amount*(20/100))
        elif(c=="Great"):
            return math.ceil(amount*(15/100))
        elif(c=="Good"):
            return math.ceil(amount*(10/100))
        elif(c=="Terrible"):
            return 0
    return 'Rating not recognised'

dict = {
"terrible": 0.0,
"poor": 0.05,
"good": 0.1,
"great": 0.15,
"excellent": 0.2
}
    
import math

    
def calculate_tip(amount, rating):
    try:
        return math.ceil(float(amount) * dict[rating.lower()])
    except:
        return 'Rating not recognised'

from math import ceil

def calculate_tip(amount, rating):
    per = {
        "terrible": 0,
        "poor": 0.05,
        "good": 0.1,
        "great": 0.15,
        "excellent": 0.2
    }.get(rating.lower(), None)
    
    return ceil(amount * per) if per != None else 'Rating not recognised'


import math

def calculate_tip(amount, rating):
    
    rating=rating.lower()
    
    result_2="Rating not recognised"
    result=-1
    
    if rating=="poor":
       result=amount*0.05
    elif rating== "good":
       result=amount*0.1
    elif rating== "great":   
       result=amount*0.15
    elif rating== "excellent":   
       result=amount*0.2
    elif rating=="terrible":
       result=0
    
    
  
    
    if result==-1:
       result=result_2
    
    if rating not in ("poor","excellent","great","good","terrible") :
        return 'Rating not recognised'
    else:
        return math.ceil(result)

import math
def calculate_tip(amount, rating):
    if rating.lower()=="poor":
        return math.ceil(0.05*amount)
    if rating.lower()=="good":
        return math.ceil(0.1*amount)
    if rating.lower()=="great":
        return math.ceil(0.15*amount)
    if rating.lower()=="excellent":
        return math.ceil(0.2*amount)
    if rating.lower()=="terrible":
        return 0
    return 'Rating not recognised'

def calculate_tip(amount, rating):
    import math
    table = {
        "terrible": 0,
        "poor": 0.05,
        "good": .1,
        "great": 0.15,
        "excellent": .2
    }
    rating = rating.lower()
    if rating in table:
        return(math.ceil(amount * table[rating]))
    else:
        return("Rating not recognised")

def calculate_tip(amount, rating):
    
    error = 'Rating not recognised'
    ratings = {
        'terrible' : 0,
        'poor'     : 0.05,
        'good'     : 0.1,
        'great'    : 0.15,
        'excellent': 0.2, 
    }

    try:
        if isinstance(amount, str):
            return error

        v = ratings[rating.lower()]*amount

        if not v % 2 == 0: 
            return int(v+(1-(v%1)))
        else:
            return int(v)
        
    except KeyError:
        return error

from math import ceil

d = {
    "terrible":0, "poor":5, "good":10, "great":15, "excellent":20    
}

def calculate_tip(amount, rating):
    #your code here
    rating = rating.lower()
    if rating not in d.keys():
        return 'Rating not recognised'
    else:
        return ceil(amount*d[rating]/100)

from math import ceil

def calculate_tip(amount, rating):
    if rating.lower() == "excellent":
        return ceil(amount * 0.2)
    elif rating.lower() == "great":
        return ceil(amount * 0.15)
    elif rating.lower() == "good":
        return ceil(amount * 0.1)
    elif rating.lower() == "poor":
        return ceil(amount * 0.05)
    elif rating.lower() == "terrible":
        return 0
    return "Rating not recognised"

import math
def calculate_tip(amount, rating):
    ratings = {'terrible': 0, 'poor': 0.05, 'good': 0.1, 'great': 0.15, 'excellent': 0.2}
    return math.ceil(amount * ratings.get(rating.lower(), 0)) if rating.lower() in ratings else 'Rating not recognised'

from math import ceil
def calculate_tip(amount, rating):
    try:
        tip = {'terrible': 0, 'poor': 0.05, 'good': 0.1, 'great': 0.15, 'excellent': 0.2}.get(rating.lower())
        return ceil(amount * tip)
    except:
        return 'Rating not recognised'

from math import ceil


def calculate_tip(amount, rating):
    TIP = {'terrible': 0, 'poor': 5, 'good': 10, 'great': 15, 'excellent': 20}.get(rating.lower(), None)
    if TIP == None:
        return 'Rating not recognised'
    return ceil((amount * TIP) / 100)

import math

rates = {
    'terrible': 0,
    'poor': 0.05,
    'good': 0.1,
    'great': 0.15,
    'excellent': 0.2
}

def calculate_tip(amount, rating):
    rating = rating.lower()
    
    return math.ceil(amount * rates[rating]) if rating in rates else 'Rating not recognised'


import math 
def calculate_tip(amount, rating):
    return math.ceil((amount*5)/100) if rating.lower() == "poor" else 0 if rating.lower() == "terrible" else math.ceil((amount*10)/100) if rating.lower() == "good" else math.ceil((amount*15)/100) if rating.lower() == "great" else math.ceil((amount*20)/100) if rating.lower() == "excellent" else "Rating not recognised"

import numpy as np

d = {
    'Terrible':0,
    'Poor':0.05,
    'Good':0.1,
    'Great':0.15,
    'Excellent':0.2
}

def calculate_tip(amount, rating):
    try:
        return np.ceil(amount * d[rating.title()])
    except:
        return "Rating not recognised"

import math
def calculate_tip(amount, rating):
    rating=rating.lower()    
    service={'terrible':0, 'poor':0.05, 'good':0.10, 'great':0.15, 'excellent':0.20}
    
    if rating in service:
        return(math.ceil(amount*service[rating]))
    else:
        return('Rating not recognised')
    


tip = {
    'terrible': 0,
    'poor': 0.05,
    'good': 0.1,
    'great': 0.15,
    'excellent': 0.2
}
import math
def calculate_tip(amount, rating):
    rating = rating.lower()
    if rating not in tip:
        return "Rating not recognised"
    return math.ceil(amount * tip[rating])

import math

def calculate_tip(amount, rating):
    r = {
        'terrible': 0,
        'poor': 5,
        'good': 10,
        'great': 15,
        'excellent': 20,        
    }
    
    p = r.get(rating.lower(), 'Rating not recognised')
    
    try:
        return math.ceil(amount * p / 100)
    except:
        return p

import math
 
def calculate_tip(amount, rating):
    dict={"terrible":0,"poor":0.05,"good":0.10,"great":0.15,"excellent":0.20}
    return math.ceil(amount*dict[rating.lower()]) if rating.lower() in dict else "Rating not recognised"

import math
def calculate_tip(amount, rating):
    if(rating.lower()=="poor".lower()):
        a=amount*(5/100)
        return math.ceil(a)
    elif(rating.lower()=="Excellent".lower()):
        a=amount*(20/100)
        return math.ceil(a)
    elif(rating.lower()=="Great".lower()):
        a=amount*(15/100)
        return math.ceil(a)
    elif(rating.lower()=="Good".lower()):
        a=amount*(10/100)
        return math.ceil(a)
    elif(rating.lower()=="terrible".lower()):
        return 0
    else:
        return "Rating not recognised"

import math
def calculate_tip(amount, rating):
    """(^-__-^)"""
    dic = {"terrible": 0, "poor": 5, "good": 10, "great": 15, "excellent": 20}
    return math.ceil((amount / 100) * dic.get(rating.lower())) if rating.lower() in dic else 'Rating not recognised'


import math
def calculate_tip(amount, rating):
    try:
        k = {'terrible': 0, 'poor': 0.05, 'good': 0.1, 'great': 0.15, 'excellent': 0.20}[rating.lower()]*amount
    except:
        return 'Rating not recognised'
    return math.ceil(k)

from math import ceil

def calculate_tip(amount, rating):
    percent = {"terrible": 0, "poor": 5, "good": 10, "great": 15, "excellent": 20}
    tip = percent.get(rating.lower())
    try:
        return ceil(amount*tip/100)
    except:
        return "Rating not recognised"

def calculate_tip(a, r):
    tp = {"terrible": 0, "poor": 5, "good": 10, "great": 15, "excellent": 20}
    if tp.get(r.lower(), None) != None: return int(a*tp[r.lower()]/100 + .99)
    return 'Rating not recognised' 

import math
def calculate_tip(amount, rating):
    if rating.lower() == 'poor':
        return math.ceil((amount / 100) * 5)
    elif rating.lower() == 'good':
        return math.ceil((amount / 100) * 10)
    elif rating.lower() == 'great':
        return math.ceil((amount / 100) * 15)
    elif rating.lower() == 'excellent':
        return math.ceil((amount / 100) * 20)
    elif rating.lower() not in ['poor', 'good', 'great', 'excellent', 'terrible']:
        return 'Rating not recognised'
    else:
        return 0

import math
def calculate_tip(amount, rating):
    tip={"Terrible":0,
         "Poor":5/100,
         "Good":10/100,
         "Great":15/100,
         "Excellent":20/100}

    try:
        return math.ceil(int(amount) * (tip[rating.title()]))
    except:
        return "Rating not recognised"

import math

def calculate_tip(amount, rating):
    tips = {"terrible" : 0,
            "poor"     : 0.05,
            "good"     : 0.1,
            "great"    : 0.15,
            "excellent": 0.2}.get(rating.lower(), None)
    return math.ceil(amount * tips) if tips is not None else 'Rating not recognised'


from math import ceil

def calculate_tip(amount, rating):
    tip = ceil(amount * {"terrible": 0, "poor": 0.05, "good": 0.1, "great": 0.15, "excellent": 0.20}.get(rating.lower(), -1))
    return tip if tip >= 0 else "Rating not recognised"

import math
def calculate_tip(amount, rating):
  
    tips = {'Terrible': 0,
            'Poor': 0.05,
            'Good': 0.1,
            'Great': 0.15,
            'Excellent': 0.2
            }
    return math.ceil(amount*tips[rating.capitalize()]) if rating.capitalize() in tips else 'Rating not recognised'


import math

def calculate_tip(amount, rating):
    rating = rating.lower()
    if rating == "terrible":
        return math.ceil(amount*0)
    if rating == "poor":
        return math.ceil(amount*0.06)
    if rating == "good":
        return math.ceil(amount*0.1)
    if rating == "great":
        return math.ceil(amount*0.15)
    if rating == "excellent":
        return math.ceil(amount*0.2)
    else:
        return 'Rating not recognised'
    


from math import ceil

def calculate_tip(amount, rating):
    ratings  = {
        "terrible": 0,
        "poor": 5,
        "good": 10,
        "great": 15,
        "excellent": 20,
    }
    if rating.lower() not in ratings.keys(): return "Rating not recognised"
    return ceil(ratings.get(rating.lower()) * amount / 100)

from math import ceil
def calculate_tip(amount, rating):
    return {'terrible':0,'poor':ceil(amount*(0.05)),'good':ceil(amount*(1/10)),'great':ceil(amount*(15/100)),'excellent':ceil(amount*(1/5))}.get(rating.lower(),'Rating not recognised')

 


from math import ceil
def calculate_tip(amount, rating):
    dict={
'Terrible': 0,
'Poor': 0.05,
'Good': 0.1,
'Great': 0.15,
'Excellent': 0.2
    }
    return ceil(amount * dict.get(rating.capitalize())) if dict.get(rating.capitalize(),'nothing')!='nothing' else 'Rating not recognised'

import math
def calculate_tip(amount, rating):
    rating = rating.lower()
    if rating == "poor":
        return math.ceil(amount*0.05)
    elif rating == "terrible":
        return 0
    elif rating == "good":
        return math.ceil(amount*0.1)
    elif rating == "great":
        return math.ceil(amount*0.15)
    elif rating == "excellent":
        return math.ceil(amount*0.2)
    else:
        return "Rating not recognised"

import math
def calculate_tip(amount, rating):
    calc_tip = {"terrible":0, "poor":0.05, "good":0.10, "great":0.15, "excellent":0.20}
    if rating.lower() in calc_tip:
        res = amount* calc_tip[rating.lower()]
        if type(res) == float: res = math.ceil(res) 
        return res
    else: return "Rating not recognised"

from math import ceil
def calculate_tip(amount, rating):
    if rating.lower() == 'terrible':
        return ceil(amount * 0)
    elif rating.lower() == 'poor':
        return ceil(amount * 0.05)
    elif rating.lower() == 'good':
        return ceil(amount * 0.1)
    elif rating.lower() == 'great':
        return ceil(amount * 0.15)
    elif rating.lower() == 'excellent':
        return ceil(amount * 0.2)
    else:
        return "Rating not recognised"


import math

def calculate_tip(amount, rating):
    x = {
        'terrible': 0,
        'poor': 5,
        'good': 10,
        'great': 15,
        'excellent': 20
    }.get(rating.lower())
    return math.ceil(x * amount/100) if x != None else 'Rating not recognised'

from math import ceil
def calculate_tip(amount, rating):
    dict_ = {'excellent': .2, 'great': .15, 'good': .1, 'poor': .05, 'terrible': 0}
    if rating.lower() in dict_:
        return ceil(amount * dict_[rating.lower()])
    else:
        return 'Rating not recognised'

import math

def calculate_tip(amount, rating):
    d = {'terrible': 0,
    'poor': 0.05,
    'good': 0.10,
    'great': 0.15,
    'excellent': 0.20}

    for key, val in d.items():
        if key == rating.lower():
            return math.ceil(amount * val)
    return 'Rating not recognised'

import math
def calculate_tip(amount, rating):
    rating = rating.lower()
    if rating == "poor":
        return math.ceil(amount*0.05)
    elif rating == "good":
        return math.ceil(amount * 0.1)
    elif rating == "great":
        return math.ceil(amount * 0.15)
    elif rating == "excellent":
        return math.ceil(amount * 0.2)
    elif rating == "terrible":
        return math.ceil(amount * 0)
    else:
        return "Rating not recognised"

import math
def calculate_tip(amount, rating):
    amount = math.ceil(amount)
    if rating.title() == 'Terrible':
        return amount * 0
    elif rating.title() == 'Poor':
        return math.ceil(amount * 0.05)
    elif rating.title() == 'Good':
        return math.ceil(amount * 0.10)
    elif rating.title() == 'Great':
        return math.ceil(amount * 0.15)
    elif rating.title() == 'Excellent':
        return math.ceil(amount * 0.2)
    else:
        return 'Rating not recognised'

import numpy as np
def calculate_tip(amount, rating):
    tips={'terrible': 0, 'poor':0.05, 'good': 0.1, 'great': 0.15, 'excellent':0.2}
    try:
        return np.ceil(tips[rating.lower()]*amount)
    except:
        return 'Rating not recognised'

import math

def calculate_tip(amount, rating):
    rate = rating.lower()
    
    discount = 0
    discountTwo = amount * .05
    discountThree = amount * .10
    discountFour = amount * .15
    discountFive = amount * .20
    
    if rate == "terrible":
        return math.ceil(discount)
    elif rate == "poor":
        return math.ceil(discountTwo)
    elif rate == "good":
        return math.ceil(discountThree)
    elif rate == "great":
        return math.ceil(discountFour)
    elif rate == "excellent":
        return math.ceil(discountFive)
    return "Rating not recognised"

from math import ceil
def calculate_tip(amount, rating):
    tab = {'terrible': 0, 'poor': 0.05, 'good': 0.1, 'great': 0.15, 'excellent': 0.2}
    mpl = tab.get(rating.lower(), -1)
    return ceil(amount * mpl) if mpl >= 0 else "Rating not recognised"

from math import ceil

def calculate_tip(amount, rating):
    ratings = ["terrible","poor",'good','great','excellent']
    if rating.lower() in ratings:
        tip = 5 * ratings.index(rating.lower())
        return ceil((tip/100) * amount)
    else:
        return "Rating not recognised"

from math import ceil

def calculate_tip(amount, rating):
    rating_table = {
        'Terrible': 0, 'Poor': 0.05, 'Good': 0.1, 'Great': 0.15, 'Excellent': 0.2
    }
    rating = rating.title()
    if rating in rating_table:
        return ceil(amount * rating_table.get(rating))
    else:
        return 'Rating not recognised'

import math
def calculate_tip(amount, rating):
    rates = {"terrible":0, "poor":0.05, "good":0.1, "great":0.15,"excellent":0.2}
    
    return math.ceil(amount * rates[rating.lower()]) if rating.lower() in rates.keys() else "Rating not recognised"

import math
def calculate_tip(amount, rating):
    legend=[("terrible",0),("poor",5),("good",10),("great",15),("excellent",20)]
    for i in range (len(legend)):
        if rating.lower()==legend[i][0]:
            return math.ceil(amount*legend[i][1]/100)
        else:
            pass
    return "Rating not recognised"


def calculate_tip(amount: int, rating: str) -> int:
    return {
        "Terrible": round((lambda x: x * 0.00)(amount) + 0.5),
        "Poor": round((lambda x: x * 0.05)(amount) + 0.5),
        "Good": round((lambda x: x * 0.10)(amount) + 0.5),
        "Great": round((lambda x: x * 0.15)(amount) + 0.5),
        "Excellent": round((lambda x: x * 0.20)(amount) + 0.5),
    }.get(rating.title(), "Rating not recognised")