# Solution
importmathRATINGS={'terrible':.0,'poor':0.05,'good':0.1,'great':0.15,'excellent':0.2}tip=lambdap,s:math.ceil(p*RATINGS[s.lower()])ifs.lower()inRATINGSelse'Rating not recognized'# Test cases
cases=[(30,"poor"),(20,"hi"),(107.65,"great"),(78,"good"),(50,"poor"),(125,"excellent"),]forcaseincases:print(f'With score "{case[1]}" and amount {case[0]}, tip: {tip(*case)}')
Python 3
Try it online!