Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 Restrictions shape _ echo ( arg 1 , arg 2 , arg 3 ) ( spec continues on next page ) 5 Part 2

1 Restrictions shape_echo(arg1, arg2, arg3)
(spec continues on next page)5 Part 2: Draw Your Own Reference Diagrams
For these diagrams, you may either submit a set of image files, or a single PDF
that has all of them. Whatever you do, make sure to clearly label each one.
5.1 Diagram A
Draw a reference diagram for the final state of the variables, after this snippet
of code runs.
5.2 Diagram B
Draw a reference diagram for the final state of the variables, after this snippet
of code runs.
5.3 Diagram(s) C
Draw multiple reference diagrams for this snippet of code; draw one for each
step where you see the DRAW HERE comment. (Inside the loop, draw it once for
each iteration of the loop.)
For this problem, also write out what this code will print.
(spec continues on next page)
Do not use any of the following Python features in your code:
import of libraries (except if explicitly allowed)
List comprehensions
Generators
Type annotations
with open - Explicitly open and close the file instead
Ternary operator
Recursion (until we study it)
Lambda expressions
Nested functions
Jlosures
2 Overview
In this project, you will be practicing with reading and creating reference di-
agrams. First, we will give you a series of reference diagrams, and you will
produce a function to build each one; some of the functions will have parame-
ters, while others will not.
Second, we will give you a few snippets of code, and you will draw the
reference diagram for each; in some cases, you will simply produce a reference
diagram for the final state, but in others you will produce multiple diagrams,
to represent various steps in the process.
3 Background - A File of Functions???
We all have seen that we can write a program inside a Python file; we define
the main() function, and then we call it ourselves.
But another important skill for a programmer is the ability to write a func-
tion which will be utilized in somebody else's program. In this case, you define a
file, and define functions inside of it, but you do not call the function yourself.
Instead, a main() function, in some other file, calls your function when it wants
to.(Of course, this means that the other file has to import your file.)
For the first part of this Short Project, you will be defining several functions
in one file. Each of my testcases will import your file, and then call one or more
of the functions. It will then examine things about the data structure that you
return, and maybe print some things out.
IMPORTANT:
When designing a function to be called by other code, always be clear about
what the caller expects you to do. Are you supposed to print something out?
Fine - call print() as necessary (but don't print more than you are asked to
do!) But if you are only asked to return a value, then return it, and let the
caller figure out what to do with the value that you give them.
4 Part 1: Shape Functions
In
shapes.py write a series of functions, each of which builds a data structure
of some sort; we've drawn the picture for each data structure below. Some of
the functions take one or more parameters; in that case, drop the values into
the data structure at the proper location. You should not do anything to these
parameters (other than putting them in the proper locations); you know nothing
about what they contain.
NOTE: All of the rectangles in these pictures represent Python lists (that is,
arrays). Do not attempt to use tuples, classes, or any other type.
NOTE: Notice that some of these functions take parameters. Those that take
parameters will put those parameters at specific locations within the shape that
you must generate.
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

SQL Database Programming

Authors: Chris Fehily

1st Edition

1937842312, 978-1937842314

More Books

Students also viewed these Databases questions