Python: A Very Simple Guessing Game Dedicated For Beginners
In this tutorial we will create a very simple Guessing Game Using Python Programming. Python lets you work more quickly than other programming languages.It is very easy to learn syntax emphasizes readability and reduces time consuming in developing. In Python you don't have to worry about a miss semi colon, because it is not necessarily needed in python. So let now start the coding...
First you will have to download & install the Python IDLE's, here the link for the Integrated Development And Learning Environment for python https://www.python.org/downloads/
After you installed the Pythons IDLE's, run the IDLE and then click file and then new file. After that a new window will appear containing a black file this will be the text editor for the python
To Start with The Game
This script will gain access to the code in another module called 'random'. We will use this module to make the word random
- import random
Making the random choice of words
- print('**************Guess The Programming Language Game**************\n') #title of the game
- answer = random.choice(Plangs) #this will randomly pick the word from an array
- correct = answer #If the has been picked the word will into a new variable
- rumble = "" #creating a new variable
The Logic of the game
- while answer: #check if answer is true
- position = random.randrange(len(answer)) #get the range of the word
- rumble += answer[position] #then rumble the word of choice
- answer = answer[:position] + answer[(position + 1):] #rearrange the rumble words
- print("The Word Is:", rumble) # display the jumble word
- guess = input("Guess This Programming Language:") #create a input for answering the guess word
- guess = guess.lower() #lowercase the jumble word
- while (guess != correct) or (guess == ""): # check if the given answer is incorrect
- print("That is not the correct answer")
- print("\nThe Word Is:", rumble)
- guess = input("Guess This Programming Language:")
- guess = guess.lower()
- if guess == correct: #check if the answer is correct
- print("\nCongratulation You Win!")
- input("\n\n Press enter to exit")
There you have it we created a very simple game for Python Programming. I hope that you learn something from this tutorial. For more updates and tutorials just kindly visit this site. Enjoy Coding!!
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.