-
Notifications
You must be signed in to change notification settings - Fork 6.4k
/
Copy pathPYTHONCODE.py
71 lines (58 loc) · 1.7 KB
/
PYTHONCODE.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
from tkinter import *
import random
from tkinter import messagebox
real_word = [
"GOAT",
"BOAT",
"RAIN",
"CODE",
"DISH",
"FISH",
"WASH",
"HAIR",
"NOSE",
"HAND"]
jumbled_word=[
"AOGT",
"TOAB",
"INRA",
"DECO",
"DHIS",
"SHFI",
"SWAH",
"IRHA",
"SENO",
"NDHA"]
options = random.randrange(0,len(jumbled_word),1)
def one():
global jumbled_word, real_word,options
lbl1.config(text=jumbled_word[options])
def answer():
global jumbled_word,real_word,options
options=random.randrange(0,len(jumbled_word),1)
lbl1.config(text=jumbled_word[options])
e1.delete(0,END)
def correct():
global jumbled_word,real_word,options
one_var=e1.get()
if one_var==real_word[options]:
messagebox.showinfo("congratulations!","your answer is correct.")
answer()
else:
messagebox.showinfo("sorry!","Better luck next time.")
e1.delete(0,END)
window=Tk()
window.geometry("350x400+400+300")
window.title("Jumbled Words Game")
window.configure(background = "yellow")
lbl1=Label(window,text="write here",font=("Arial",25,"bold"),bg="black",fg="white")
lbl1.pack(pady=30,ipady=10,ipadx=10)
correct_1=StringVar()
e1=Entry(window,font=("Arial",25,"bold"),textvariable=correct_1)
e1.pack(ipady=5,ipadx=5)
correct_button=Button(window,text="Check Out",font=("Arial",20,"bold"),width=20,bg="red",fg="white",relief=GROOVE,command=correct)
correct_button.pack(pady=40)
reset_button=Button(window,text="Reset",font=("Arial",20,"bold"),width=20,bg="blue",fg="white",relief=GROOVE,command=answer)
reset_button.pack()
one()
window.mainloop()