Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

At this point, it is a given that your programs should be written using excellent programming style with a program header at the top of

At this point, it is a given that your programs should be written using excellent programming style with a program header at the top of your program, using meaningful variables, and the use of white space and meaningful groupings of statements to make the program readable.

Now that we are writing functions, we expect to see function header comments in addition to the program header. We would like you to follow the convention below for writing your function headers (called \"docstrings\". Please note that this is different than what the book shows. Our method follows the suggested styling found in the pep 8 Python style guide for docstring conventions. A docstring, short for \"documentation string\" is a string literal that serves as documentation of the program. Every function should have a docstring that describes what the function's purpose is, anything that might be unique about the coding of the function, a list and description of the parameters and an indication of what the function returns. Each of your functions should have a docstring that looks something like this. (Take note of where the docstring is - it isafter the function definition, not before like in the textbook).

def myFunction(a, b):

\"\"\"

This function adds the values of the two parameters, a and b, and returns the result.

Parameters: a, b - integer values representing some interesting things

Return Value - the sum of a and b - an integer

\"\"\"

From this point on, all of your programs will be written using functions. All the code (except for a few exceptions) should be put into a function. A function should have one purpose and should be named accordingly. For instance, if you write a function to calculate the area of a triangle, you might name it \"calculateArea()\" or \"calculateTriangleArea()\" but you would not name it \"triangle()\" or \"a()\" or some other non-meaningful name. You should be able to determine from the name of the function what it's purpose is. And the function should ONLY carry out that specified functionality. A function called calculateArea() should not ask the user for the values that it should use to calculate the area (those should be provided via the parameters) and it also should not calculate, say, the perimeter of the triangle as well as the area.

Question 1:

Write a function that draws your ascii art picture from assignment 3. Start with having it draw once. Put the drawing code in a function and call the function. The picture will draw one time. Next, add a parameter that will specify how many times the picture should be drawn. You will need to add a loop in your function that will repeat the picture the number of times that is specified by the parameter.

Be sure your function has a proper docstring. You only need to hand in the finished function (ie. the one that repeats the picture). Your program should contain a main() function. In the main() function, you will call the drawing function so that the picture is drawn 3 times. Add a call at the bottom of your program to call the main function.

This is the code behind my picture as well as the picture

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

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions

Question

What is meant by planning or define planning?

Answered: 1 week ago

Question

Define span of management or define span of control ?

Answered: 1 week ago

Question

What is meant by formal organisation ?

Answered: 1 week ago

Question

What is meant by staff authority ?

Answered: 1 week ago