livepython.net

134. Python Program to Print a Triangle Using a Function with Parameters

MediumArguments

Overview

Combine a default value, a keyword argument and a loop.

Problem Statement

Write a function print_row(count, symbol="*") that prints symbol repeated count times on one line.

Then read a size (a whole number) and a base symbol (one character), one per line. Use your function to print:

  1. A triangle of stars: rows of 1, 2, 3 … up to size stars. Use the default symbol for these.
  2. A base: one row of size copies of the base symbol.

For example, for size 3 and base symbol -:

*
**
***
---

Use input() with no prompt text: the tests type the input for you, and a prompt would end up in your output.

Input

One value per line, in this order: the size, then the base symbol. Example:

3\

Output

The triangle and base shown above.

The tests try 3 different inputs.

Learn this firstChapter 15 · Python Function Parameters and Arguments
solution.py
# write your code here

EXPECTED OUTPUT

1*
2**
3***
4---

YOUR OUTPUT

Press Run to see your output here. Lines are compared with the expected output.