Math Calculator Buttons With eval() - Python Kivy GUI Tutorial #19

Поделиться
HTML-код
  • Опубликовано: 14 ноя 2024

Комментарии • 55

  • @Codemycom
    @Codemycom  3 года назад +2

    ▶️ Watch Entire Kivy Playlist ✅ Subscribe To My RUclips Channel:
    bit.ly/37LrJ27 bit.ly/2IGzvOR
    ▶️ See More At: ✅ Join My Facebook Group:
    Codemy.com bit.ly/2GFmOBz
    ▶️ Learn to Code at Codemy.com ✅ Buy a Codemy T-Shirt!
    Take $30 off with coupon code: youtube1 bit.ly/2VC9WUN
    ▶️ Get The Code
    bit.ly/39Oi8Z8

    • @AnujKumar-xn5tg
      @AnujKumar-xn5tg 3 года назад

      Sir, can binding of buttons is possible in Kivy as it can be done in tkinter

  • @sparshbatta7070
    @sparshbatta7070 3 года назад +1

    Hands Down the Best Tutorial Ever !! No perplexing, no confusions just a plain, easy and nice approach to teach the stuff !! Keep up the good work.👍👍👌👌😎😎

    • @Codemycom
      @Codemycom  3 года назад +1

      Thanks! Glad you enjoyed it!

  • @joephinazee5422
    @joephinazee5422 3 года назад +3

    I look forward to taking lunch breaks just to watch your videos. I love all your teachings! Also, I completed my percentage button. Probably use some tweaking, but it works as is.
    def percentage(self):
    if self.answer == '0':
    pass
    else:
    self.answer = self.answer / 100
    self.ids.calc_input.text = str(self.answer)
    self.answer = '0'

  • @gregnstuff1118
    @gregnstuff1118 3 года назад +1

    Thanks for the lesson and mad props to all the calculator creators out there. It it is fun to see how easy one missed function can break/fix a whole lot of things.

  • @unclebuddy
    @unclebuddy 2 года назад +2

    Good Kivy tutorial. Division needs some work. When the answer goes on forever past the decimal, eval() works, but in the calculator, what's displayed is just part of the answer, like the last three digits of 0.8333333333333334 for "5/6". If you print the answer it's right but it doesn't display right in the calculator. Solved by using the round() function built into Python.

    • @paulushimawan5196
      @paulushimawan5196 2 года назад

      Yes that's the way you do it

    • @digitaldigitz
      @digitaldigitz Год назад +1

      wow! for totally random comment to come across in youtube, this was mind blowing haha. I've only been python coding self taught for 3 years, and i run into problems with floats all the time
      example
      f = 3.2 + 3.2 + 3.2
      print(float(f))
      output: 9.600000000000001
      lol wtf, I never knew about the round function until today, maybe its something so basic but i didnt know it!
      anyway, thanks for your comment! haha 😀

  • @nejinii1353
    @nejinii1353 3 года назад +1

    Funny thing in programming world is this surprised face when you don't expect something to work, or like in this case work so well xD
    Thank you very much for presenting us these things in such simple manner, and i'm glad your dog is fine!

    • @Codemycom
      @Codemycom  3 года назад

      Thanks! Glad you're enjoying the videos!

  • @miladsmaeeli9119
    @miladsmaeeli9119 3 года назад +1

    Thank you very much. I've learned many things from your series...

    • @Codemycom
      @Codemycom  3 года назад

      You're very welcome!

  • @playerandroidtutoriais8905
    @playerandroidtutoriais8905 3 года назад

    Another alternative for division:
    if '/' in prior:
    num_list = prior.split('/')
    answer = 1

    for number in num_list:
    answer = int(num_list[0]) / int(num_list[1])


    self.ids.calc_input.text = str(answer)

  • @msvisoko9105
    @msvisoko9105 Год назад

    Percentage function with '+' and '-' operations. For example: 90 + 10% of 90 = 99. It can be modified further in similar way:
    def percentage(self):
    global result, result2
    prior = self.ids.calc_input.text
    if '+' in prior:
    result = prior.split('+')
    else:
    result2 = prior.split('-')
    if prior == '0':
    pass
    elif '-' in prior and len(result2) == 2:
    result3 = float(result2[0]) - (float(result2[0]) / 100)*float(result2[-1])
    self.ids.calc_input.text = str(round(result3, 3))
    elif '+' in prior and len(result) == 2:
    result4 = float(result[0]) + (float(result[0]) / 100)*float(result[-1])
    self.ids.calc_input.text = str(round(result4, 3))

  • @paulushimawan5196
    @paulushimawan5196 2 года назад +1

    I challenge all of you to code overflow error. The logic is pretty simple. If the answer is more than 12 digits, it will output an error, just like standard calculator. For example, 99999999*99999999 = Error.

  • @franciscocardozo9665
    @franciscocardozo9665 3 года назад +1

    Hi John,thanks for uploading these videos. I really learn a lot with them
    I have a question: can you import "special" functions like sin,cos,exponential,etc and place them in the calculator?

    • @Codemycom
      @Codemycom  3 года назад +1

      Sure, just like you would with any python program

  • @saadahmedkhan3897
    @saadahmedkhan3897 3 года назад

    Me watching this video. Suddenly a load shedding occars . Wi-Fi turn off. I make the calculator without watching this video. Yay!

  • @DamienMurtagh-Galea
    @DamienMurtagh-Galea 3 года назад +1

    Hi John
    Love all the work you do. I'm an IT teacher and you're the #1 place I send my students to understand Python GUI programming.
    Mate, I seem to get really weird values when I divide by 3. For example 10/3 will give 335, 7/3 = 335. 10/6 = 667. Any ideas what I've done wrong?

    • @Codemycom
      @Codemycom  3 года назад +1

      That's weird...try converting either the original numbers or answers to a float. float(answer)

    • @paulushimawan5196
      @paulushimawan5196 2 года назад

      Basically it's because the answer is so long that it can't fit the textbox. For example 10/6 is 1.66666666666666666666666666666667. You can round the answer, for example to 10 digits, to fit in the textbox.

  • @drcgaming4195
    @drcgaming4195 3 года назад +1

    6:20 i think it is supposed to mean modulo but im not sure
    and also "//" is floor div

    • @paulushimawan5196
      @paulushimawan5196 2 года назад

      Actually it doesn't mean modulo in normal calculator. But in Python and other prog languages, yes it's modulo. So it's up to you to interpret. And yes // is floor div

  • @durazno45
    @durazno45 3 года назад

    Good job master!!!

  • @hiwab41
    @hiwab41 3 года назад

    Your helping alot thx 😊😊😊💖

  • @erindeerhart5538
    @erindeerhart5538 Год назад

    Maybe you fix this in a later video, but a subtraction operator will simply be deleted from the text input if you press the +/- button. So "3*5-10" will become "3*510".
    Do I have that right?

    • @Codemycom
      @Codemycom  Год назад

      doesn't appear to be right, no.

  • @abhishekranjan7143
    @abhishekranjan7143 2 года назад

    I am getting below error message during execution with eval() function . May kindly please help fixing the issue.
    AttributeError: 'super' object has no attribute '__getattr__'

  • @christopherjonesramos3655
    @christopherjonesramos3655 3 года назад

    I've been watching your videos. And I seem to not be able to figure out how to clear the text input automatically after the answer has been displayed, when the user will enter another set of numbers, without pressing the C button.

    • @erindeerhart5538
      @erindeerhart5538 Год назад

      Check to see if the next button after the answer is displayed is a number. If so, clear the text box before adding the number to it. I know your question is a year old, but that's how I would do it.

  • @swastiksarkar
    @swastiksarkar 3 года назад

    I recently started learning Kivy and someone said that learning UI framework in python is just a waste of time. Is this true?

    • @Codemycom
      @Codemycom  3 года назад +1

      Why would that possibly be true? Lol

    • @paulushimawan5196
      @paulushimawan5196 2 года назад

      Probably "someone" that said to you is already "attached" to a certain programming language and find it useful, that's why for him/her learning something python is just a waste of time.

  • @elenaab4356
    @elenaab4356 3 года назад

    hello , I change the color's button in kivy file whit canvas , but I want to change the colour of button when pressing this , but I can't .
    can you help me , thank you sir :)

    • @Codemycom
      @Codemycom  3 года назад

      I believe I have a video on that in the playlist

    • @elenaab4356
      @elenaab4356 3 года назад

      @@Codemycom Thank you very much, I am looking forward to your video

  • @yahyaa4499
    @yahyaa4499 3 года назад +1

    There is an error
    Can you please try 6/9

  • @HarikrishnanSrinivasan
    @HarikrishnanSrinivasan 3 года назад +2

    First

  • @عالمالبرمجةالعربي
    @عالمالبرمجةالعربي 3 года назад

    hi teacher the you wolf is very beautiful