219k views
5 votes
In python, create a program that prompts the user for a set of scores and then calculates the percentage of scores above 70%. Please use if statement and another counter Example:

Please enter a set of scores:90 70 60 85
Output: Percent passing is (blank)

User David Genn
by
7.8k points

1 Answer

4 votes

Final answer:

A Python program can be written to prompt users for scores, count the number that are above 70% using an if statement and a counter, and then calculate and display the percentage of those passing scores.

Step-by-step explanation:

To calculate the percentage of scores above 70% in Python, you can prompt the user for a set of scores and utilize an if statement to determine which scores are passing. You'll also use a counter to keep track of the number of passing scores. Here's an example program:

# Prompt the user for input
scores_input = input("Please enter a set of scores (separated by space): ")

# Convert the input string to a list of integers
scores = list(map(int, scores_input.split()))

# Initialize the counter for scores above 70
count_passing = 0

# Iterate over the scores and increment the counter if the score is above 70
for score in scores:
if score > 70:
count_passing += 1

# Calculate the percentage of passing scores
percent_passing = (count_passing / len(scores)) * 100

# Output the result
print("Percent passing is", percent_passing)

Upon execution, this program will display the percentage of scores that are above 70%, giving you the output you need.

User German Lashevich
by
7.4k points