Write a function visit_length (visit) to determine the length of a person's visit to a particular location. The function takes one argument, visit, which is a 7-tuple formatted as described above. The function should return the length of the visit as a tuple of integer values, corresponding to hours and minutes if the visit is valid, or None if the visit is not valid. A valid visit is one with a positive length (ie, more than zero minutes). For example, visit_length(("Irene", "Skylabs", 3, 9, 15, 13, 45)) (4, 30) which means that Irene spent 4 hours and 30 minutes at Skylabs from 9:15am to 1:45pm on the third day of the outbreak. Assumptions: • You can assume that the input arguments are syntactically correct given the definitions and assumptions on the previous slides. Here are some example calls to the function: >>> print(visit_length(('Russel', 'Foodigm', 2, 9, e, 10, e))) (1, 0) >>> print(visit_length(('Natalya', 'Foodigm', 2, 9, 30, 9, 45))) (e, 15) >>> print(visit_length(('Chihiro', 'Foodigm', 2, 8, 45, 9, 15))) (в, з0) >>> print(visit_length(('Aravinda', 'Afforage', 2, 9, e, 10, 0))) (1, e) >>> print(visit_length(('Chihiro', 'Foodigm', 2, 8, 30, 9, e))) (0, зе) >>> print(visit_length(('Natalya', 'Afforage', 2, 15, 10, 14, 45))) * the length of the visit is negative None >>> print(visit_length(('Aravinda', 'Nutrity', 2, 15, 10, 15, 10))) # the length of the visit is zero None

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Write a function visit_length (visit) to determine the length of a person's visit to a particular location.
The function takes one argument, visit, which is a 7-tuple formatted as described above.
The function should return the length of the visit as a tuple of integer values, corresponding to hours and minutes if the visit is valid, or None if the visit is not valid. A valid visit is one
with a positive length (ie, more than zero minutes).
For example,
visit_length ( ("Irene", "Skylabs", 3, 9, 15, 13, 45))
|(4, 30)
which means that Irene spent 4 hours and 30 minutes at Skylabs from 9:15am to 1:45pm on the third day of the outbreak.
Assumptions:
• You can assume that the input arguments are syntactically correct given the definitions and assumptions on the previous slides.
Here are some example calls to the function:
>>> print (visit_length(('Russel', 'Foodigm', 2, 9, 0, 10, 0)))
(1, 0)
>>> print (visit_length(('Natalya', 'Foodigm', 2, 9, 30, 9, 45)))
(0, 15)
>>> print(visit_length(('Chihiro', 'Foodigm', 2, 8, 45, 9, 15)))
(0, 30)
>>> print (visit_length(('Aravinda', 'Afforage', 2, 9, e, 10, 0)))
(1, 0)
>>> print (visit_length(('Chihiro', 'Foodigm', 2, 8, 30, 9, 0)))
(0, 30)
>>> print (visit_length(('Natalya', 'Afforage', 2, 15, 10, 14, 45)))
# the length of the visit is negative
None
>>> print (visit_length(('Aravinda', 'Nutrity', 2, 15, 10, 15, 10)))
# the length of the visit is zero
None
Transcribed Image Text:Write a function visit_length (visit) to determine the length of a person's visit to a particular location. The function takes one argument, visit, which is a 7-tuple formatted as described above. The function should return the length of the visit as a tuple of integer values, corresponding to hours and minutes if the visit is valid, or None if the visit is not valid. A valid visit is one with a positive length (ie, more than zero minutes). For example, visit_length ( ("Irene", "Skylabs", 3, 9, 15, 13, 45)) |(4, 30) which means that Irene spent 4 hours and 30 minutes at Skylabs from 9:15am to 1:45pm on the third day of the outbreak. Assumptions: • You can assume that the input arguments are syntactically correct given the definitions and assumptions on the previous slides. Here are some example calls to the function: >>> print (visit_length(('Russel', 'Foodigm', 2, 9, 0, 10, 0))) (1, 0) >>> print (visit_length(('Natalya', 'Foodigm', 2, 9, 30, 9, 45))) (0, 15) >>> print(visit_length(('Chihiro', 'Foodigm', 2, 8, 45, 9, 15))) (0, 30) >>> print (visit_length(('Aravinda', 'Afforage', 2, 9, e, 10, 0))) (1, 0) >>> print (visit_length(('Chihiro', 'Foodigm', 2, 8, 30, 9, 0))) (0, 30) >>> print (visit_length(('Natalya', 'Afforage', 2, 15, 10, 14, 45))) # the length of the visit is negative None >>> print (visit_length(('Aravinda', 'Nutrity', 2, 15, 10, 15, 10))) # the length of the visit is zero None
Each visit by a person to a location results in the following data being generated when they scan
a QR code with their phone:
• an ID associated with that person
• an ID associated with the location
• an integer value corresponding to the day (note that this is not a calendar date, but rather
increments from "day zero" of the outbreak)
• a pair of integer values, corresponding to the time (hours and minutes, in 24 hour time)
that the person arrived at the location
• a pair of integer values corresponding to the time (hours and minutes, in 24 hour time)
that the person departed from the location
In this project, we will represent this data in a 7-tuple. For example, the tuple:
("Irene", "Skylabs", 3, 9, 15, 13, 45)
tells us that Irene visited Skylabs on day 3 of the outbreak, arriving at 9:15am and departing at
1:45pm (ie, 13:45 in 24 hour time).
Another example, the tuple:
("Xaiton", "CoffeX", 10, 2, 5, 23, 59)
tells us that Xaiton visited CoffeX on day 10 of the outbreak, arriving at 2:05am and departing at
11:59pm. If Xaoitan had stayed past midnight, there would be another entry for day 11, starting
at 00:00am.
In this project, you may always assume that these 7-tuples are correctly formatted; that is, they
will consist of two strings followed by five non-negative integers. The two values
corresponding to hours (indices 3 and 5) will be in the range [0, 23], and the two values
corresponding to minutes (indices 4 and 6) will be in the range [0, 59]. Please note: 2am is
recorded as 2 rather than 02, and 5 minutes is recorded as 5 rather than 05.
You may assume that all visits are syntactically valid and that no visits for a single person are
overlapping in time, although a successive visits may end and start at the same time
Transcribed Image Text:Each visit by a person to a location results in the following data being generated when they scan a QR code with their phone: • an ID associated with that person • an ID associated with the location • an integer value corresponding to the day (note that this is not a calendar date, but rather increments from "day zero" of the outbreak) • a pair of integer values, corresponding to the time (hours and minutes, in 24 hour time) that the person arrived at the location • a pair of integer values corresponding to the time (hours and minutes, in 24 hour time) that the person departed from the location In this project, we will represent this data in a 7-tuple. For example, the tuple: ("Irene", "Skylabs", 3, 9, 15, 13, 45) tells us that Irene visited Skylabs on day 3 of the outbreak, arriving at 9:15am and departing at 1:45pm (ie, 13:45 in 24 hour time). Another example, the tuple: ("Xaiton", "CoffeX", 10, 2, 5, 23, 59) tells us that Xaiton visited CoffeX on day 10 of the outbreak, arriving at 2:05am and departing at 11:59pm. If Xaoitan had stayed past midnight, there would be another entry for day 11, starting at 00:00am. In this project, you may always assume that these 7-tuples are correctly formatted; that is, they will consist of two strings followed by five non-negative integers. The two values corresponding to hours (indices 3 and 5) will be in the range [0, 23], and the two values corresponding to minutes (indices 4 and 6) will be in the range [0, 59]. Please note: 2am is recorded as 2 rather than 02, and 5 minutes is recorded as 5 rather than 05. You may assume that all visits are syntactically valid and that no visits for a single person are overlapping in time, although a successive visits may end and start at the same time
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY