Dev.to AI 🤖 Ai 👁 0 📖 3 min read

Python learning series | list Programs solving

The given list , the scored mark in quartaly exam(q), halfy exam(h) and annual exam q = [90,80, 67, 58, 49] h = [87,89, 99, 47, 36] a = [56,78, 46, 67, 69] To find total Mark in each exam To find highest ma

The given list , the scored mark in quartaly exam(q),

halfy exam(h) and annual exam

q = [90,80, 67, 58, 49]
h = [87,89, 99, 47, 36]
a = [56,78, 46, 67, 69]

  • To find total Mark in each exam
  • To find highest mark in each exam
  • To find the highest mark position in each exam
  • To find overall highest mark in all exam
  • To find Single subject average in all exam

1) To find total Mark in each exam

q = [90,80, 67, 58, 49]
h = [87,89, 99, 47, 36]
a = [56,78, 46, 67, 69]

each_exam = [q,h,a]

total = 0
i = 0
while i < len(each_exam[0]):
    total += q[i]
    i+=1
print("Total mark in q : ",total)


total = 0
i = 0
while i < len(each_exam[1]):
    total += h[i]
    i+=1
print("Total mark in h : ",total)


total = 0
i = 0
while i < len(each_exam[2]):
    total += a[i]
    i+=1
print("Total mark in a : ",total)

output:

Total mark in q :  344
Total mark in h :  358
Total mark in a :  316

2) To find highest mark in each exam

highest = 0
total = 0
i = 0
while i < len(each_exam[0]):
    if q[i] > highest:
        highest = q[i]
    i+=1
print("Highest mark in q : ",highest)

highest = 0
i = 0
while i < len(each_exam[1]):
    if h[i] > highest:
        highest = h[i]
    i+=1
print("Highest mark in h : ",highest)

highest = 0
i = 0
while i < len(each_exam[2]):
    if a[i] > highest:
        highest = a[i]
    i+=1
print("Highest mark in a : ",highest)

*Output : *

Highest mark in q :  90
Highest mark in h :  99
Highest mark in a :  78

3) To find the highest mark position in each exam

subject_position = 0
highest = 0
total = 0
i = 0
while i < len(each_exam[0]):
    if q[i] > highest:
        highest = q[i]
        subject_position = i + 1
    i+=1
print("Highest mark in q : ",highest)
print("Highest_Mark in q subject is : " , subject_position )

subject_position = 0
highest = 0
i = 0
while i < len(each_exam[1]):
    if h[i] > highest:
        highest = h[i]
        subject_position = i + 1
    i+=1
print("Highest mark in h : ",highest)
print("Highest_Mark in q subject is : " , subject_position )

subject_position = 0
highest = 0
i = 0
while i < len(each_exam[2]):
    if a[i] > highest:
        highest = a[i]
        subject_position = i + 1
    i+=1
print("Highest mark in a : ",highest)
print("Highest_Mark in q subject is : " , subject_position )

output :

Highest mark in q :  90
Highest_Mark in q subject is :  1
Highest mark in h :  99
Highest_Mark in q subject is :  3
Highest mark in a :  78
Highest_Mark in q subject is :  2

4) To find overall highest mark in all exam

highest_score = 0
exam = ""
highest = 0
total = 0
i = 0
while i < len(each_exam[0]):
    if q[i] > highest:
        highest = q[i]
    i+=1
if highest > highest_score :
    highest_score = highest
    exam = "Exam q"

highest = 0
i = 0
while i < len(each_exam[1]):
    if h[i] > highest:
        highest = h[i]
    i+=1
if highest > highest_score :
    highest_score = highest
    exam = "Exam h"

highest = 0
i = 0
while i < len(each_exam[2]):
    if a[i] > highest:
        highest = a[i]
    i+=1
if highest > highest_score :
    highest_score = highest
    exam = "Exam a"

print(f"overall Highest mark in all exam: {highest_score} in {exam} ")

output :

overall Highest mark in all exam: 99 in Exam h 

All in one

q = [90,80, 67, 58, 49]
h = [87,89, 99, 47, 36]
a = [56,78, 46, 67, 69]

each_exam = [q,h,a]

highest_score = 0
exam = ""
total = 0
highest = 0
subject = 0
i = 0
while i < len(each_exam[0]):
    total += q[i]

    if q[i] > highest:
        highest = q[i]
        subject = i+1
    i+=1
if highest > highest_score :
    highest_score = highest
    exam = "Exam q"
print("Total mark in q : ",total)
print("Highest mark in q : ",highest)
print("Highest_Mark in q subject is : " , subject )


total = 0
subject = 0
highest = 0
i = 0
while i < len(each_exam[1]):
    total += h[i]
    if h[i] > highest:
        highest = h[i]
        subject_position = i+1
    i+=1
if highest > highest_score :
    highest_score = highest
    exam = "Exam h"
print("Total mark in h : ",total)
print("Highest mark in h : ",highest)
print("Highest_Mark in q subject is : " , subject_position )


total = 0
highest = 0
subject = 0
i = 0
while i < len(each_exam[2]):
    total += a[i]
    if a[i] > highest:
        highest = a[i]
        subject_position = i+1
    i+=1
if highest > highest_score :
    highest_score = highest
    exam = "Exam a"
print("Total mark in a : ",total)
print("Highest mark in a : ",highest)
print("Highest_Mark in q subject is : " , subject_position )

print(f"overall Highest mark in all exam: {highest_score} in {exam} ")

5) To find Single subject average in all exam

i = 0
while i < len(q) :
    total = q[i] + h[i] + a [i]
    average = total // 3
    print("Average of each subject " , average)
    i +=1

output :

Average of each subject  77
Average of each subject  82
Average of each subject  70
Average of each subject  57
Average of each subject  51

📰 Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.