Question

A video game club at the community center hosts a tournament. The total number of participants...

A video game club at the community center hosts a tournament. The total number of participants is 30. Write pseudocode for a python program that takes in input the name of the player and the number of points each player got total and display the top 3 players’ scores.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

PSEUDOCODE

A function getTopPlayer which has four paramters (all lists): names, points, topNames and topPoints
   Get maximum points from list of points using max(built-in function) and store it in top variable
   Get index of that top (highest) points from topPoints list
   Append name (that is found at index in names list) in topNames list
   Append points (that is found at index in points lits) in topPoints list
   Remove name at that index from names list using pop (built-in function) of list
   Remove points at that index from points list using pop(built-in function) of list

create an empty list named 'playerNames' to store names of players entered by user
create an empty list named 'playerPoints' to store number of points for each player entered by user
create an empty list named 'topPlayerNames' to store names of top three players
create an empty list named 'topPlayerPoints' to store points of top three players

for i=0 to 30:
   print the player number
   Take input 'Enter name of player: ' and store it in variable name
   Append that name in the playerNames list
   Take input 'Enter number of points: ' and store it in points variable
   Append that points in the playerPoints list

print 'The Top Three Players'

for i=0 to 3:
   calling getTopPlayer function with passing playerNames, playerPoints, topPlayerNames and topPlayerPoints as paramters
   print 'Player#' and name of player using topPlayerNames[i] and points using topPlayerPoints[i]
     

PROGRAM CODE (Proof Pseudocode is working!!)

def getTopPlayer(names = [], points = [], topNames =[], topPoints = []):

# Getting index where points are highest because later to display that top player name and score

top = max(points)
index = points.index(top)

topNames.append(names[index])
topPoints.append(points[index])

# Removing that top player name as well as points because next time to get further top player with highest points

names.pop(index)
points.pop(index)

# A list of Player names and their points

playerNames = []
playerPoints = []
topPlayerNames = []
topPlayerPoints = []

# Taking input name of 5 players instead of 30 as a sample

for i in range(5):
print("---Player#", i+1, "---")

name = input("Enter name of player: ")
points = input("Enter number of points: ")

playerNames.append(name)
playerPoints.append(points)

# Showing top 3 Player names stored in topPlayerNames and topPlayerPoints lists

print('\nThe top three players')

for i in range(3):

# Calling getTopPlayer function
getTopPlayer(playerNames, playerPoints, topPlayerNames, topPlayerPoints)

print('(Player#', (i+1), ')-> Name: ', topPlayerNames[i], ', Points: ', topPlayerPoints[i])

PROGRAM CODE SCREEN SHOT

def getTopPlayer(names[], points.bl, topNames topPoints ...): # Getting index where points are highest because later to displ

playerNames.append(name) playerPoints.append(points) # Showing top 3 Player names stored in topPlayerNames and topPlayerPoint

SAMPLE OUTPUT

Player C:\Users\Dell\anaconda3\envs\MRS\python.exe C:/Users/Dell/Downloads/AI Project/MRS/Player ---Player# 1 Enter name of

-------------------------------------------------------------------------------------------------------------


COMMENT DOWN FOR ANY QUESTIONS...........
HIT A THUMBS UP IF YOU DO LIKE IT!!!

Add a comment
Know the answer?
Add Answer to:
A video game club at the community center hosts a tournament. The total number of participants...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • The the results or the golf tournament played at the end of March. The Club president...

    The the results or the golf tournament played at the end of March. The Club president Mr. Martin has asked you to write two programs. Country Club has asked you to write a program to gather, then display The first program will input each player's first name, last name, handicap and golf score and then save these records in a file named golf.txt (each record will have field for the first name, last name, handicap and golf score). The second...

  • The Springfork Amateur Golf Club has a tournament every weekend. The club president has asked you...

    The Springfork Amateur Golf Club has a tournament every weekend. The club president has asked you to write a program that will read each player's name and score as keyboard input, and then save these as records in a file named golf.txt. First, have the program ask the user how many players they want to add to their record. Then, ask the user for each name and score individually. golf.txt should be structured so that there is a line with...

  • There are three basketball players, A, B, and C. A takes 30 shots a game, with...

    There are three basketball players, A, B, and C. A takes 30 shots a game, with a shooting percentage of 70%. B takes 20 shots, hitting 60%, and C takes 10 shots, hitting 50%. Write a program in java or python. Use the above statement to simulate players A, B, and C in a season of 82 games. Generate a string of shots for each player in each game, length 30, 20, and 10 shots. Count the number of shots...

  • Write a Python program (rock_paper_scissors.py) that allows two players play the game rock paper scissors. Remember...

    Write a Python program (rock_paper_scissors.py) that allows two players play the game rock paper scissors. Remember the rules: 1. Rock beats scissors 2. Scissors beats paper 3. Paper beats rock The program should ask the users for their names, then ask them for their picks (rock, paper or scissors). After that, the program should print the winner's name. Note, the players may pick the same thing, in this case the program should say it's tie. when the user input an...

  • Python Program Python: Number Guessing Game Write a Python function called "Guess.py" to create a number...

    Python Program Python: Number Guessing Game Write a Python function called "Guess.py" to create a number guessing game: 1. Function has one input for the number to Guess and one output of the number of attempts needed to guess the value (assume input number will always be between 1 and 1000). 2. If no number was given when the function was called, use random.randint(a,b) to generate a random number between a=1 and b=1000. You will also need to add an...

  • C or C++ Project Overview Wild, Wild, West! Dice Game The Wild, Wild, West! is an...

    C or C++ Project Overview Wild, Wild, West! Dice Game The Wild, Wild, West! is an elimination dice game. It can be played by any number of players, but it is ideal to have three or more players. Wild, Wild, West! Requires the use of two dice. At the start of the game, each player receives a paper that will track the number of lives that player has. Each player starts the game with 6 lives. In the first round,...

  • JAVA We will write a psychic game program in which a player guesses a number randomly...

    JAVA We will write a psychic game program in which a player guesses a number randomly generated by a computer. For this project, we need 3 classes, Player, PsychicGame, and Driver. Description for each class is as following: Project Folder Name: LB05 1. Player class a.Input - nickName : nick name of the player - guessedNumber : a number picked for the player will be assigned randomly by a computer later. b. Process - constructor: asks a user player’s nickName...

  • Two player Dice game In C++ The game of ancient game of horse, not the basketball...

    Two player Dice game In C++ The game of ancient game of horse, not the basketball version, is a two player game in which the first player to reach a score of 100 wins. Players take alternating turns. On each player’s turn he/she rolls a six-sided dice. After each roll: a. If the player rolls a 3-6 then he/she can either Roll again or Hold. If the player holds then the player gets all of the points summed up during...

  • JAVA program. I have created a game called GuessFive that generates a 5-digit random number, with...

    JAVA program. I have created a game called GuessFive that generates a 5-digit random number, with individual digits from 0 to 9 inclusive. (i.e. 12345, 09382, 33044, etc.) The player then tries to guess the number. With each guess the program displays two numbers, the first is the number of correct digits that are in the proper position and the second number is the sum of the correct digits. When the user enters the correct five-digit number the program returns...

  • Assignment 2 – The two player game of Poaka The game of Poaka is a dice...

    Assignment 2 – The two player game of Poaka The game of Poaka is a dice game played by two players. Each player takes turns at rolling the dice. At each turn, the player repeatedly rolls a dice until either the player rolls a 1 (in which case the player scores 0 for their turn) or the player chooses to end their turn (in which case the player scores the total of all their dice rolls). At any time during...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT