Skip to content

Commit

Permalink
add error handler
Browse files Browse the repository at this point in the history
  • Loading branch information
koshkar committed Oct 6, 2023
1 parent 6c829e3 commit 30127f9
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/lab1/calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,22 @@ def button_equal(self):
self.number_entry.insert(0, self.f_num * int(second_number))

if self.math == "division":
self.number_entry.insert(0, self.f_num / int(second_number))
if second_number == '0':
self.number_entry.insert(0, 'На 0 делить нельзя! (Здесь)')
else:
self.number_entry.insert(0, self.f_num / int(second_number))

if self.math == "floor_div":
self.number_entry.insert(0, self.f_num // int(second_number))
if second_number == '0':
self.number_entry.insert(0, 'На 0 делить нельзя! (Здесь)')
else:
self.number_entry.insert(0, self.f_num // int(second_number))

if self.math == "modulus":
self.number_entry.insert(0, self.f_num % int(second_number))
if second_number == '0':
self.number_entry.insert(0, 'На 0 делить нельзя! (Здесь)')
else:
self.number_entry.insert(0, self.f_num % int(second_number))

def button_subtraction(self):
'''Обработка команды разность'''
Expand Down

0 comments on commit 30127f9

Please sign in to comment.