Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON - Write a function named split that accepts a list of integers as a parameter and returns a new list twice as large as

PYTHON - Write a function named split that accepts a list of integers as a parameter and returns a new list twice as large as the original, replacing every integer from the original list with a pair of integers, each half the original. If a number in the original list is odd, then the first number in the new pair should be one higher than the second so that the sum equals the original number. For example, if a variable named a refers to a list storing the values [18, 7, 4, 24, 11], the call of split(a) should return a new list containing [9, 9, 4, 3, 2, 2, 12, 12, 6, 5]. (The number 18 is split into the pair 9, 9, the number 7 is split into 4, 3, the number 4 is split into 2, 2, the number 24 is split into 12, 12 and the number 11 is split into 6, 5.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

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

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions