-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdef function.py
80 lines (50 loc) · 1.07 KB
/
def function.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# ex 1
def sam():
print("hello")
print('how are you')
sam()
# Ex 2
def sam(name):
print('hello', name)
print('how are you ?')
sam("Amar")
# Ex 3
def addition_val(n1, n2):
result = n1 + n2
return result
number1 = 5.5
number2 = 7.5
result = addition_val(number1, number2)
print("the sum is : ", result)
# Ex 4
def addition_val(n1, n2):
result = n1 + n2
return result
n1 = 5.5
n2 = 7.5
result = addition_val(n1, n2)
print("the sum is : ", result)
# Ex 5
# find avarage marks
def value(numbers):
total_sum = sum(numbers)
avarage_value = total_sum / len(numbers)
return avarage_value
# find Grade
def grade_of(total_marks):
if total_marks >= 80:
grade = 'A'
elif total_marks >= 70:
grade = 'B'
elif total_marks >= 55:
grade = 'C'
elif total_marks >= 35:
grade = 'D'
else:
grade = 'D'
return grade
marks = [50, 60, 70, 59, 78, 80]
avarage_value = value(marks)
print("avarage value is ", avarage_value)
grade = grade_of(avarage_value)
print('your grade is ', grade)