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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 19:20, ChaosMind
Write a program that reads a file consisting of students’ test scores in the range 0–200. it should then determine the number of students having scores in each of the following ranges: 0–24, 25–49, 50–74, 75–99, 100–124, 125–149, 150–174, and 175–200. output the score ranges and the number of students. (run your program with the following input data: 76, 89, 150, 135, 200, 76, 12, 100, 150, 28, 178, 189, 167, 200, 175, 150, 87, 99, 129, 149, 176, 200, 87, 35, 157, 189.)
Answers: 3
image
Computers and Technology, 23.06.2019 00:00, dubouuu
Donna and her team of five have invented a new gadget for the science exhibition in their college. which intellectual property right will protect their invention?
Answers: 1
image
Computers and Technology, 23.06.2019 03:50, nakeytrag
Iam a bacterium. i cause stomach cramps and diarrhea. i am caused by eating rotten foodssuch as chicken, fish, or eggs. sometimes turtles carry my bacteria. what am i?
Answers: 2
image
Computers and Technology, 23.06.2019 22:30, delawdermia27
The output voltage of a power supply is assumed to be normally distributed. sixteen observations are taken at random on voltage are as follows: 10.35, 9.30, 10.00, 9.96, 11.65, 12.00, 11.25, 9.58, 11.54, 9.95, 10.28, 8.37, 10.44, 9.25, 9.38, and 10.85
Answers: 1
You know the right answer?
Question 1 (already finished) Extract: "Data" From: "Introduction to Data Science" def question1(tex...

Questions in other subjects:

Konu
Chemistry, 04.04.2021 01:10
Konu
Mathematics, 04.04.2021 01:10
Konu
Mathematics, 04.04.2021 01:10
Konu
Chemistry, 04.04.2021 01:10
Konu
Mathematics, 04.04.2021 01:10