An athlete is taking rounds of a triangular park with sides as 30 m, 25 m and 35 m.

This question can be found in PriP 1.2, Data HandlingClass 12 Computer Science with Python by Sumita Arora is referred to in schools affiliated to but not limited to CBSE. Question numbers can vary according to the book edition.

Q13. An athlete is taking rounds of a triangular park with sides of 30 m, 25 m and 35 m. The athlete has run 560 m till now. Write a program to print how many rounds of the park the athlete has completed.

Determining the number of rounds completed by the athlete needs one to calculate the perimeter of the triangle. That would be the total distance of one complete round if made around the park.

Further, we need to calculate how many rounds the athlete might have completed if he has run 560 m till now. So, follow the steps.

Steps to Calculate

  1. Calculate the perimeter of the triangle:
    Perimeter = Side1 + Side2 + Side3
  2. Determine how many rounds the athlete has completed:
    Rounds = Distance run / Perimeter
    where Distance run = 560 m.

Python Program

Next, you can work with translating the formula to python code. That’s simple to do here.

Python
# Side lengths of the triangular park
side1 = 30
side2 = 25
side3 = 35

# Distance run by the athlete
distance_run = 560

# Calculate the perimeter of the triangular park
perimeter = side1 + side2 + side3

# Calculate the number of rounds completed
rounds_completed = distance_run / perimeter

# Print the result
print(f"The athlete has completed {int(rounds_completed)} rounds of the park.")

Code Review

  1. Side Lengths: We define the lengths of the three sides of the triangular park.
  2. Distance Run: We set the total distance the athlete has run.
  3. Perimeter Calculation: calculating the perimeter by adding the lengths of the three sides is easy.
  4. Rounds Calculation: Dividing the total distance run by the perimeter can help determine the number of rounds the athlete has completed.
  5. Output: The program prints the number of rounds completed, formatted to an integer to show only full rounds completed by the athlete.

Example Usage and Output

This output indicates that the athlete has completed 6 full rounds around the triangular park. This question is among the easiest in python if you really are in class 12 :p. Well, no doubt about that.

Output
The athlete has completed 6 full rounds of the park.
"Spread the light within, illuminate the hearts around you. Sharing is not just an action, but a sacred journey of connecting souls."~ Anonymous

Leave a Reply

Your email address will not be published. Required fields are marked *