Question

Use the jumble function to write a program jumbleguess.py that chooses a secret word from a...

Use the jumble function to write a program jumbleguess.py that chooses a secret word from a dictionary,prints a scrambled version of the word,and then asks the user to guess the secret word. Count the number o

1.Write a function jumble (word) that returns a scrambled version of the word from (as a string) by randomly permuting its letters.

2. Use the jumble function from the previous exercise to write a program jumbleguess.py that chooses a secret word from a dictionary, prints a scrambled version of the word, and then asks the user to guess the secret word. Count the number of guesses used.

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

Explanation:

Code in python is given below

An dictionary is created with some words in it

User is asked to enter word until he/she do not enter correct word

CODE IN PYTHON:

import string, random, re

dictionary=["yellow","watermelon","banana","computer","window"]

def jumble(secretWord):

  listWord=list(secretWord)

  random.shuffle(listWord)

  return ''.join(listWord)

def main():

  guessCount=1

  index = random.randint(0,len(dictionary))

  secretWord = jumble(dictionary[index])

  correctWord =dictionary[index]

  print("The secret word is ",secretWord)

  print("\n")

  while True:

    guess=input("Enter your guess :")

    if guess == correctWord:

      print("Correct Word !!")

      print("You took",guessCount,"guess count(s)")

      break

    else:

      print("The guess is wrong!")

      guessCount=guessCount+1

  

if __name__ == "__main__":

  main()

  

  

  

OUTPUT:

The secret word is romtecup

Enter your guess :comp

The guess is wrong!

Enter your guess :sadhjasd

The guess is wrong!

Enter your guess :computer

Correct Word !!

You took 3 guess count(s)

Add a comment
Know the answer?
Add Answer to:
Use the jumble function to write a program jumbleguess.py that chooses a secret word from a...
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
  • using c++ program write this program without the optional exercise 3. Word Counter Write a function...

    using c++ program write this program without the optional exercise 3. Word Counter Write a function that accepts a pointer to a C-string as an argument and returns the number of words contained in the string. For instance, if the string argument is "Four score and seven years ago” the function should return the number 6. Demonstrate the function in a program that asks the user to input a string and then passes it to the func tion. The number...

  • For this lab you will write a Java program that plays a simple Guess The Word...

    For this lab you will write a Java program that plays a simple Guess The Word game. The program will prompt the user to enter the name of a file containing a list of words. These words mustbe stored in an ArrayList, and the program will not know how many words are in the file before it starts putting them in the list. When all of the words have been read from the file, the program randomly chooses one word...

  • Do in Python please provide screenshots aswell. Here are the requirements for your game: 1. The...

    Do in Python please provide screenshots aswell. Here are the requirements for your game: 1. The computer must select a word at random from the list of avail- able words that was provided in words.txt. The functions for loading the word list and selecting a random word have already been provided for you in ps3 hangman.py. 2. The game must be interactive; the flow of the game should go as follows: • At the start of the game, let the...

  • ***How do I insert the Halloween text into this and write the program**** Topics: List, tuple...

    ***How do I insert the Halloween text into this and write the program**** Topics: List, tuple In this lab, you will write a scrambled word game.  The game starts by loading a file containing scrambled word-answer pair separated.  Sample of the file content is shown below.  Once the pairs are loaded, it randomly picks a scrambled word and has the player guess it.  The number of guesses is unlimited.  When the user guesses the correct answer, it asks the user if he/she wants another scrambled...

  • Overview In this exercise you are going to recreate the classic game of hangman. Your program...

    Overview In this exercise you are going to recreate the classic game of hangman. Your program will randomly pick from a pool of words for the user who will guess letters in order to figure out the word. The user will have a limited number of wrong guesses to complete the puzzle or lose the round. Though if the user answers before running out of wrong answers, they win. Requirements Rules The program will use 10 to 15 words as...

  • Using Python 3+ for Question P5.9 Instructions: Use one main() to call each of the functions...

    Using Python 3+ for Question P5.9 Instructions: Use one main() to call each of the functions you created. Only use one value of r and h for all the function. Ask the user for the r and h in the main() as an input, and h for all the functions. You should put the functions for areas in a separate file. ​ For example, firstDigtec7ze Write a function e digits n) (returning the number of digits in the argument returning...

  • Create a new program, WordGuessingGame. Using a while loop, create a game for the user. The...

    Create a new program, WordGuessingGame. Using a while loop, create a game for the user. The game requires the user to guess a secret word. The game does not end until the user guesses the word. After they win the game, they are prompted to choose to play again. The secret word that user must guess is "valentine". It is a case-sensitive analysis With each guess... If the guess does not have an equal number of characters, tell the user...

  • 2. Create the program guessgame.py discussed in the video in module 1. Make sure you can...

    2. Create the program guessgame.py discussed in the video in module 1. Make sure you can run it without syntax errors.3. Modify that program so that the user is asked to think of a secret number and the computer guesses that number. Here is the interaction: 1. The computer asks the user for the range.2. The user inputs the lowest and highest numbers in the range. The USER thinks of a secret number in that range. 3. The computer tries...

  • Write a program that allows a user to play a guessing game. Pick a random number...

    Write a program that allows a user to play a guessing game. Pick a random number in between 1 and 100, and then prompt the user for a guess. For their first guess, if it’s not correct, respond to the user that their guess was “hot.” For all subsequent guesses, respond that the user was “hot”if their new guess is strictly closer to the secret number than their old guess and respond with“cold”, otherwise. Continue getting guesses from the user...

  • Write a Java application program that plays a number guessing game with the user. In the...

    Write a Java application program that plays a number guessing game with the user. In the starter code that you are given to help you begin the project, you will find the following lines of code: Random generator = args.length == 0 ? new Random() :                    new Random(Integer.parseInt(args[0])); int secret = generator.nextInt(100); You must keep these lines of code in your program. If you delete these lines, or if you change thse lines in any way, then your program...

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