0

A gymnast can earn a score between 1 and 10 from each judge; nothing lower, nothing higher. All scores are integer values; there are no decimal scores from a single judge. Store the possible scores a gymnast can earn from one judge in a tuple. Print out the sentence:

"The lowest possible score is ____, and the highest possible score is ____."

Use the values from your tuple. Print out a series of sentences, "A judge can give a gymnast _ points."

My Solution:

scores = (1,2,3,4,5,6,7,8,9,10)

for num in scores:
    print('A judge can give a gymnast %d points.' % (num))

Output:

A judge can give a gymnast 1 points.  
A judge can give a gymnast 2 points.
A judge can give a gymnast 3 points.
A judge can give a gymnast 4 points.
A judge can give a gymnast 5 points.
A judge can give a gymnast 6 points.
A judge can give a gymnast 7 points.
A judge can give a gymnast 8 points.
A judge can give a gymnast 9 points.
A judge can give a gymnast 10 points.

How can I change the first line so that it becomes grammatically correct "A judge can give a gymnast 1 point"?

2 Answers 2

1

You can use f-strings from python 3.6:

scores = (1,2,3,4,5,6,7,8,9,10)

for num in scores:
    print(f'A judge can give a gymnast {num} point{"s" if num > 1 else ""}.')

Output:

A judge can give a gymnast 1 point.
A judge can give a gymnast 2 points.
A judge can give a gymnast 3 points.
A judge can give a gymnast 4 points.
A judge can give a gymnast 5 points.
A judge can give a gymnast 6 points.
A judge can give a gymnast 7 points.
A judge can give a gymnast 8 points.
A judge can give a gymnast 9 points.
A judge can give a gymnast 10 points.
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very much for your feedback.
1

You can use a conditional expression to only add the 's' to 'point' if the number is greater than 1. Also note that using range() is neater than manually typing the scores and .format better than a % (especially when doing multiple formats).

for num in range(1, 11):
    print('A judge can give a gymnast {} point{}.'.format(num, 's' if num > 1 else ''))

which gives:

A judge can give a gymnast 1 point.
A judge can give a gymnast 2 points.
A judge can give a gymnast 3 points.
A judge can give a gymnast 4 points.
A judge can give a gymnast 5 points.
A judge can give a gymnast 6 points.
A judge can give a gymnast 7 points.
A judge can give a gymnast 8 points.
A judge can give a gymnast 9 points.
A judge can give a gymnast 10 points.

1 Comment

Thank you very much for your help :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.