Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Extract the timestamp and the phone number from each specific line into separate variables (e.g., timestamp and phone_number). For example, you can use the split

Extract the timestamp and the phone number from each specific line into separate variables (e.g., timestamp and phone_number). For example, you can use the split method to separate the line into the two constituents (carefully choose where to split). You can assign the constituents in a single statement just like this: x, y = 'Hello, World'.split(', ') # `x` is assigned with 'Hello' # `y` with 'World' Implement an if statement that checks the phone_number's area code and evaluates to True if the area code matches the argument provided to the area_code parameter (else it evaluates to False). Validate your work by printing the lines to the terminal

You should see a similar output as before. However, there should only be the phone numbers with the area code matching the one provided in the argument.

Next, parse the timestamp into a datetime object. This will enable you to easily determine if the call happened between certain hours in a day. You can also refer to the following example

Modify the if statement to also check if the phone call happened between the hour of the day indicated by the start argument (included) and before the hour indicated by the end argument (not included).

Validate your work by printing the lines to the terminal.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Heres the Python code that addresses the requirements Python import datetime def extractandf... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Discovering Advanced Algebra An Investigative Approach

Authors: Jerald Murdock, Ellen Kamischke, Eric Kamischke

1st edition

1559539844, 978-1604400069, 1604400064, 978-1559539845

More Books

Students also viewed these Programming questions

Question

Describe the New York Stock Exchange.

Answered: 1 week ago