-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday 2.py
More file actions
45 lines (36 loc) · 1004 Bytes
/
day 2.py
File metadata and controls
45 lines (36 loc) · 1004 Bytes
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
class Student:
def __init__(self, name, age, marks=0):
self.name = name
self.age = age
self.marks = marks
def show_info(self):
print(f"Name: {self.name}, Age: {self.age}, Marks: {self.marks}")
def grade(self):
if self.marks >= 80:
return "A+"
elif self.marks >= 70:
return "A"
elif self.marks >= 60:
return "A-"
elif self.marks >= 50:
return "B+"
elif self.marks >= 40:
return "C"
elif self.marks >= 33:
return "D"
else:
return "F"
students = []
n = int(input("How many students? "))
for i in range(n):
print(f"\nStudent {i+1}")
name = input("Enter name: ")
age = int(input("Enter age: "))
marks = int(input("Enter marks: "))
s = Student(name, age, marks)
students.append(s)
print("\n--- Student List ---")
for s in students:
s.show_info()
print("Grade:", s.grade())
print()