Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The purpose of this question is to write a python program (script) that draws a series of triangles. Write a function that begins with the

The purpose of this question is to write a python program (script) that draws a series of

triangles.

Write a function that begins with the header:

def getPosInt(prompt):

This function returns a positive integer if the user enters a positive. The function repeatedly

asks for a positive integer until the user enters either a positive.

Hint: Strip the leading and trailing whitespace from the input from the user.

If value is the value returned by input the function must perform the following tests:

? if value is not an integer display value of value and the message 'is not an integer!'.

? if value is an integer but is less than zero display value of value and the message 'is

not a positive integer!'.

? if eval(value, {}, {}) causes an exception display the message 'Invalid input!'.

? if value is an empty string (that is the user did not type anything in and pressed

return/enter) display the message 'Missing input!'

Note: You should be able to modify an example given in class to do this.

Write a function that begins with the header:

def drawTriangle(size):

The function is given the size of a triangle to draw. The size must be a positive integer. For

example if size is 3 the output should be

***

**

*

and if size is 5 the output should be

*****

****

***

**

*

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 Server T-SQL Recipes

Authors: David Dye, Jason Brimhall

4th Edition

1484200616, 9781484200612

More Books

Students also viewed these Databases questions

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago