Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PYTHON QNS. I need help with this python qns, would appreciate if someone can he

ID: 3743201 • Letter: P

Question

PYTHON QNS. I need help with this python qns, would appreciate if someone can help me solve it, THANK YOU IN ADVANCE!

3.(a) Demonstrate how you implement top-down design to the problem, showing at least 3 levels of refinement. Show also the final set of functions derived from your top-down design in a structure chart.

(b) Implement your solution based on your structure chart in part Q3(a) and specify the order in which you test your functions.

*USE WITHOUT DICTIONARY DATA TYPE*

Question 3 Develop a simple game application without using the data type dictionary. Allovw any number of players to play MasterMind together For the game design and implementation, you must adhere to the following constraints Start the application by asking the user how many players will be playing MasterMind and the names of the players Before each new game commences, the application randomly generates a hidden code To generate the hidden code, the application makes 4 random choices to pick 4 different colors from 6 colors (stored as a string "RGBYOP" The letters represent the 6 distinct colors: Red, Green, Blue, Yellow, Orange and Purple. The random choices are stored as a single string e.g. "YBRP" Players take turns to make a guess, the order follows the order the names are entered. When it is a player's turn, he guesses the colors and positions of the hidden code. The guess is read as a string and consists of 4 letters e.g., "BORY". The result of his guess is displayed before the next player takes his turn. Show both the before and after score of a player after his guess is checked The next player then takes his turn, each guess is checked and the score updated, until the game ends when the hidden code is broken, that is, a player gets 4 black pins. At the end of each game, print out the details of the players and list the winner(s). The output should be shown on both screen and file The players can repeatedly decide whether to play another game of MasterMind. If the players decide to stop play, print out the players with the most number of games won. The output should be shown on both screen and file

Explanation / Answer

Answer:

Demonstration of how you implement top-down design to the problem and 3 levels of refinement also the final set of functions

derived from top-down design in a structure chart.

import pythongame

from pythongame.locals

import *pythongame.int()

int no.of players();

screen=pythongame.visible_players((number, //to show the name of players

player name = pythongame.name("master mind players")

visual.display(0) //clear the screen before naming

  

visual.name(player, (master mind))

  

pythongame.display.visual()

//generates hidden code

for app in pythongame.application.get():

  

if event.type==pythongame.QUIT://check whether displays

  

pythongame.quit() //if it hides

exit(0)

random = pythongame.visual.display("RGBYOP")

distinct = pythongame("stored sting YBRP")

//generation of hidden code

for code hidden(stored as string RGBYOP):

visual.display()

display(string,(names entered)//guess the colour position of the hidden cide

red as a string = [BORY]

playerNEXT=[BEF(),AFT()] //shows before and after score

visual.display(player, guess check) //player guess his checks

if hidden.code == pythongame.KEYDOWN(broken):

if event.key==K_w:

keys[0]=True(display)

//output shown both in screen and file

position = pythongame.repeatget_pos()

//decide to play other game repeatedly

repeat = play.game(position[1]-(playerpos[1])//earns white pin

wrong position= pythongame.transform.rotate(player,1pt,) //wrong position game

playerpos1 = (playerpos[0]-playerrot.get_displays(wwb).(right colour,right position)

visual.display(playerrot, player(bp(0)) //best performance for blackpins is 0

for end game(add):

index=0

blackpin(add)=game.won(breaks[0]//player won the game

blackpin=game.add(break[0]) //has no additional pin

game[1]+=points()

//decides to stop the game

if player[0] game=[0]blackpin:

game.player()

//to show both screen and file

for player stops:

game = pythongame.player

stop()

Implementation of solution based on structure chart.

Hope you understand and this helps you.All the best