Computers and Technology

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 (

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 12:10, tragesserj
1. declare a constant named cents_per_pound and initialize with 25. 2. get the shipping weight from user input storing the weight into shipweightpounds. 3. using flat_fee_cents and cents_per_pound constants, assign shipcostcents with the cost of shipping a package weighing shipweightpounds.
Answers: 2
image
Computers and Technology, 24.06.2019 02:10, ttangelique
Which sentences describe the things you need to ensure while creating a sketch and a drawing? while an artistic or creative drawing is a creative expression, a technical drawing is an informative expression. you need to create accurate and neat drawings to convey accurate information. a technical drawing clearly conveys its meaning or information, and does not leave room for interpretation maintain a good speed while creating drawings
Answers: 1
image
Computers and Technology, 24.06.2019 09:00, king514
Technician a says that a new replacement part is always good. technician b says that sometimes recent repair work will be the cause of a complaint. who is correct? a. both technicians a and b b. technician a c. technician b d. neither technician a nor b
Answers: 3
image
Computers and Technology, 24.06.2019 10:00, genyjoannerubiera
In which view can you see speaker notes?
Answers: 1
Do you know the correct answer?
Question 1 (already finished) Extract: "Data" From: "Introduction to Data Science" def question1(tex...

Questions in other subjects:

Konu
Mathematics, 17.12.2020 01:00
Konu
Biology, 17.12.2020 01:00