{"id":229,"date":"2023-08-24T15:10:19","date_gmt":"2023-08-24T12:10:19","guid":{"rendered":"https:\/\/www.facadium.com.tr\/blog\/?p=229"},"modified":"2023-08-29T18:26:32","modified_gmt":"2023-08-29T15:26:32","slug":"python-ile-basit-bir-hesap-makinesi-olusturmak","status":"publish","type":"post","link":"https:\/\/www.facadium.com.tr\/blog\/python-ile-basit-bir-hesap-makinesi-olusturmak\/","title":{"rendered":"Python ile Basit Bir Hesap Makinesi Olu\u015fturmak"},"content":{"rendered":"\n<p>Merhabalar, bu yaz\u0131m\u0131zda Python yaz\u0131l\u0131m dili ile hesap makinesi olu\u015fturmay\u0131 deneyece\u011fiz. Hesap makineleri, art\u0131k cep telefonlar\u0131 ve ak\u0131ll\u0131 cihazlar\u0131n \u00e7ok kullan\u0131lmas\u0131 nedeniyle pop\u00fclerli\u011fini yitirmeye ba\u015flasa da bir\u00e7ok kullan\u0131c\u0131 taraf\u0131ndan halen daha kullan\u0131lmaktad\u0131r. Python gibi matematik alt yap\u0131s\u0131 g\u00fc\u00e7l\u00fc ve matematiksel i\u015flemlerde \u00e7ok g\u00fc\u00e7l\u00fc bir yap\u0131s\u0131 olan yaz\u0131l\u0131m dilinde de bu uygulamay\u0131 yapmak ve sizlerle payla\u015fman\u0131n faydal\u0131 olaca\u011f\u0131n\u0131 d\u00fc\u015f\u00fcnd\u00fck. \u0130\u015flem ad\u0131mlar\u0131n\u0131 a\u015fa\u011f\u0131da ad\u0131m ad\u0131m haz\u0131rlad\u0131k.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Ad\u0131m 1: Python Ortam\u0131n\u0131 Haz\u0131rlamak<\/h2>\n\n\n\n<p>\u0130lk ad\u0131mda, Python programlama dili i\u00e7in bir geli\u015ftirme ortam\u0131 kurman\u0131z gerekmektedir. E\u011fer hen\u00fcz bir Python yorumlay\u0131c\u0131s\u0131 y\u00fcklemediyseniz, <a href=\"https:\/\/www.python.org\/\" target=\"_blank\" rel=\"noopener\">Python resmi web sitesinden<\/a> indirebilir ve kurabilirsiniz. Ayr\u0131ca, tercihinize g\u00f6re bir Python entegre geli\u015ftirme ortam\u0131 (IDE) kullanabilirsiniz. \u00d6rne\u011fin, PyCharm, Visual Studio Code veya Jupyter Notebook gibi pop\u00fcler se\u00e7enekler mevcuttur.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Ad\u0131m 2: Temel Aray\u00fcz\u00fc Olu\u015fturmak i\u00e7in K\u00fct\u00fcphaneleri \u0130\u00e7e Aktarmak<\/h2>\n\n\n\n<p>Python&#8217;da bir aray\u00fcz olu\u015fturmak i\u00e7in genellikle <code>tkinter<\/code> adl\u0131 bir k\u00fct\u00fcphane kullan\u0131l\u0131r. Bu k\u00fct\u00fcphane, basit grafiksel kullan\u0131c\u0131 aray\u00fczleri (GUI) olu\u015fturman\u0131za yard\u0131mc\u0131 olur. \u0130lk olarak, hesap makinenizin temel aray\u00fcz\u00fcn\u00fc olu\u015fturmak i\u00e7in <code>tkinter<\/code>&#8216;\u0131 i\u00e7e aktaral\u0131m. Daha sonra butonlar i\u00e7in fonksiyonlar\u0131m\u0131z\u0131 olu\u015fturuyoruz. Bundan sonra ana pencerenin yap\u0131s\u0131n\u0131 olu\u015fturuyoruz. Ard\u0131ndan ekran\u0131n yap\u0131s\u0131n\u0131 (geni\u015flik, hizalama) belirleyerek olu\u015fturuyoruz.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import tkinter as tk\n\ndef button_click(number):\n    current = display.get()\n    display.delete(0, tk.END)\n    display.insert(tk.END, current + str(number))\n\ndef button_clear():\n    display.delete(0, tk.END)\n\ndef button_equal():\n    expression = display.get()\n    result = eval(expression)\n    display.delete(0, tk.END)\n    display.insert(tk.END, result)\n\n# Ana pencereyi olu\u015fturun\nwindow = tk.Tk()\nwindow.title(\"Hesap Makinesi\")\n\n# Ekran\ndisplay = tk.Entry(window, width=30, justify=\"right\")\ndisplay.grid(row=0, column=0, columnspan=4)\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Ad\u0131m 3: Aray\u00fcz Bile\u015fenlerini Eklemek<\/h2>\n\n\n\n<p>Hesap makinenizin aray\u00fcz\u00fc, en az\u0131ndan birka\u00e7 d\u00fc\u011fme ve bir sonu\u00e7 alan\u0131 i\u00e7ermelidir. Buradaki butonlar\u0131 belirtiyoruz. \u00d6rne\u011fin 0-9 say\u0131lar\u0131, toplama, \u00e7\u0131karma, b\u00f6lme, \u00e7arpma gibi butonlar olu\u015fturuluyor.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Butonlar\nbutton_1 = tk.Button(window, text=\"1\", padx=20, pady=10, command=lambda: button_click(1))\nbutton_2 = tk.Button(window, text=\"2\", padx=20, pady=10, command=lambda: button_click(2))\nbutton_3 = tk.Button(window, text=\"3\", padx=20, pady=10, command=lambda: button_click(3))\nbutton_4 = tk.Button(window, text=\"4\", padx=20, pady=10, command=lambda: button_click(4))\nbutton_5 = tk.Button(window, text=\"5\", padx=20, pady=10, command=lambda: button_click(5))\nbutton_6 = tk.Button(window, text=\"6\", padx=20, pady=10, command=lambda: button_click(6))\nbutton_7 = tk.Button(window, text=\"7\", padx=20, pady=10, command=lambda: button_click(7))\nbutton_8 = tk.Button(window, text=\"8\", padx=20, pady=10, command=lambda: button_click(8))\nbutton_9 = tk.Button(window, text=\"9\", padx=20, pady=10, command=lambda: button_click(9))\nbutton_0 = tk.Button(window, text=\"0\", padx=20, pady=10, command=lambda: button_click(0))\nbutton_add = tk.Button(window, text=\"+\", padx=20, pady=10, command=lambda: button_click(\"+\"))\nbutton_subtract = tk.Button(window, text=\"-\", padx=20, pady=10, command=lambda: button_click(\"-\"))\nbutton_multiply = tk.Button(window, text=\"*\", padx=20, pady=10, command=lambda: button_click(\"*\"))\nbutton_divide = tk.Button(window, text=\"\/\", padx=20, pady=10, command=lambda: button_click(\"\/\"))\nbutton_equal = tk.Button(window, text=\"=\", padx=20, pady=10, command=button_equal)\nbutton_clear = tk.Button(window, text=\"C\", padx=20, pady=10, command=button_clear)<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Ad\u0131m 4: Butonlar\u0131 Yerle\u015ftirme ve \u0130\u015flevselli\u011fi Ekleme<\/h2>\n\n\n\n<p>Hesap makinenizin aray\u00fcz\u00fc haz\u0131r oldu\u011funa g\u00f6re, d\u00fc\u011fmelere t\u0131klama ve matematiksel i\u015flemleri ger\u00e7ekle\u015ftirme i\u015flevselli\u011fini eklemeye ge\u00e7ebiliriz ve ard\u0131ndan ana d\u00f6ng\u00fcy\u00fc \u00e7al\u0131\u015ft\u0131r\u0131r\u0131z:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Butonlar\u0131 yerle\u015ftirin\nbutton_1.grid(row=1, column=0)\nbutton_2.grid(row=1, column=1)\nbutton_3.grid(row=1, column=2)\nbutton_4.grid(row=2, column=0)\nbutton_5.grid(row=2, column=1)\nbutton_6.grid(row=2, column=2)\nbutton_7.grid(row=3, column=0)\nbutton_8.grid(row=3, column=1)\nbutton_9.grid(row=3, column=2)\nbutton_0.grid(row=4, column=0)\nbutton_add.grid(row=1, column=3)\nbutton_subtract.grid(row=2, column=3)\nbutton_multiply.grid(row=3, column=3)\nbutton_divide.grid(row=4, column=3)\nbutton_equal.grid(row=4, column=2)\nbutton_clear.grid(row=4, column=1)\n\n# Ana d\u00f6ng\u00fcy\u00fc \u00e7al\u0131\u015ft\u0131r\u0131n\nwindow.mainloop()\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Sonu\u00e7 Olarak<\/h2>\n\n\n\n<p>Burada bir basit hesap makinesinin ne kadar kolay bir \u015fekilde yap\u0131ld\u0131\u011f\u0131n\u0131 \u00f6\u011frenmi\u015f olduk. Python \u00f6zellikle sahip oldu\u011fu matematik alt yap\u0131l\u0131 k\u00fct\u00fcphaneleri sayesinde veri bilimi, b\u00fcy\u00fck veri, veri analizi, veri madencili\u011fi ve m\u00fchendislik analizleri gibi konularda olduk\u00e7a uzman ve g\u00fc\u00e7l\u00fc bir yaz\u0131l\u0131m dilidir. Bu yaz\u0131l\u0131m dilini kullanarak sizler de farkl\u0131 projeler geli\u015ftirebilirsiniz.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Merhabalar, bu yaz\u0131m\u0131zda Python yaz\u0131l\u0131m dili ile hesap makinesi olu\u015fturmay\u0131 deneyece\u011fiz. Hesap makineleri, art\u0131k cep telefonlar\u0131 ve ak\u0131ll\u0131 cihazlar\u0131n \u00e7ok kullan\u0131lmas\u0131 nedeniyle pop\u00fclerli\u011fini yitirmeye ba\u015flasa [&#8230;]<\/p>\n","protected":false},"author":3,"featured_media":422,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[54,52,8,53],"class_list":["post-229","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-calculator","tag-hesap-makinesi","tag-python","tag-tkinter"],"_links":{"self":[{"href":"https:\/\/www.facadium.com.tr\/blog\/wp-json\/wp\/v2\/posts\/229","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.facadium.com.tr\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.facadium.com.tr\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.facadium.com.tr\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.facadium.com.tr\/blog\/wp-json\/wp\/v2\/comments?post=229"}],"version-history":[{"count":2,"href":"https:\/\/www.facadium.com.tr\/blog\/wp-json\/wp\/v2\/posts\/229\/revisions"}],"predecessor-version":[{"id":233,"href":"https:\/\/www.facadium.com.tr\/blog\/wp-json\/wp\/v2\/posts\/229\/revisions\/233"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.facadium.com.tr\/blog\/wp-json\/wp\/v2\/media\/422"}],"wp:attachment":[{"href":"https:\/\/www.facadium.com.tr\/blog\/wp-json\/wp\/v2\/media?parent=229"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.facadium.com.tr\/blog\/wp-json\/wp\/v2\/categories?post=229"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.facadium.com.tr\/blog\/wp-json\/wp\/v2\/tags?post=229"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}