Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON: Write a function first_half that takes a list and returns a new list (use the slice operator) with just the items from the first

PYTHON:

Write a function first_half that takes a list and returns a new list (use the slice operator) with just the items from the first half of the original list. For example, first_half([1,2,3,4]) would return [1, 2] and first_half([7,8,9]) should return [7].

image text in transcribed

Write a function first_half that takes a list and returns a new list (use the slice operator) with just the items from the first half of the original list. For example, first_half([1,2,3,4]) would return (1, 2] and first_half([7,8,9]) should return [7]. Save & Run 1/31/2021, 11:53:12 PM - 43 of 51 1 def first_half(alist): 2 return alist[:2] 3 Activity: 4.20.4.4 ActiveCode (fuct_ac_list_first_half) Result Actual Value Expected Value Notes Pass [1, 2] [1, 2] first_half([1,2,3,4]) Fail [7,8] [7] first_half([7,8,9]) Pass 0 first_half(I) Fail [6] 0 first_half([6]) Pass [1, 2] [1, 2] first_half([1,2,3,4,5)) Fail [1, 2] [1, 2, 3] first_half([1,2,3,4,5,6]) You passed: 50.0% of the tests

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Database And Expert Systems Applications 24th International Conference Dexa 2013 Prague Czech Republic August 2013 Proceedings Part 1 Lncs 8055

Authors: Hendrik Decker ,Lenka Lhotska ,Sebastian Link ,Josef Basl ,A Min Tjoa

2013 Edition

3642402844, 978-3642402845

More Books

Students also viewed these Databases questions

Question

DESCRIBE behaviour that could constitute haras sment.

Answered: 1 week ago

Question

=+ f. instituting laws against driving while intoxicated

Answered: 1 week ago