@TheFlooBearer/

Python Guessing Game Exercise

Python

Just a test of the random variable.

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import random
import math
import time


number = random.randint(1, 10)
number1 = str(number)
tries = 3
tries1 = str(tries)


uname = input("Hello, what is your username? \n")

print ("Hello, " +uname+ "." ,)

enter= input("Would you like to play this game (Guess the number)? (Y for yes, N for no.)\n")



if enter == "Y":
    print ("Welcome then, let us begin.")
    time.sleep(1)
    guess = input("Enter your number, pick wisely, out of ten.\n")


    if int(guess) == number:
        print ("Congrats! You won! the number was "+number1+". Come again!")
        time.sleep(5)
    if int(guess)!= number and tries>=1:
        print ("\n Tries left:"+str(tries))
        guess= input("Agh! So close. Try again \n")
        tries: int = tries - 1


        if int(guess) == number:
            print ("Congrats! You have won! \n", "Your score is "+tries1 +". Rerun the program to do it again!")
            time.sleep(5)
        if int(guess) != number and tries >= 1:
            print("\n Tries left:" + str(tries))
            guess = input("Agh! So close. Try again\n")
            tries: int = (tries - 1)


            if int(guess) == number:
                print ("Congradulations! Your score is "+tries1+". Rerun the program to do it again!")
                time.sleep(5)
            if int(guess) != number and tries >= 1:
                print("\n Tries left:" + str(tries))
                guess = input("Agh! So close. Try again\n")
                tries: int = tries - 1


                if int(guess) != number:
                    print ("Boo hoo.. you lost. Rerun the program though!")
                    print ("\n The answer was "+number1)
                    time.sleep(5)
                if int(guess) == number:
                    print ("Congrats! You have won! You don't have a score you did so bad. Come "," again!")
                    time.sleep(5)
                    
if enter != "Y":
    print ("Either, you don't want to play, or you entered another number.")