Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Below is my code from Lab Assignment 6: from random import shuffle, randint #module used to create a random number used to later shuffle the

image text in transcribed

Below is my code from Lab Assignment 6:

from random import shuffle, randint #module used to create a random number used to later shuffle the words up def scrambled_word(word): #defining an initial function to shuffle the words word = list(word) #converts the word variable into a list to better be read shuffle(word) #now that this variable is converted into a list, it can be rearranged using the shuffle method return ''.join(word) #returns the words using the .join method. Although not learned from the book, I found the shuffle and join method #much easier to use for this assignment than attempting to use other methods. def main(): #defining my main function score = 0 #setting the overall score print(""" Rules of the Game ---------------------------------------------------------------------------- * You will be given a scrambled word * You have three attemps at a correct guess! * If at any point you need a hint, simply type "Hint" *If you are still stumped, use another hint! It may offer new information! * If you wish to exit the game, type "quit" """) #printing out the initial rules to the user score = guess_game(score) print("Your current score is :", score, "Nice Job!") def guess_game(score): #defining the next function, that being the guessing game itself dict = {} #beginning with an empty dict size = 0 with open('words.txt') as fp: #opening the .txt document as an fp, allowing the program to open, read, and close the file for line in fp: word_to_guess, hint = line.split(':') #allows the program to differentiate between the word and the description hint = hint.split(',') #splits the description into chunks, so the user can have more than one hint #while this doesn't really work with the given input file set up, I felt it could improve the program #Allows for multiple hints to be used, given the correct input file dict[word_to_guess] = hint #adds this hint system to dict for word_to_guess, val in dict.items(): #using the dictionary items() method to return "word_to_guess" (key) count = 1 letter_switch = scrambled_word(word_to_guess) while letter_switch == word_to_guess: letter_switch = scrambled_word(word_to_guess) #confirms that the scrambled word is not the same as the word to guess for the user print('The Word to Guess is: ' + letter_switch) print() while (count = 3): return score #if at any point the user guesses more than 3 times on a single word, the game ends and the score is displayed main() #calls and ends the main function
In this lab assignment, you are going to develop a GUI application using Python Tinter package. Description: Using tkinter, create a GUI (Graphical User Interface) for the "Scrambled Words" game that you have previously developed in the lab assignment 6 Requirements: Only use tkinter widgets (do not use other libraries) Display all the information on the game window (No input/output from or to the console) Provide instant feedback for every interaction Use tkinter grid to organize your widgets All buttons and controllers must work properly Note: check the sample program provided for getting and setting string variables In this lab assignment, you are going to develop a GUI application using Python Tinter package. Description: Using tkinter, create a GUI (Graphical User Interface) for the "Scrambled Words" game that you have previously developed in the lab assignment 6 Requirements: Only use tkinter widgets (do not use other libraries) Display all the information on the game window (No input/output from or to the console) Provide instant feedback for every interaction Use tkinter grid to organize your widgets All buttons and controllers must work properly Note: check the sample program provided for getting and setting string variables

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Database Modeling With Neo4j

Authors: Ajit Singh

2nd Edition

B0BDWT2XLR, 979-8351798783

More Books

Students also viewed these Databases questions

Question

1. Who will you assemble on the team?

Answered: 1 week ago

Question

Did the team members feel that their work mattered

Answered: 1 week ago