Keen Learner and Exp... • 2d
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 arithematic operations, generate a table, and convert units. My initial plan was to use error handling in my previous programs however I put it on hold and created a new program (I will still be using error handling in my previous code as well). Error handling consists of two main functions: try: this will run when the there is no error in the user input or program i.e the program runs as expected. except: this gets executed whenever an error arise however we can use this to raise custom error ex: print("Invalid Input") rather than those long red error lines. we can also use "raise" function to create a custom error ex: raising value error when a user typed a string where he was supposed to enter an integer. raise essentially stops the function when an error arsie however the program executes completely when using try and except. I first begin by creating a specific class dedicated for a specific feature like arithematic operation, generate table and unit converter. Then I called these functions using if elif and else ladder (can someone please tell me how to call these functions in a better way as I feel like using so many if elif and else isn't very efficient). I have attached the code in two parts (classes and script) because it was to long to come under one image. And of course everything will work fine if there is no errors in input however I have only added the result where error handling is involved. I will soon be publishing my codes on github so that all of you can run it and learn and also suggest potential changes and bugs etc. Of course after completing my little gift for you all amazing people which I told you about in my yesterday's post (I don't know its effect on your life however I am trying my best). I warmly welcome all the suggestions and questions regarding my code which will help me improve my knowledge and code structure and execution.
Keen Learner and Exp... • 6d
Day 11 of learning python as a beginner. Topic: creating journal entry program using file I/O. I got a little sidleline from my original plan of editing my to-do list program and created an entirely new program this time for writing a daily journal
See MoreHey I am on Medial • 1y
Finally I found out the logic for my code . I was literally stucked at a program for past 1 week. How???mmmmm.. actually while discussing my problem with my bestfriend , he helped me with a hint and that's enough for me to build logic for my program
See MoreHey I am on Medial • 1y
Is it only me that whenever i start some project , i would run into problems that are so silly and insignificant that searching the solution for it would give anyone second hand embarrassment. For Ex. before even writing the first line of code, i wo
See MoreDownload the medial app to read full posts, comements and news.