All our Data Science projects include bite-sized activities to test your knowledge and practice in an environment with constant feedback.
All our activities include solutions with explanations on how they work and why we chose them.
Given a variable fruits_data
containing information about fruits, your task is to create a dictionary called fruits
that mirrors the data in fruits_data
. The resulting fruits
dictionary should have the following structure:
{
'apple': {'color': 'red', 'price': 0.99},
'banana': {'color': 'yellow', 'price': 0.59},
# Add more fruits here
}
Use the information in fruits_data
to populate the fruits dictionary.
Building upon the previous activity where we created a dictionary named fruits
, your next task is to create a new dictionary called colors
. The colors
dictionary should retain the same data as fruits
, but with a different structure. In the colors
dictionary, the keys should represent the colors of the fruits, and the values should be lists containing the names of fruits of that color.
Upon completion, the colors
dictionary should resemble the following structure:
{
'red': ['apple', 'cherry', 'strawberry', 'raspberry'],
'yellow': ['banana', 'lemon'],
# Add more colors and associated fruits here
}
Utilize the information from the fruits
dictionary to construct the colors
dictionary.
Your objective is to augment the existing fruits
dictionary by adding the following fruits and their associated information:
('cherry', 'red', 1.99)
('lemon', 'yellow', 0.79)
('lime', 'green', 0.69)
Incorporate this new data into the fruits
dictionary.
Determine the total number of unique colors present in the fruits
dictionary. Please submit your answer in the input field below.
Enter your answer as an integer.
Find and report the color of the 'mango' fruit in the fruits
dictionary. Please enter your answer in the input field below.
Enter your answer as a string. Example:
red
Calculate and provide the total count of fruits with the color red
in the fruits
dictionary. Please input your answer into the designated field below.
Enter your answer as an integer.
Determine the average price of all the fruits within the fruits
dictionary. Please input your answer in the designated field below.
Enter your answer as a float. Example:
1.99
(rounded to 2 decimal places)
Your task is to create a Python function named find_expensive_fruits
that accepts two parameters: a dictionary of fruits and a threshold price. The function should return a set of fruit names that have a price exceeding the specified threshold.
Here's how the function definition should appear:
def find_expensive_fruits(fruits_data, threshold_price):
# Your code goes here
The function should output a set of strings.
Your objective is to compute the average caloric value of all fruits listed in the fruits
dictionary. Please submit your answer in the input field provided.
Enter your answer as a float. Example:
1.99
(rounded to 2 decimal places)
Your task is to identify and compile a list of fruits with "excellent" vitamin C content. This list should be stored in a variable named excellent_vitamin_c_fruits
.
For reference, the result should be in the format of a list, such as: ['apple', 'orange', 'kiwi']
.
Your task is to construct a Python function named update_fruit_price
that requires three parameters: the fruits dictionary, the name of the fruit, and the new price. This function should adjust the price of the specified fruit within the dictionary and return the updated dictionary.
Here's how the function definition should appear:
def update_fruit_price(fruits_data, fruit_name, new_price):
# Your code goes here
The function should return a dictionary.
Your objective is to generate a list of fruits with "low" sugar content and store this list in a variable named low_sugar_fruits
.
For reference, the result should be in the format of a list, like this: ['apple', 'orange', 'kiwi']
.
Your task is to determine and report the fruit with the highest caloric content. Please enter the name of the fruit in the input field provided.
Enter the name of the fruit as a string. Example:
apple
Your task is to eliminate the entry for 'banana' from the fruits
dictionary and then update the fruits
dictionary accordingly.
You have to remove the key-value pair for 'banana' from the
fruits
dictionary.
Your goal is to produce a copy of the fruits
dictionary and store this copy in a variable named fruits_copy
.
Your task is to clear or empty the fruits
dictionary.