Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Task 0 3 ( 2 0 points ) Task 0 4 ( 2 0 points ) Write a Python program that completes the following steps:
Task points Task points
Write a Python program that completes the following steps:
Create a list named fruits containing the following elements: "Apple", "Banana", "Cherry",
"Date", "Elderberry".
Print the list.
Convert the fruits list to a tuple named fruitstuple.
Print the tuple.
Convert the fruits list to a set named fruitsset.
Print the set.
Convert the fruits list to a dictionary named fruitsdict that contains the fruits as keys and
their lengths as values:
a Lengths being the size of the word key Apple is Banana is but these
should not be hardcoded values, you need to use the len function to gather the
length of the key.
Print the dictionary.
Add "Fig" and "Grape" to the fruits list.
Remove "Date" from the fruits list.
Print the updated list.
Update fruitsdict to reflect the changes made to the fruits list.
Print the updated dictionary.
Here is a screenshot of the expected behavior. Replicate this functionality in your script,
including the formatting and outputs of all messages. Task points
Write a Python program that contains multiple userdefined functions that calculate storage
requirements and costs. These functions will provide useful metrics in the context of data
storage and backup solutions. Perform the following steps:
Create a function named calculatebackupsize that takes two arguments: datasize in
gigabytes and backupfrequency. This function should return the datasize multiplied
by backupfrequency, representing the total storage needed for backups in a week.
Create another function named calculatestoragecost that takes two arguments:
backupsize and costpergb This function should return the value of backupsize
multiplied by costpergb representing the total cost for the backup storage.
Create a third function named storageinfo that takes four arguments: datasize,
backupfrequency, costpergb and weeks. This function should call
calculatebackupsize and calculatestoragecost functions, taking the appropriate
arguments. Then it should multiply the cost by the number of weeks. It should return a
string that says "The total storage needed for backup is GB and the total cost for
weeks is dollars", replacing and with the calculated values.
Prompt the user to enter values for datasize, backupfrequency, costpergb and
weeks. If the user does not enter a positive number, your program should catch this error
and ask for the input again.
Call the storageinfo function with the userprovided datasize, backupfrequency,
costpergb and weeks and print the returned string.
Provide comments in your code to explain the logic used.
Test your program with different inputs and ensure it performs the calculations correctly.
When your program runs, it should match the expected output. Go back in and put in labels as
needed. The program should work for any valid inputs that the user provides.
Write a Python program that manages the student records of a class in your school.
Lists: Create a list of student names. These are strings representing the names of
students in your class egJohn "Mary", "Peter", "Sam"
Tuples: For each student, create a tuple that stores their grades in different subjects.
The subjects are Mathematics, English, and Science eg
Dictionaries: Now, create a dictionary where the keys are the names of the students
from your list and the values are the tuples storing their grades. This way, you can
easily look up a student's grades in different subjects.
Your final program should be able to print the names of all students, their grades in different
subjects, and their average grade. Make sure to use loops and appropriate Python builtin
functions in your program.
Here is a screenshot of the expected behavior. Replicate this functionality in your script,
including the formatting and outputs of all messages.
eric@iftlinux: Labg$ labgtasksdevil.py
Student Name: John
Mathematics Grade:
English Grade:
Science Grade:
Average Grade:
Student Name: Mary
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started