Back

Sanskar

Keen Learner and Exp... • 1d

Day 30 of learning python as a beginner. Topic: making a fully functional calculator. Yesterday I got introduced to tkinter and was successful in creating a basic graphical layout for the calculator and today I added logic into it and now I finally have my own fully functional calculator (though basic one). However I do want to emphasize that I don't really think I have learned tkinter as I required much of AI assistance here and I am not much confident so I may also practice more of this and maybe next I will learn about scikit-learn or TensorFlow (suggestions are welcomed). As you may know that I had created a basic calculator program in my first few days of learning python as a beginner and I just reused its functions in my GUI logic and I know I may have also used the library also however I just want to reuse my code (my excuse for practicing import functions). I used command function to add logic to each button, I first created an anonymous function using lambda which assigns the value of text to each button via a for loop. After this I created the logic of identifying and actually calculating the user's input and returning him a meaningful answer. For this I used match case (I can also use if else statements however I find match case more readable and scalable for future). I then used some common functions like .delete, .insert for deleting and inserting inputs to print the result. I then used regrex functions to replace input%input (eg 20%80) to (input/100)*input (eg (20/100)*80). Then I used try except for handling any possible errors which may occur while the user is using the calculator. And here's my code and it's result.

Reply
2

More like this

Recommendations from Medial

Sanskar

Keen Learner and Exp... • 2d

Day 29 of learning python as a beginner. Topic: GUI using tkinter. I was getting some suggestions that I should start learning tkinter and PyQt as those will pose some really interesting challenge and I will have some fun learning them. Therefore I

See More
Reply
1

Sanskar

Keen Learner and Exp... • 27d

Day 5 of learning python as a beginner. Topic: Functions On my previous day post many people shared their github where I was introduced to def functions and since then I started learning more about def functions. Thank you all those people who are

See More
Reply

Sanskar

Keen Learner and Exp... • 16d

Day 15 of learning python as a beginner. Topic: Error Handling. A lot of amazing people have suggested me that I should learn error handling in order to tackle unexpected situation which may arise. I created this basic calculator which can perform

See More
Reply
3

Sanskar

Keen Learner and Exp... • 3d

Day 28 of learning python as a beginner. Topic: web scraping with postgreSQL database. When I posted my first web scraping project I just had the result on console however I wanted it to be stored somewhere where it can be reviewed later that's whe

See More
Reply
1

Sanskar

Keen Learner and Exp... • 5d

Day 26 of learning python as a beginner. Topic: CRUD operations in python postgreSQL. I had tried to explore SQL database handling in python and someone suggested me that I should also try performing CRUD (Create, Read, Update and Delete) operation

See More
Reply

Sanskar

Keen Learner and Exp... • 1d

Day x of learning python as a beginner. Nor more? Its been a month since I started leaning python as my first programming language. I am really enjoying my python journey and have learned many important concepts which will be used throughout my prog

See More
Reply

Sanskar

Keen Learner and Exp... • 13d

Day 17 of learning python as a beginner. Topic: lambda functions + email filter Lambda functions are a single line anonymous function without using the usual def key word. All function: checks whether all the key words (spam_keywords) are present

See More
Reply
2
Image Description
Image Description

nuthan kalyan

Data Enthusiast • 7d

hii actually I have my ai application. and I used gemini for the ai model. as am scaling my application I had to use gemini more. so what I did was I created multiple projects and in each project i created a single key such that the limits are only

See More
3 Replies
9

Sanskar

Keen Learner and Exp... • 29d

Day 3 of learning python as a beginner. Topic: Loops Loops are of two types: for loop and while loop. For loop is used when: 1. you know how many times you have to repeat, in my case I know I have to repeat it 10 times to get a full multiplication

See More
Reply
2

Download the medial app to read full posts, comements and news.