Ejemplo n.º 1
0
def show_poll_votes(connection):
    poll_id = int(input("Enter poll you would like to see votes for: "))
    try:
        # This gives us count and percentage of votes for each option in a poll
        poll_and_votes = database.get_poll_and_vote_results(connection, poll_id)
    except DivisionByZero:
        print("No votes yet cast for this poll.")
    else:
        for _id, option_text, count, percentage in poll_and_votes:
            print(f"{option_text} got {count} votes ({percentage:.2f}% of total)")
Ejemplo n.º 2
0
def show_poll_votes(connection):
    poll_id = int(input("Enter poll you would like to see votes for: "))
    try:
        poll_and_votes = database.get_poll_and_vote_results(
            connection, poll_id)
    except DivisionByZero:
        print("No votes yet cast for this poll.")
    else:
        for result in poll_and_votes:
            print(
                f"{result[1]} got {result[2]} votes ({result[3]:.2f}% of total)"
            )