This challenge write-up first appeared on PyBites.
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.
Basic Requirements:
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.
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!
See our INSTALL doc how to fork our challenges repo to get cracking.
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).
If you have ideas for a future challenge or find any issues, please contact us or open a GH Issue.
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