Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
75 views
in Technique[技术] by (71.8m points)

python - Write a program to accept; the matric number

Write a program to accept; the matric number, first name, last name, 3scores(1st ca, 2nd ca and Exam) . It should compute the total score and average and should be able to give the highest and lowest scorer and finally print out the matric number and scores.

so this is what i have so far

    def start():
    print("")
    op = input("""
1. Add Score to Data base
2. Read database

                     e to exit
>""")

    if op.lower() == "1":
        reg()
    elif op.lower() == "2":
        check_data()
    elif op.lower() == "e":
        credits()
    else:
        start()

def readd():
    print("=" *23)
    re = input("Do you want another one yes or no 
> ")
    if re.lower() == "yes":
        reg()
    elif re.lower() == "no":
        start()
    else:
        start()

def credits():
    print("code by All things Phantasm an iamphantasm project")

def check_data():
    input_v = input("what is the name of the file: ")
    filename = input_v + ".txt"
    if filename:
        demac = "=" * 23
        print(f"{demac}")
        try:
            with open(filename, 'r') as file:
                p = file.read()
            print(p)
            start()
        except:
            print('No file with that name')
            start()
    elif filename.lower() == "e":
        start()


def reg():
    filename = "score.txt"
    try:
        print('Enter your name: ')
        fname = input('First name: ')
        lname = input('Last name: ')
        matric_no = input('Matric No: ')
        level = input('Level: ')
        course_study = input('What is your course of study: ')
        print('Enter your scores')
        fca = int(input('1st ca: '))
        sca = int(input('2st ca: '))
        exam = int(input('Exam: '))
        total = fca + sca + exam

        with open(filename, "a") as f:
            student_data = f"{fname} {lname} | {matric_no} | {level}lvl | {course_study} | {fca} | {sca} | {exam} | {total} 
"
            f.write(student_data)
            readd()

    except:
        start()


start()

i need some help on how to find d average and be able to give the highest and lowest scorer and finally print out the matric number and scores.

question from:https://stackoverflow.com/questions/65863181/write-a-program-to-accept-the-matric-number

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...