0% found this document useful (0 votes)
23 views

Assignment Worksheet Python

assignment

Uploaded by

maivagii70
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Assignment Worksheet Python

assignment

Uploaded by

maivagii70
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

DEPARTMENT OF

COMPUTER SCIENCE & ENGINEERING

Worksheet 1

Student Name: YASH UID: 23BCS13230


Branch: CSE Section/Group: 23BCS804-B
Semester: 3 Date of Performance:18/07/24
Subject Name: Python Programming Subject Code: 23CSP-201

Aim: Simple Grade Calculator

Requirements (Hardware/Software):
1. Take Three test scores and calculate the average.
2. Assign a letter grade based on the average score.
3. Display the average score and corresponding letter grade.
4. Allow for multiple grade calculation in one sessions.

Program:
def calculate_grade(average_score):
if average_score >= 90:
return 'A'
elif average_score >= 80:
return 'B'
elif average_score >= 70:
return 'C'
elif average_score >= 60:
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

return 'D'
else:
return 'F'

def main():
print("Enter your three test scores:")

score1 = float(input("Enter the first test score: "))


score2 = float(input("Enter the second test score: "))
score3 = float(input("Enter the third test score: "))

if (score1 < 0 or score1 > 100) or (score2 < 0 or score2 > 100) or (score3 < 0 or score3 > 100):
print("Invalid score. Please enter scores between 0 and 100.")
else:
average_score = (score1 + score2 + score3) / 3
grade = calculate_grade(average_score)
print(f"Your average score is: {average_score:.2f}")
print(f"Your grade is: {grade}")

if __name__ == "__main__":
main()
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

OUTPUT:

You might also like