An isosceles right triangle is a right triangle that consists of two equal-length legs. Given a number , we want to sketch an isosceles right triangle with two legs of length . Specifically, you are required to write a function named trisketch
that accepts one integer as an argument and sketches the triangle with star symbol (*
) to the output stream. Note that the right angle of the triangle should be at the bottom-left of your output.
You can start with this template code and ensure your code can run correctly within this template:
def trisketch(n):
# your code here
# Note that the following code is for local testing purposes only. You should leave this part of code unchanged and not submit it to the OJ system.
T = int(input())
for t in range(T):
n = int(input())
trisketch(n)
Please note that you only have to submit the definition of the trisketch
function to the OJ system. The rest of the code is for your local testing purposes only.
Input Specification
The first line of the input gives the number of test cases, , and then test cases follow.
For each test case, there will be a single line containing an integer that indicates the length of the two equal-length legs of an isosceles right triangle.
Constraints
Output Specification
For each test case, output an isosceles right triangle with two legs of length n using star symbol (*
). Ensure that the right angle of the triangle is positioned at the bottom-left of your output.
Sample Input
2
3
5
Sample Output
*
**
***
*
**
***
****
*****
Hint
function
for-loop
string repetition
Comments