Create a function finalGrade, which calculates the final grade of a student depending on two parameters: a grade for the exam and a number of completed projects.

This function should take two arguments:
exam - grade for exam (from 0 to 100);
projects - number of completed projects (from 0 and above);

This function should return a number (final grade).
There are four types of final grades:
- 100, if a grade for the exam is more than 90 or if a number of completed projects more than 10.
- 90, if a grade for the exam is more than 75 and if a number of completed projects is minimum 5.
- 75, if a grade for the exam is more than 50 and if a number of completed projects is minimum 2.
- 0, in other cases

Examples:

~~~if-not:nasm
```python
final_grade(100, 12)  # 100
final_grade(99, 0)    # 100
final_grade(10, 15)   # 100
final_grade(85, 5)    # 90
final_grade(55, 3)    # 75
final_grade(55, 0)    # 0
final_grade(20, 2)    # 0
```
~~~

*Use Comparison and Logical Operators.

Difficulty: EASY
Starter code: def final_grade(exam, projects):
	

Solutions:
def final_grade(exam, projects):
	if exam > 90 or projects > 10:
		return 100
	if exam > 75 and projects >= 5:
		return 90
	if exam > 50 and projects >= 2:
		return 75
	return 0


def final_grade(x, p):
	return (x > 90 or p > 10) and 100 or (x > 75 and p >= 5 and 90) or (x > 50 and p >= 2 and 75) or 0


def final_grade(exam, projects):
	if exam > 90 or projects > 10:
		results = 100
	elif exam > 75 and projects >= 5:
		results = 90
	elif exam > 50 and projects >= 2:
		results = 75
	else:
		results = 0
	return results


def final_grade(exam, projects):
	if exam > 90 or projects > 10:
		return 100
	if exam > 75 and projects > 4:
		return 90
	if exam > 50 and projects > 1:
		return 75
	return 0


final_grade = lambda e, p: {e > 50 and p >= 2: 75, e > 75 and p >= 5: 90, e > 90 or p > 10: 100}.get(True, 0)


from functools import reduce
from operator import and_, or_
from typing import NamedTuple, Tuple, Callable, Any
Exam = Projects = int
Activities = Tuple[Exam, Projects]

class Rule(NamedTuple):
	limits: Activities
	relation: Callable[[bool, bool], bool]
	result: Any
RULES = (Rule((90, 10), or_, 100), Rule((75, 4), and_, 90), Rule((50, 1), and_, 75))

def final_grade(*scores: Activities) -> int:
	for rule in RULES:
		pairs = tuple(zip(scores, rule.limits))
		if pairs and reduce(rule.relation, (score > limit for (score, limit) in pairs)):
			return rule.result
	return 0


def final_grade(exam, projects):
	try:
		return {exam > 50 and projects >= 2: 75, exam > 75 and projects >= 5: 90, exam > 90 or projects > 10: 100}[True]
	except KeyError:
		return 0


def final_grade(exam, projects):
	return {exam > 50 and projects > 1: 75, exam > 75 and projects > 4: 90, exam > 90 or projects > 10: 100}.get(True, 0)


def final_grade(exam: int, projects: int) -> int:
	return {all([exam > 50, projects >= 2]): 75, all([exam > 75, projects >= 5]): 90, any([exam > 90, projects > 10]): 100}.get(True, 0)


final_grade = lambda e, p: [0, 75, 90, 100][sum([e > 90 or p > 10, e > 75 and p > 4 or (e > 90 or p > 10), e > 50 and p > 1 or (e > 90 or p > 10)])]


def final_grade(exam, projects):
	if exam > 90 or projects > 10:
		return 100
	for val in [(75, 5, 90), (50, 2, 75)]:
		if exam > val[0] and projects >= val[1]:
			return val[2]
	return 0


def final_grade(exam, projects):
	return min(75 * (exam > 50 and projects > 1) + 15 * (exam > 75 and projects > 4) + 100 * (exam > 90 or projects > 10), 100)


_ = '_'

def match(patterns, *args):
	for (pattern, result) in patterns:
		if all((p == _ or p == actual for (p, actual) in zip(pattern, args))):
			return result

