Question

(Python)

Implement a function that would take pairs of strings that contain time interval and event name and add them to the dictionary that contains events in your schedule for the week. The function should have toprint keyword with a default value of True, that would control whether your schedule will be printed.

Format your printed schedule nicely so that it prints out something similar to this (no need to put many events in your schedule, just enough to demonstrate that your function is working).

Implement a function that would take pairs of strings that contain time interval and event name and add them to the dictionar

0 0
Add a comment Improve this question Transcribed image text
Answer #1

code:

def schedule(time_interval, event_name, toprint=True):
    day, time = time_interval.split(';')
    week[day].update({time: event_name})
    if toprint: # if True
        for day in week:
            if(week[day]): # if week[day] != None
                print(day)
                print("-------------")
                for time_stamp in week[day]:
                    print(f'{time_stamp}  {week[day][time_stamp]}')
                print()
                
# week dictonary
week = {"Monday":{"1:50 - 3:30 PM": "ASTR 205 class"}, "Tuesday": {}, "Wednesday": {"1:50 - 3:30 PM": "ASTR 205 class"}, 
"Thrusday":{"10:30 AM - noon": "ASTR 205 class"}, "Friday": {"1:50 - 3:10 PM": "ASTR 205 lab"}, "Saturday": {}, "Sunday": {}}

schedule("Wednesday;3:30 - 4:30 PM ", "Astronomy coliquium", False)
schedule("Thrusday;noon - 1:00 PM", "KICP seminar", True)

Explanation:

We have a global dictionary week which holds tast of the week day with time stamp, we update the dictonary when a new task is to be added by using update method on dictionary.

output:

File Edit Selection View Go Run Terminal Help schedule.py - HomeworkLib - Visual Studio Code х schedule.py X DO OUTPUT Code [Runnin

Add a comment
Know the answer?
Add Answer to:
(Python) Implement a function that would take pairs of strings that contain time interval and event...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Implement a function in assembly that would do the following: loop through a sequence of characters...

    Implement a function in assembly that would do the following: loop through a sequence of characters and swap them such that the end result is the original string in reverse ( 50 points ) before looping, call another assembly function to extract the number of characters in the string ( 30 points ) for swapping characters, call another assembly function to do just that ( 20 points ) .cpp and .asm files. The three assembly functions should be called something...

  • IN PYTHON Assignment Overview This assignment will give you experience on the use of classes. Understand...

    IN PYTHON Assignment Overview This assignment will give you experience on the use of classes. Understand the Application The assignment is to first create a class calledTripleString.TripleStringwill consist of threeinstance attribute strings as its basic data. It will also contain a few instance methods to support that data. Once defined, we will use it to instantiate TripleString objects that can be used in our main program. TripleString will contain three member strings as its main data: string1, string2, and string3....

  • Assignment 4 Real Deal: Crier On Us Some word games, like Scrabble, require rearranging a combination of letters to make...

    Assignment 4 Real Deal: Crier On Us Some word games, like Scrabble, require rearranging a combination of letters to make a word. This type of arrangement is generally referred to as an anagram, it's known as a permutation in mathematics. This assignment will give you some experience thinking about and writing recursive functions. Write a C++ program that searches for ``anagrams'' in a dictionary. An anagram is a word obtained by scrambling the letters of some string. For example, the...

  • C++ Inheritance Problem Step a: Suppose you are creating a fantasy role-playing game. In this game...

    C++ Inheritance Problem Step a: Suppose you are creating a fantasy role-playing game. In this game we have four different types of Creatures: Humans, Cyberdemons, Balrogs, and elves. To represent one of these Creatures we might define a Creature class as follows: class Creature { private: int type; // 0 Human, 1 Cyberdemon, 2 Balrog, 3 elf int strength; // how much damage this Creature inflicts int hitpoints; // how much damage this Creature can sustain string getSpecies() const; //...

  • You need not run Python programs on a computer in solving the following problems. Place your...

    You need not run Python programs on a computer in solving the following problems. Place your answers into separate "text" files using the names indicated on each problem. Please create your text files using the same text editor that you use for your .py files. Answer submitted in another file format such as .doc, .pages, .rtf, or.pdf will lose least one point per problem! [1] 3 points Use file math.txt What is the precise output from the following code? bar...

  • Assignment Predator / Prey Objectives Reading from and writing to text files Implementing mathematical formulas in...

    Assignment Predator / Prey Objectives Reading from and writing to text files Implementing mathematical formulas in C++ Implementing classes Using vectors Using command line arguments Modifying previously written code Tasks For this project, you will implement a simulation for predicting the future populations for a group of animals that we’ll call prey and their predators. Given the rate at which prey births exceed natural deaths, the rate of predation, the rate at which predator deaths exceeds births without a food...

  • In Problem Set 7 you designed and implemented a Message class. This time, let's design and...

    In Problem Set 7 you designed and implemented a Message class. This time, let's design and implement a Mailbox class in a file named Mailbox java. Do the following with this class • You may use the Message class from PS 7. You will have to add new features to the Message class from PS 7 as you work through this problem. You are welcome to start with my sample solution if you wish • Suppose there are multiple mail...

  • C++ Programming Hi! Sorry for all the material attached. I simply need help in writing the...

    C++ Programming Hi! Sorry for all the material attached. I simply need help in writing the Facility.cpp file and the other files are included in case they're needed for understanding. I was able to complete the mayday.cpp file but am stuck on Facility. The following link contains a tar file with the files provided by the professor. Thank you so much in advanced! http://web.cs.ucdavis.edu/~fgygi/ecs40/homework/hw4/ Closer.h: #ifndef CLOSER_H #define CLOSER_H #include <string> #include "gcdistance.h" struct Closer { const double latitude, longitude;...

  • How can we assess whether a project is a success or a failure? This case presents...

    How can we assess whether a project is a success or a failure? This case presents two phases of a large business transformation project involving the implementation of an ERP system with the aim of creating an integrated company. The case illustrates some of the challenges associated with integration. It also presents the obstacles facing companies that undertake projects involving large information technology projects. Bombardier and Its Environment Joseph-Armand Bombardier was 15 years old when he built his first snowmobile...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT