Write program that accepts arguments for a number of rows


Problem

Write program that accepts program arguments for a number of rows, and then prints a triangle of that number of rows. In addition, your program should display the number of asterisk characters that are printed.

Make sure there is no space between the left margin and the widest row.

1. Write some pseudocode that implements this program, even if not (yet!) sure how to write it in code. There's no one right way to write pseudocode, but short English sentences suffice. Odds are your pseudocode will use one or more functions, conditions, Boolean expressions, loops, and/or variables.

2. Read the program argument as input and store in a variable

a. Use the import sys statement and numRows = int(sys.argv[1]) statement to read the program arguments

b. If the input value is less than 1, display the following error message, 'Invalid input value. The number of rows cannot be less than 1.'

c. If the input value is greater than 20, display the following error message, 'Invalid input value. The number of rows cannot be more than 20.'

3. Write code under the pseudocode comments that describe each of the next parts of the program.

4. To add up the number of * characters, create variable before the loop and set it to 0. Inside the loop body, add the number of * printed in that run through the loop to your total variable. When the loop ends, the total will be the sum of all the * characters in your triangle.

Request for Solution File

Ask an Expert for Answer!!
Python Programming: Write program that accepts arguments for a number of rows
Reference No:- TGS03249195

Expected delivery within 24 Hours