Професионална програма
Loading...
ItsMomchilS avatar ItsMomchilS 28 Точки

Judge Exam Exercise

Здравейте, бих искал да попитам. Ако знаете как да реша тази задача по-правилно, защото все получавам 80/100, а не знам къде трябва да е проблема. 

Тя е от задачите на Programming Basics Online Exam - 27 and 28 July 2019

Благодаря, предварително!

Ето я програмата:

import math

player_name = input()
played_games = int(input())

game_percent = 0
volleyball_sum = 0
tennis_sum = 0
badminton_sum = 0
win = False

for games in range(0, played_games):
    game_name = input()
    points_won = int(input())

    if game_name == "volleyball":
        game_percent = 7
        points_won = ((points_won / 100) * 7) + points_won
        volleyball_sum += points_won

    elif game_name == "tennis":
        game_percent = 5
        points_won = ((points_won / 100) * 5) + points_won
        tennis_sum += points_won

    elif game_name == "badminton":
        game_percent = 2
        points_won = ((points_won / 100) * 2) + points_won
        badminton_sum += points_won

if badminton_sum >= 75 and tennis_sum >= 75 and volleyball_sum >= 75:
    win = True

sum_points_won = math.floor(volleyball_sum + tennis_sum + badminton_sum)

if win:
    print(f"Congratulations, {player_name}! You won the cruise games with {sum_points_won} points.")

elif not win:
    print(f"Sorry, {player_name}, you lost. Your points are only {sum_points_won}.")

 

0
en.yaneva avatar en.yaneva 2 Точки

Здравей, ето ти моето решение на задачата. Няма да е лошо  друг път да опеменаваш и името на задачата, за да е намират колегите по-лесно ;)


import math
player_name = input()
played_games = int(input())

counter_v = 0
counter_t = 0
counter_b = 0
volleyball_points = 0
tennis_points = 0
badminton_points = 0

for x in range(played_games):
    game_name = input()
    points = int(input())

    if game_name == "volleyball":
        volleyball_points += points * 1.07
        counter_v += 1

    elif game_name == "tennis":
        tennis_points += points * 1.05
        counter_t += 1

    elif game_name == "badminton":
        badminton_points += points * 1.02
        counter_b += 1

end_points_volleyball = math.floor(volleyball_points / counter_v)
end_points_tennis = math.floor(tennis_points / counter_t)
end_points_badminton = math.floor(badminton_points / counter_b)
total_points = math.floor(volleyball_points + tennis_points + badminton_points)

if end_points_volleyball >= 75 and end_points_tennis >= 75 and end_points_badminton >= 75:
    print(f"Congratulations, {player_name}! You won the cruise games with {total_points} points.")
else:
    print(f"Sorry, {player_name}, you lost. Your points are only {total_points}.")


0
ItsMomchilS avatar ItsMomchilS 28 Точки

Да, благодаря ти за коментара. Не е било нарочно, че не съм казал задачата. Явно не съм се усетил, но благодаря все пак!

0
en.yaneva avatar en.yaneva 2 Точки

Да, знам :) това бешe просто съвет... Дано съм успяла да ти помогна да намериш грешката. 

0