I entered the school from April, but I haven't been to school except for the entrance ceremony, so I haven't made any friends: cry: Of course, studying is the most important thing because it is a school, but I think it is also important to make friends. So, I decided to introduce myself a little in ** quiz format ** using python. (The name will not be posted on Qiita due to privacy issues)
I thought about information that can be easily understood when face-to-face After all, the best is ** face **, but it is difficult to explain the face. Then, the next information you can find is ** height ** So I thought I'd ask everyone to guess my height
If you don't enter my height exactly, you won't get the correct answer If you're too tall, you'll get caught up in me
import tkinter as tk
import tkinter.messagebox as tmsg
def ButtonClick_h():
h = editboxl_h.get()
c = editboxl_h.get()
my_h = False
if len(c) != 3:
tmsg.showinfo("mistake", "Enter a 3-digit number!")
else:
kazuok = True
for i in range(1):
if (h[i] < "0") or (h[i] > "9"):
tmsg.showerror("error", "Numbers!")
kazuok = False
break
if kazuok :
my_h = True
if my_h :
if int(h) == 174:
tmsg.showinfo("Correct answer", "I'll do it!")
elif 170 <= int(h) < 174:
tmsg.showinfo("I'm sorry!", "It ’s a little higher!")
elif 174 < int(h) <= 179:
tmsg.showinfo("I'm sorry!", "It ’s a little lower!")
elif int(h) < 170:
tmsg.showinfo("At all!", "Such a small one!")
else:
int(h) > 180
tmsg.showinfo("At all!", "That's not the case!" )
I've introduced myself several times before, but I thought about what I was talking about. I talk a lot, but I thought the next thing to say after the name was ** birthday ** and ** favorite thing **
If you don't guess your birthday, you won't get the correct answer
def ButtonClick_b():
b = editboxl_b.get()
d = editboxl_b.get()
my_b = False
if len(d) != 1:
tmsg.showinfo("mistake", "Great tip! In a single digit!")
else:
kazuok = True
for i in range(1):
if (b[i] < "0") or (b[i] > "9"):
tmsg.showerror("error", "Not a number")
kazuok = False
break
if kazuok :
my_b = True
if my_b :
if int(b) == 3:
tmsg.showinfo("Correct answer", "大Correct answer!君とは気が合うかもね(笑)")
elif 1 <= int(b) < 2:
tmsg.showinfo("I'm sorry!", "It ’s a little higher")
elif 4 < int(b) <= 6:
tmsg.showinfo("I'm sorry!", "A little lower")
else:
int(b) > 6
tmsg.showinfo("At all!", "The temperature is just right(Tips)" )
I like sports, but I get the ones I especially like This is a program where you can win from "basketball," "baseball," and "soccer."
def ButtonClick_s1():
tmsg.showinfo("No!", "Basketball is also interesting though! !!")
def ButtonClick_s2():
tmsg.showinfo("Correct answer", "Baseball is the best! !!" )
def ButtonClick_s3():
tmsg.showinfo("No!", "I'm not very good at soccer.")
import tkinter as tk
import tkinter.messagebox as tmsg
def ButtonClick_h():
h = editboxl_h.get()
c = editboxl_h.get()
my_h = False
if len(c) != 3:
tmsg.showinfo("mistake", "Enter a 3-digit number!")
else:
kazuok = True
for i in range(1):
if (h[i] < "0") or (h[i] > "9"):
tmsg.showerror("error", "Numbers!")
kazuok = False
break
if kazuok :
my_h = True
if my_h :
if int(h) == 174:
tmsg.showinfo("Correct answer", "I'll do it!")
elif 170 <= int(h) < 174:
tmsg.showinfo("I'm sorry!", "It ’s a little higher!")
elif 174 < int(h) <= 179:
tmsg.showinfo("I'm sorry!", "It ’s a little lower!")
elif int(h) < 170:
tmsg.showinfo("At all!", "Such a small one!")
else:
int(h) > 180
tmsg.showinfo("At all!", "That's not the case!" )
def ButtonClick_b():
b = editboxl_b.get()
d = editboxl_b.get()
my_b = False
if len(d) != 1:
tmsg.showinfo("mistake", "Great tip! In a single digit!")
else:
kazuok = True
for i in range(1):
if (b[i] < "0") or (b[i] > "9"):
tmsg.showerror("error", "Not a number")
kazuok = False
break
if kazuok :
my_b = True
if my_b :
if int(b) == 3:
tmsg.showinfo("Correct answer", "大Correct answer!君とは気が合うかもね(笑)")
elif 1 <= int(b) < 2:
tmsg.showinfo("I'm sorry!", "It ’s a little higher")
elif 4 < int(b) <= 6:
tmsg.showinfo("I'm sorry!", "A little lower")
else:
int(b) > 6
tmsg.showinfo("At all!", "The temperature is just right(Tips)" )
def ButtonClick_s1():
tmsg.showinfo("No!", "Basketball is also interesting though! !!")
def ButtonClick_s2():
tmsg.showinfo("Correct answer", "Baseball is the best! !!" )
def ButtonClick_s3():
tmsg.showinfo("No!", "I'm really bad at soccer!")
root = tk.Tk()
root.geometry("800x800")
root.title("Get to know me")
labell_h = tk.Label(root, text="(It's about this time ...)Nice to meet you!", font=("Helvetica", 30))
labell_h.place(x = 20, y = 0)
labell_i = tk.Label(root, text="Get to know me even a little in 2 minutes!", font=("Helvetica", 20))
labell_i.place(x = 20, y = 50)
labell_h = tk.Label(root, text="[SIZE] Let's guess the height(3 single-byte numbers)", font=("Helvetica", 20))
labell_h.place(x = 20, y = 150)
labell_b = tk.Label(root, text="[BIRTHDAY] Let's guess the month of birth(Half-width numbers)", font=("Helvetica", 20))
labell_b.place(x = 20, y = 300)
labell_x = tk.Label(root, text="[LIKE] Let's guess which sport you like", font=("Helvetica", 20))
labell_x.place(x = 20, y = 500)
editboxl_h = tk.Entry(width = 3, font=("Helvetica", 28))
editboxl_h.place(x =120, y = 200)
editboxl_b = tk.Entry(width = 3, font=("Helvetica", 28))
editboxl_b.place(x =120, y = 360)
height = tk.Label(root, text = "cm", font=("Helvetica", 20))
height.place(x = 200, y = 200)
monthl = tk.Label(root, text = "Month", font=("Helvetica", 20))
monthl.place(x = 200, y = 360)
buttonl_h = tk.Button(root, text = "click", font=("Helvetica", 14), command=ButtonClick_h)
buttonl_h.place(x = 240, y =200)
buttonl_b= tk.Button(root, text = "click", font=("Helvetica", 14), command=ButtonClick_b)
buttonl_b.place(x = 240, y =360)
buttonl_s1 = tk.Button(root, text = "basketball", font=("Helvetica", 14), command=ButtonClick_s1)
buttonl_s1.place(x = 120, y =560)
buttonl_s2 = tk.Button(root, text = "baseball", font=("Helvetica", 14), command=ButtonClick_s2)
buttonl_s2.place(x = 120, y =630)
buttonl_s3 = tk.Button(root, text = "Football", font=("Helvetica", 14), command=ButtonClick_s3)
buttonl_s3.place(x = 120, y =700)
root.mainloop()
It will look like this! !! !!
Originally, I might have been able to introduce myself face-to-face in April, but I'm glad I was able to introduce myself in this way.
Recommended Posts