def final_grade(exam, projects):
	patterns = [((True,), 100), ((_, _, _, True), 100), ((_, True, _, _, True), 90), ((_, _, True, _, _, True), 75), ((), 0)]
	return match(patterns, exam > 90, exam > 75, exam > 50, projects > 10, projects > 4, projects > 1)


final_grade = lambda e, p: [0, 75, 90, 100][3 * (e > 90 or p > 10) or 2 * (e > 75 and p > 4) or (e > 50 and p > 1)]


def final_grade(e, p, o=0):
	return 100 if e > 90 or p > 10 else 90 if e > 75 and p > 4 else 75 if e > 50 and p > 1 else 0


final_grade = lambda g, p: 100 if g > 90 or p > 10 else 90 if g > 75 and p > 4 else 75 if g > 50 and p > 1 else 0


def final_grade(exam, projects):
	results = [0, 75, 90, 100, 100, 100]
	return results[3 * (exam > 90 or projects > 10) + (exam > 75 and projects >= 5) + (exam > 50 and projects >= 2)]


def final_grade(exam, projects):
	array = [100, 90, 75, 0]
	if exam > 90 or projects > 10:
		return array[0]
	elif exam > 75 and projects >= 5:
		return array[1]
	elif exam > 50 and projects >= 2:
		return array[2]
	else:
		return array[3]


def final_grade(exam, projects):
	if exam > 90 or projects > 10:
		return 100
	minimums = ((90, 76, 5), (75, 51, 2), (0, 0, 0))
	return next((score for (score, exam_min, projects_min) in minimums if exam_min <= exam and projects_min <= projects))


def final_grade(exam, projects):
	(exams, proj, grades) = ([90, 75, 50, 0], [10, 4, 1, 0], [100, 90, 75, 0])
	for i in range(4):
		if exam > 90 or projects > 10:
			return 100
		if exam > exams[i] and projects > proj[i]:
			return grades[i]
	return 0


import unittest

def final_grade(exam, projects):
	print((exam, projects))
	if exam > 90 or projects > 10:
		return 100
	elif exam > 75 and projects >= 5:
		return 90
	elif exam > 50 and projects >= 2:
		return 75
	else:
		return 0

class TestFinalGrade(unittest.TestCase):

	def test_final_grade_on_100_with_exam_score_that_is_more_than_90(self):
		(exam, projects) = (100, 12)
		actual = final_grade(exam, projects)
		self.assertEqual(actual, 100)

	def test_final_grade_on_100_with_projects_that_is_more_than_10(self):
		(exam, projects) = (80, 10)
		actual = final_grade(exam, projects)
		self.assertEqual(actual, 100)

	def test_final_grade_on_90_with_exam_score_that_is_more_than_75(self):
		(exam, projects) = (75, 3)
		actual = final_grade(exam, projects)
		self.assertEqual(actual, 90)

	def test_final_grade_on_90_with_projects_that_is_more_than_5(self):
		(exam, projects) = (70, 5)
		actual = final_grade(exam, projects)
		self.assertEqual(actual, 90)

	def test_final_grade_on_75_with_exam_score_that_is_more_than_50(self):
		(exam, projects) = (50, 3)
		actual = final_grade(exam, projects)
		self.assertEqual(actual, 75)

	def test_final_grade_on_75_with_projects_that_is_more_than_2(self):
		(exam, projects) = (40, 3)
		actual = final_grade(exam, projects)
		self.assertEqual(actual, 75)

	def test_final_grade_on_0_with_projects_and_exam_score_that_is_less_than_final_grade_on_75(self):
		(exam, projects) = (30, 1)
		actual = final_grade(exam, projects)
		self.assertEqual(actual, 0)


def final_grade(exam, pro):
	if exam > 90 or pro > 10:
		return 100
	if exam > 75 and pro >= 5:
		return 90
	if exam > 50 and pro >= 2:
		return 75
	else:
		return 0


def final_grade(exam, projects):
	if exam > 90:
		return 100
	elif projects >= 11:
		return 100
	if exam > 75 and projects >= 5:
		return 90
	if exam > 50 and projects >= 2:
		return 75
	else:
		return 0


def final_grade(points, project):
	if points > 90 or project > 10:
		point = 100
	elif points > 75 and project >= 5:
		point = 90
	elif points > 50 and project >= 2:
		point = 75
	else:
		point = 0
	return point


