subject

Question 1 (already finished) Extract: "Data" From: "Introduction to Data Science" def question1(text): return (text[16:20], slice(16,20,1)) Notes and hints: 'extract' means return the substring that is to be 'extracted' (i. e. removed) from the 'From' text. if you want to debug your answers, just do the following (in main. py) import lesson as ans result = ans. question1("Introduction to Data Science") print(result[0] == 'Data') # looking for True you can also test each part of your expect = "Data" word = "Introduction to Data Science" s1 = slice(16,20,None) value = word[s1] if (value != expect): print("Bad Slice", expect, value) value = word[16:20] if (value != expect): print("Bad Index", expect, value) In each of your answers, you should ONLY use the slice function as part of the final return and you must use the parameter text in the return statement. do some answer(text): idx = some calculation() return (text[idx:20], slice(idx,20,1)) Bonus: ideally, you should solve each of these without any hardcoded numbers other than the step amount: Extract: "Data" From: "Introduction to Data Science" def question1(text): word = 'Data' wl = len(word) idx = text. find(word) return (text[idx:idx+wl], slice(idx, idx+wl, 1)) Question 2: Extract: "ar" From: "Orange" def question2(text): return (

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 25.06.2019 19:00
Which of the following statements is true of field names? a. they should be as short as possible. b. they should use abbreviations. c. they should use words such as name and date. d. they should have special characters.
Answers: 1
question
Computers and Technology, 25.06.2019 19:30
What are the two types of cache memory
Answers: 1
question
Computers and Technology, 26.06.2019 02:30
Melissa needs to put a topic name on her email that she will send will to her teacher . choose the name of the field
Answers: 1
question
Computers and Technology, 26.06.2019 03:30
What is your reflection on the nature of ict in the context of your life, society, and professional tracks
Answers: 1
You know the right answer?
Question 1 (already finished) Extract: "Data" From: "Introduction to Data Science" def question1(tex...
Questions
question
Mathematics, 18.03.2021 02:40
question
English, 18.03.2021 02:40
question
Mathematics, 18.03.2021 02:40
question
Mathematics, 18.03.2021 02:40
question
Mathematics, 18.03.2021 02:40
question
Mathematics, 18.03.2021 02:40
Questions on the website: 13722363