Python: A Very Simple Guessing Game Dedicated For Beginners

Language
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... Getting started: 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
  1. import random
Making the random choice of words
  1. print('**************Guess The Programming Language Game**************\n') #title of the game
  2.  
  3. Plangs = ("python", "php", "javascript", "c", "perl", "c++", "java", "ruby", "c#", "visual basic", "fortran") #this will be the array word for the guess game
  4.  
  5. answer = random.choice(Plangs) #this will randomly pick the word from an array
  6.  
  7. correct = answer #If the has been picked the word will into a new variable
  8.  
  9. rumble = "" #creating a new variable
The Logic of the game
  1. while answer: #check if answer is true
  2.     position = random.randrange(len(answer)) #get the range of the word
  3.     rumble += answer[position] #then rumble the word of choice
  4.     answer = answer[:position] + answer[(position + 1):] #rearrange the rumble words
  5.  
  6. print("The Word Is:", rumble) # display the jumble word
  7.  
  8. guess = input("Guess This Programming Language:") #create a input for answering the guess word
  9. guess = guess.lower() #lowercase the jumble word
  10.  
  11. while (guess != correct) or (guess == ""): # check if the given answer is incorrect
  12.     print("That is not the correct answer")
  13.     print("\nThe Word Is:", rumble)
  14.     guess = input("Guess This Programming Language:")
  15.     guess = guess.lower()
  16.  
  17. if guess == correct: #check if the answer is correct
  18.     print("\nCongratulation You Win!")
  19.     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.

Tags

Add new comment