Question 17: Fruits Plotly

🛒  Simple Fruit Store App

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.


Page 1 – Record Fruit Sales

  1. Show a dropdown menu with the following 10 fruits:
    ['Apple', 'Banana', 'Mango', 'Orange', 'Grapes', 'Watermelon', 'Pawpaw', 'Pear', 'Avocado', 'Pineapple']

  2. Ask the user to select a fruit from the dropdown.

  3. Ask the user to enter the quantity sold as a number.

  4. Save each entry into a CSV file called sales.csv with two columns:

    • Fruit

    • Quantity Sold


Page 2 – View and Analyze Sales

  1. Read and display the contents of sales.csv as a table.

  2. Ask the user to choose between Bar Chart and Pie Chart using a radio button or a selectbox.

  3. 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.

Write what you are looking for, and press enter to begin your search!