A smooth sea never made a skilled sailor. - Franklin D. Roosevelt
Hi Pythonistas, a new week, a new 'bite' of Python coding! This week we will get you to create a simple app to calculate the monetary cost of using an electrical device. Enjoy!
The challenge is simple. We want you to create an app that will allow you to calculate the hourly cost of running an electrical device.
App will allow a user to enter the wattage consumption of a device (eg, a 20w light globe) and a cost per kilowatt hour (kWh). kWh being the unit of measurement the electric company charges by.
The app will then return the cost of running the device for 1 hour.
This is the absolute baseline for beginners. We recommend you continue with the Bonus Features.
To make it interesting, see if you can complete the following:
Make this a web app using the framework of your choice. It’d look great in a browser!
Allow a user to enter in how many hours they want to use the device for and have this factored into your cost result (eg, Using a 20w globe at 50 cents per kWh for 10 hours).
Use persistent storage (sqlite, shelf, etc) to store all queries to the app and have the ability to print this stored data back to the user when requested.
If you don’t want to make it a web app, see if you can construct a GUI using TkInter or other.
Consider this a half specific, half open ended challenge. There’s an intentional, specific goal here but how you get there is up to you. If you’re a newbie and it takes time, feel free to leave this as a CLI based app.
It doesn’t matter how great it looks, only that you were challenged along the way and learned something!
This doc also provides you with instructions how you can submit your code to our community branch via a Pull Request (PR). We will feature your PRs in our end-of-the-week challenge review (previous editions).
Last but not least: there is no best solution, only learning more and better Python. Good luck!
Keep Calm and Code in Python!
-- Bob and Julian
Do you want to get 250+ concise and applicable Python tips in an ebook that will cost you less than 10 bucks (future updates included), check it out here.
"The discussions are succinct yet thorough enough to give you a solid grasp of the particular problem. I just wish I would have had this book when I started learning Python." - Daniel H
"Bob and Julian are the masters at aggregating these small snippets of code that can really make certain aspects of coding easier." - Jesse B
"This is now my favourite first Python go-to reference." - Anthony L
"Do you ever go on one of those cooking websites for a recipe and have to scroll for what feels like an eternity to get to the ingredients and the 4 steps the recipe actually takes? This is the opposite of that." - Sergio S