Mr. Tee owns a small fruit market and sells 10 different fruits. He wants to keep daily records of how many fruits were sold. To help him, you’re building a very simple Python app that allows him to record fruit sales and visualize them with charts.
You must ensure that Tee only selects fruits from a dropdown (not typed manually) to avoid mistakes. The app should also allow him to switch between viewing a bar chart or a pie chart on the results page.
Show a dropdown menu with the following 10 fruits:['Apple', 'Banana', 'Mango', 'Orange', 'Grapes', 'Watermelon', 'Pawpaw', 'Pear', 'Avocado', 'Pineapple']
Ask the user to select a fruit from the dropdown.
Ask the user to enter the quantity sold as a number.
Save each entry into a CSV file called sales.csv
with two columns:
Fruit
Quantity Sold
Read and display the contents of sales.csv
as a table.
Ask the user to choose between Bar Chart and Pie Chart using a radio button or a selectbox.
Display the selected chart using Plotly Express:
Bar chart: Fruit names on the x-axis, quantities on the y-axis.
Pie chart: Each fruit’s share of the total sold.
We’re always looking for international STEM educators to join our team. If you are interested, please send us a mail and we’ll get back to you!
If you have any questions, kindly send us a mail. Don’t forget to follow and like all our social accounts to get updates on competitions!