78.9k views
3 votes
write a python program that determines the average of three test scores. the program should prompt the user to enter the three scores from the keyboard. all test scores are to be entered as scores out of 100 but without the % sign. the program should calculate the average as a percent and display it accurate to two decimal places with the % symbol immediately following the final digit.

User Alicja
by
6.9k points

1 Answer

4 votes

Answer:

Certainly! Here's a Python program that calculates the average of three test scores entered by the user and displays the result as a percentage.

```python

# Prompt the user to enter the three test scores

score1 = int(input("Enter score 1 (out of 100): "))

score2 = int(input("Enter score 2 (out of 100): "))

score3 = int(input("Enter score 3 (out of 100): "))

# Calculate the average as a percentage

average = (score1 + score2 + score3) / 3

# Display the average with the % symbol

print("Average score: {:.2f}%".format(average))

```

In this program, we use the `input()` function to prompt the user to enter the three test scores. Each score is converted to an integer using the `int()` function to ensure numeric calculations. The average is calculated by summing the scores and dividing by 3. The `print()` function is used to display the average with two decimal places and the `%` symbol.

Step-by-step explanation:

User Thomas Rollet
by
7.9k points

No related questions found