byikp commited on
Commit
b3e9ecc
·
verified ·
1 Parent(s): 8007089

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +74 -0
app.py ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ def toplama(sayi1, sayi2):
4
+ try:
5
+ return float(sayi1) + float(sayi2)
6
+ except:
7
+ return "Hatalı giriş!"
8
+
9
+ def cikarma(sayi1, sayi2):
10
+ try:
11
+ return float(sayi1) - float(sayi2)
12
+ except:
13
+ return "Hatalı giriş!"
14
+
15
+ def carpma(sayi1, sayi2):
16
+ try:
17
+ return float(sayi1) * float(sayi2)
18
+ except:
19
+ return "Hatalı giriş!"
20
+
21
+ def bolme(sayi1, sayi2):
22
+ try:
23
+ if float(sayi2) == 0:
24
+ return "Sıfıra bölme hatası!"
25
+ return float(sayi1) / float(sayi2)
26
+ except:
27
+ return "Hatalı giriş!"
28
+
29
+ with gr.Blocks(title="4 İşlem Uygulaması") as demo:
30
+ gr.Markdown("## 🧮 4 Temel İşlem Uygulaması")
31
+ gr.Markdown("Farklı sekmede her işlemi ayrı ayrı yapabilirsiniz")
32
+
33
+ with gr.Tabs():
34
+ with gr.TabItem("➕ Toplama"):
35
+ with gr.Row():
36
+ with gr.Column():
37
+ toplama_s1 = gr.Number(label="Birinci Sayı")
38
+ toplama_s2 = gr.Number(label="İkinci Sayı")
39
+ toplama_btn = gr.Button("Hesapla")
40
+ toplama_sonuc = gr.Textbox(label="Sonuç")
41
+ toplama_btn.click(toplama, inputs=[toplama_s1, toplama_s2], outputs=toplama_sonuc)
42
+ gr.Examples([[5, 7], [3.2, 4.8]], inputs=[toplama_s1, toplama_s2])
43
+
44
+ with gr.TabItem("➖ Çıkarma"):
45
+ with gr.Row():
46
+ with gr.Column():
47
+ cikarma_s1 = gr.Number(label="Birinci Sayı")
48
+ cikarma_s2 = gr.Number(label="İkinci Sayı")
49
+ cikarma_btn = gr.Button("Hesapla")
50
+ cikarma_sonuc = gr.Textbox(label="Sonuç")
51
+ cikarma_btn.click(cikarma, inputs=[cikarma_s1, cikarma_s2], outputs=cikarma_sonuc)
52
+ gr.Examples([[10, 3], [5.5, 2.3]], inputs=[cikarma_s1, cikarma_s2])
53
+
54
+ with gr.TabItem("✖️ Çarpma"):
55
+ with gr.Row():
56
+ with gr.Column():
57
+ carpma_s1 = gr.Number(label="Birinci Sayı")
58
+ carpma_s2 = gr.Number(label="İkinci Sayı")
59
+ carpma_btn = gr.Button("Hesapla")
60
+ carpma_sonuc = gr.Textbox(label="Sonuç")
61
+ carpma_btn.click(carpma, inputs=[carpma_s1, carpma_s2], outputs=carpma_sonuc)
62
+ gr.Examples([[4, 5], [2.5, 4]], inputs=[carpma_s1, carpma_s2])
63
+
64
+ with gr.TabItem("➗ Bölme"):
65
+ with gr.Row():
66
+ with gr.Column():
67
+ bolme_s1 = gr.Number(label="Birinci Sayı")
68
+ bolme_s2 = gr.Number(label="İkinci Sayı")
69
+ bolme_btn = gr.Button("Hesapla")
70
+ bolme_sonuc = gr.Textbox(label="Sonuç")
71
+ bolme_btn.click(bolme, inputs=[bolme_s1, bolme_s2], outputs=bolme_sonuc)
72
+ gr.Examples([[10, 2], [5.5, 2]], inputs=[bolme_s1, bolme_s2])
73
+
74
+ demo.launch()