Question: This is in PYTHON. please only fill in the blanks in the code below, because the program will test for the whole code AND the

This is in PYTHON. please only fill in the blanks in the code below, because the program will test for the whole code AND the "calculate" function. This is in PYTHON. please only fill in the blanks inthe code below, because the program will test for the whole codeAND the "calculate" function. Suppose that there are N events to be

Suppose that there are N events to be held this year. The ith event is scheduled from day si to day ti and free food is to be served for that event every day from day si to ti (inclusive). Your task is to find out how many days there are in which free food is served by at least one event. Write a function called calculate that takes a list of strings containing the start and end days to solve this problem. Your main function will only read in the inputs and pass those inputs as a list to the calculate function (see the provided template for more information). Example Let N = 3 events. The first event is held from day 10 to 14, the second event is held from day 13 to 17, and the third event is held from day 25 to 26. The days in which free food is served by at least one event are 10, 11, 12, 13, 14, 15, 16, 17, 25, 26, for a total of 10 days. Note that both events serve free food on days 13 and 14, and therefore they are only counted once. Input The first line the user will supply you is an integer, N, denoting the number of events. Each of the next N lines contains two integers si and ti denoting that the ith event will be held from si to ti (inclusive), and free food is served for all of those days. Output The output contains a single integer which denotes the number of days in which free food is served by at least one event. Sample Input: 3 10 14 13 17 25 26 Output: 10 main.py Load default template... 1 def calculate(events): 2 "events is a list of strings that contains the input given by the user' 3 'Write what calculate does here" 4 num_days = 0 5 6 7 return num_days 8 9 def main(): 10 evlist = [] 11 ''Write the code here to read in the number of events and then the events as 13 strings themselves. When you pass to calculate below, the list should look something like this: 14 ["10 20", "5 10", "37"]. So, you will need to split the input in the calculate function...not here. 15 16 17 print(calculate (evlist)) 18 19 20 # Do not remove this! 21 if _name "__main__": 22 main() 12 23 3: Compare output 0/2 Output differs. See highlights below. 5 Input 5 10 20 10 20 10 20 10 20 11 19 Your output 10 Expected output 11 4: Unit test 0/5 Test calculate as a module. Your output Your code gave 10, and the solution gave 100. 5: Unit test A 0/5 Test calculate as a module #2 Your output Your code gave 10, and the solution gave 6

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!