Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!