-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconsole_read_write.py
More file actions
49 lines (41 loc) · 1.22 KB
/
console_read_write.py
File metadata and controls
49 lines (41 loc) · 1.22 KB
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
# Function : Calculate percentage
def calculatePercentage(marksList):
cnt = len(marksList)
total = cnt * 100
sum = 0
for i in marksList :
sum += i
perc = sum/total * 100
return perc
# Function : Print Details
def DisplayReportCard(rollNo, name, marksList, perc):
print("\n\n------------------------- Report Card ----------------------")
print("Roll No. : ", end='\t')
print(rollNo)
print("Name : ", end='\t\t')
print(name)
print("\t Physics", end='\t')
print(marksList[0])
print("\t Chemistry", end='\t')
print(marksList[1])
print("\t Maths", end='\t\t')
print(marksList[2])
print("\n\t Percentage", end='\t')
print(perc)
# ---------------------------------------main function -------------------------------------------------
# declare marks List.
marks = []
# read input from console.
rollNo = int(input("Enter Roll No : "))
name = input("Enter Name : ")
phy = float(input("Enter marks in Physics : "))
chem = float(input("Enter marks in Chemistry : "))
math = float(input("Enter marks in Math : "))
# Add marks to the marks list.
marks.append(phy)
marks.append(chem)
marks.append(math)
# Calculate percentage
perc = calculatePercentage(marks)
# Call DisplayReportCard()
DisplayReportCard(rollNo, name, marks, perc)