@OathOfCode/

Guess the number

Python

This game is made for the Game Jam! I know it's not that impressive but I'm new in python! I can do other things too! Check out my profile

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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import random
n = random.randint(1, 50)
guess = int(input("Guess a number from 1 to 50: "))
c = 0
while (n != "guess"):
    if (guess < 1):
        print("The number you have entered is out of range!")
        c = c + 1
        break
    elif (guess > 50):
        print("The number you have entered is out of range!")
        c = c + 1
        break
    elif (guess < n):
        print ("Guess is too low")
        guess = int(input("Guess a number from 1 to 50: "))
        c = c + 1
    elif (c == 1):
        print("YOUR A GOD!")
    elif guess > n:
        print ("Guess is too high")
        guess = int(input("Guess a number from 1 to 50: "))
        c = c + 1
    else:
        print ("You guessed the number!")
        c = c + 1
        break
print("You have guessed " + str(c) + " times!")
q1 = input("Would you like to play again?\nY/N")
if (q1 == "y" or q1 == "Y"):
	n = random.randint(1, 50)
	guess = int(input("Guess a number from 1 to 50: "))
	c = 0
	while (n != "guess"):
	    if (guess < 1):
	        print("The number you have entered is out of range!")
	        c = c + 1
	        break
	    elif (guess > 50):
	        print("The number you have entered is out of range!")
	        c = c + 1
	        break
	    elif (guess < n):
	        print ("Guess is too low")
	        guess = int(input("Guess a number from 1 to 50: "))
	        c = c + 1
	    elif (c == 1):
	        print("YOUR A GOD!")
	    elif guess > n:
	        print ("Guess is too high")
	        guess = int(input("Guess a number from 1 to 50: "))
	        c = c + 1
	    else:
	        print ("You guessed the number!")
	        c = c + 1
	        break
	print("You have guessed " + str(c) + " times.\nDone.")
	q1 = input("Would you like to play again?\nY/N")
	if (q1 == "y" or q1 == "Y"):
		n = random.randint(1, 50)
		guess = int(input("Guess a number from 1 to 50: "))
		c = 0
		while (n != "guess"):
		    if (guess < 1):
		        print("The number you have entered is out of range!")
		        c = c + 1
		        break
		    elif (guess > 50):
		        print("The number you have entered is out of range!")
		        c = c + 1
		        break
		    elif (guess < n):
		        print ("Guess is too low")
		        guess = int(input("Guess a number from 1 to 50: "))
		        c = c + 1
		    elif (c == 1):
		        print("YOUR A GOD!")
		    elif guess > n:
		        print ("Guess is too high")
		        guess = int(input("Guess a number from 1 to 50: "))
		        c = c + 1
		    else:
		        print ("You guessed the number!")
		        c = c + 1
		        break
		print("You have guessed " + str(c) + " times.\nDone.")
		print("Thanks for playing!")
	if (q1 == "n" or q1 == "N"):
		print("Thanks for playing!")
if (q1 == "n" or q1 == "N"):
	print("Thanks for playing!")