final_grade = lambda e, p: [0, 75, 90, 100, 100, 100][(e > 90 or p > 10) * 3 + (e > 75 and p >= 5) + (e > 50 and p >= 2)]


def final_grade(s, p):
	return 100 if s > 90 or p > 10 else 90 if s > 75 and p >= 5 else 75 if s > 50 and p >= 2 else 0


def final_grade(a, b):
	if a > 90 or b > 10:
		return 100
	elif a > 75 and b > 4:
		return 90
	elif a > 50 and b > 1:
		return 75
	else:
		return 0


def final_grade(exam, projects):
	print(' ' + str(exam) + ' ' + str(projects))
	data = [[90, 10, 100], [75, 5, 90], [50, 2, 75]]
	if exam > data[0][0] or projects > data[0][1]:
		return data[0][2]
	elif exam > data[1][0] and projects >= data[1][1]:
		return data[1][2]
	elif exam > data[2][0] and projects >= data[2][1]:
		return data[2][2]
	return 0


def final_grade(exam, projects):
	if exam > 90 or projects > 10:
		return 100
	elif exam in range(76, 91) and projects >= 5:
		return 90
	elif exam > 50 and projects >= 2:
		return 75
	elif exam <= 50 or projects < 2:
		return 0


def final_grade(e, p):
	return 100 if e > 90 or p > 10 else 90 if e > 75 and p > 4 else 75 if e > 50 and p >= 2 else 0


def final_grade(exam, projects):
	print((exam, projects))
	grade = 0
	if exam > 90 or projects > 10:
		grade = 100
	elif exam > 75 and projects > 4:
		grade = 90
	elif exam > 50 and projects > 1:
		grade = 75
	return grade


def final_grade(e, p):
	s = 0
	if e > 90 or p > 10:
		s = 100
	elif e > 75 and p > 4:
		s = 90
	elif e > 50 and p > 1:
		s = 75
	return s


def final_grade(exam, projects):
	result = 0
	if exam > 90 or projects > 10:
		result = 100
	elif exam > 75 and projects > 4:
		result = 90
	elif exam > 50 and projects > 1:
		result = 75
	else:
		result = 0
	return result


def final_grade(ex, p):
	if ex > 90 or p > 10:
		return 100
	elif ex > 75 and p >= 5:
		return 90
	elif ex > 50 and p >= 2:
		return 75
	else:
		return 0


def final_grade(exam, projects):
	e = exam
	p = projects
	if e > 90 or p > 10:
		return 100
	elif e > 75 and p >= 5:
		return 90
	elif e > 50 and p >= 2:
		return 75
	return 0


def final_grade(exam, pr):
	if exam > 90 or pr > 10:
		return 100
	elif exam > 75 and pr >= 5:
		return 90
	elif exam > 50 and pr >= 2:
		return 75
	return 0


def final_grade(exams, projects):
	return 100 if exams > 90 or projects > 10 else 90 if exams > 75 and projects >= 5 else 75 if exams > 50 and projects >= 2 else 0


def final_grade(e, p):
	if p > 10 or e > 90:
		return 100
	if p >= 5 and e > 75:
		return 90
	if p >= 2 and e > 50:
		return 75
	return 0


def final_grade(exam, projects):
	if exam >= 91 or projects > 10:
		return 100
	elif exam >= 76 and projects >= 5:
		return 90
	elif exam >= 51 and projects >= 2:
		return 75
	else:
		return 0
	return


def final_grade(exm, prj):
	if exm > 90 or prj > 10:
		return 100
	if exm > 75 and prj >= 5:
		return 90
	if exm > 50 and prj >= 2:
		return 75
	return 0


def final_grade(ex, prj):
	return 100 if ex > 90 or prj > 10 else 90 if ex > 75 and prj >= 5 else 75 if ex > 50 and prj >= 2 else 0


def final_grade(exam, projects):
	grade = [100, 90, 75, 0]
	x = 3
	if exam > 90 or projects > 10:
		x = 0
	elif exam > 75 and projects > 4:
		x = 1
	elif exam > 50 and projects > 1:
		x = 2
	return grade[x]