Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
from tkinter import *
from tkinter import messagebox as mb
root = Tk()
root.geometry('500x200')
root.resizable(False, False)
root.title('Деление на 3')
root['bg'] = 'grey22'
txt = Label(text='Напишите число:', fg='white', bg='black')
txt.grid()
ent = Entry()
ent.grid(column=2, row=0)
def divBy3():
num = ent.get()
if not num.isnumeric():
mb.showerror(title='Ошибка', message='Произошла ошибка. Вы написали не число')
else:
num = int(num)
oper = num / 3 # get принимает только строки :(
if num % 3 == 0:
mb.showinfo(title='Информация', message='Число делится на 3, результат: ' + str(oper))
elif num % 3 != 0:
mb.showinfo(title='Информация', message='Данное число не делится на 3!')
btn = Button(text='Нажать', width=15, command=divBy3)
btn.place(x=250)
root.mainloop()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question