Browse Source

Загрузить файлы ''

u22-26kazutin 2 weeks ago
parent
commit
49bafb9daa
2 changed files with 113 additions and 0 deletions
  1. 65 0
      3.20_kazutin.py
  2. 48 0
      4.59_kazutin.py

+ 65 - 0
3.20_kazutin.py

@@ -0,0 +1,65 @@
+import tkinter as tk
+
+
+def find_units():
+    number = int(entry.get())
+    units = number % 10
+    label_units.config(text=f'Число единиц: {units}')
+
+
+def find_tens():
+    number = int(entry.get())
+    tens = (number // 10) % 10
+    label_tens.config(text=f'Число десятков: {tens}')
+
+
+def sum_digits():
+    number = int(entry.get())
+    digits_sum = sum(int(digit) for digit in str(number))
+    label_sum.config(text=f'Сумма цифр: {digits_sum}')
+
+
+def product_digits():
+    number = int(entry.get())
+    digits_product = 1
+    for digit in str(number):
+        digits_product *= int(digit)
+
+    label_product.config(text=f'Произведение цифр: {digits_product}')
+
+
+root = tk.Tk()
+root.title("Работа с трёхзначным числом")
+
+entry_label = tk.Label(root, text="Введите трёхзначное число:")
+entry_label.pack(pady=10)
+
+entry = tk.Entry(root)
+entry.pack(padx=20, pady=10)
+
+button_units = tk.Button(root, text='Найти число единиц', command=find_units)
+button_units.pack(pady=5)
+
+button_tens = tk.Button(root, text='Найти число десятков', command=find_tens)
+button_tens.pack(pady=5)
+
+button_sum = tk.Button(root, text='Найти сумму цифр', command=sum_digits)
+button_sum.pack(pady=5)
+
+button_product = tk.Button(
+    root, text='Найти произведение цифр', command=product_digits)
+button_product.pack(pady=5)
+
+
+label_units = tk.Label(root, text="")
+label_units.pack(pady=5)
+
+label_tens = tk.Label(root, text="")
+label_tens.pack(pady=5)
+
+label_sum = tk.Label(root, text="")
+label_sum.pack(pady=5)
+
+label_product = tk.Label(root, text="")
+label_product.pack(pady=5)
+root.mainloop()

+ 48 - 0
4.59_kazutin.py

@@ -0,0 +1,48 @@
+import tkinter as tk
+
+
+def check_triangle():
+    try:
+        side_a = float(entry_a.get())
+        side_b = float(entry_b.get())
+        side_c = float(entry_c.get())
+
+        if not ((side_a + side_b > side_c) and (side_a + side_c > side_b) and (side_b + side_c > side_a)):
+            result_label.config(text="Это не треугольник!")
+            return
+
+        if side_a == side_b == side_c:
+            result_label.config(text="Треугольник равносторонний.")
+        elif side_a == side_b or side_a == side_c or side_b == side_c:
+            result_label.config(text="Треугольник равнобедренный.")
+        else:
+            result_label.config(text="Треугольник неравносторонний.")
+
+    except ValueError:
+        result_label.config(text="Ошибка ввода! Пожалуйста, введите числа.")
+
+
+root = tk.Tk()
+root.title("Проверка типа треугольника")
+
+label_a = tk.Label(root, text="Сторона A:")
+entry_a = tk.Entry(root)
+label_b = tk.Label(root, text="Сторона B:")
+entry_b = tk.Entry(root)
+label_c = tk.Label(root, text="Сторона C:")
+entry_c = tk.Entry(root)
+
+button_check = tk.Button(root, text="Проверить", command=check_triangle)
+
+result_label = tk.Label(root, text="", fg="green")
+
+label_a.grid(row=0, column=0)
+entry_a.grid(row=0, column=1)
+label_b.grid(row=1, column=0)
+entry_b.grid(row=1, column=1)
+label_c.grid(row=2, column=0)
+entry_c.grid(row=2, column=1)
+button_check.grid(row=3, columnspan=2)
+result_label.grid(row=4, columnspan=2)
+
+root.mainloop()