Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You will code the following functions in the programming language Python. For help with the syntax you will need to complete the code, please read

You will code the following functions in the programming language Python. For help with
the syntax you will need to complete the code, please read the document "Code Help" that
is included with this assignment. Turn in your assignment as a PDF file.
You can call this function whatever you want, but I'll call it bit'ToTy. The input will
be a bit string, which we will represent as a list of 0's and 1's. Your function will
interpret each 0 as a tree and each 1 as a fence in our "trees and yards" problem. The
output of your function will be a list, where each component is the number of trees
in a particular yard. For instance, if our bit string is 0010100010, then we have four
yards (since we have three fences, one for each 1 in the bit string). The first yard has
two trees (two 0's); the second yard has one tree; the third yard has three tress; and
the fourth yard has one tree. Thus, if the input to the function bitToTy is the list
0,0,1,0,1,0,0,0,1,0, then the output will be the list 2,1,3,1.
Remember that if you have a 1 on either end, that indicates a yard with no trees in it.
So if you have the input 1,0,0,1,0,1, the output will be 0,2,1,0.
Now let's try a function that I'll call ty'ToBit. The input will be a list, where each
component is the number of trees in that particular yard. The input will be the bit
string that corresponds to the distribution of trees, where "1" is a fence and "0" is a
tree. For instance, if your input is 2,1,0,3, your output will be 001011000.
Make sure your functions are well documented. You should have one-line comments (using
the single line comments with #) written in complete sentences that describe what cach line
of code does. You may not import any packages to help you wilh your function.
image text in transcribed

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

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

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

a. What are S, F, and P?

Answered: 1 week ago

Question

Write formal proposal requests.

Answered: 1 week ago

Question

Write an effective news release.

Answered: 1 week ago

Question

Identify the different types of proposals.

Answered: 1 week ago