Python is a multipurpose language and one can do literally anything with it. Python can also be used for game development. Let’s create a simple Jumbled word game without using any external game libraries like PyGame.
Jumbled word game : Jumbled word is given to player, player has to rearrange the characters of the word to make a correct meaningful word.
Input: erwta Output: water Input: mehtatasmci Output: mathematics Input: keseg Output: geeks
This is a two players game, firstly program pick a random word from the given list of words using choice() method of
random module. After shuffling the characters of picked word using sample method of random module and shows the jumbled word on the screen. Current player should give the answer; if it gives the correct answer after rearranging the characters then player’s score is incremented by one otherwise not. After quitting the game, winner is decided on the basis of scores.
Using Inbuilt functions :
choice() method randomly choose any word from the list. sample() method shuffling the characters of the word.
User defined functions :
choose() : Choosing random word from the list .
jumble() : Shuffling the characters of the choosen word. we have to pass a choosen word as an argument.
thank() : Showing the final scores of both players. Pass a player1 name, player2 name and score of player1, player2 as an argument.
check_win() : Declaring the winner. Pass a player1 name, player2 name, and score of player1 and player2 as argument.
play() : Starting the game.
Below is the implementation :
player 1, Please enter your name :Ankit Player 2 , Please enter your name: John jumbled word is : abiwrno Ankit Your Turn. what is in your mind? rainbow Your score is : 1 jumbled word is : rbado John Your turn. what is in your mind? borad Better luck next time.. : Ankit Your turn. what is in your mind? board Your Score is : 2 press 1 to continue and 0 to quit :1 jumbled word is : wbrinao John Your turn. what is in your mind? rainbow Your Score is : 1 press 1 to continue and 0 to quit :1 jumbled word is : bnrawio Ankit Your Turn. what is in your mind? rainbow Your score is : 3 jumbled word is : enecsic John Your turn. what is in your mind? science Your Score is : 2 press 1 to continue and 0 to quit :0 Ankit Your score is : 3 John Your score is : 2 winner is : Ankit Thanks for playing...
- Python | Program to implement simple FLAMES game
- Python | Program to implement Rock paper scissor game
- Python program for word guessing game
- Python program to remove Nth occurrence of the given word
- Python | Program that matches a word containing 'g' followed by one or more e's using regex
- Implement IsNumber() function in Python
- Program to replace a word with asterisks in a sentence
- Implement your own word2vec(skip-gram) model in Python
- Hangman Game in Python
- Hangman Game in Python
- 21 Number game in Python
- Mastermind Game using Python
- Python - Get Nth word in given String
- Python | Word Stretch
- Number guessing game in Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : Shivam_k