Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

ALL IN PYTHON****** Your program is required to read a single line of input from

ID: 3585763 • Letter: A

Question

ALL IN PYTHON******

Your program is required to read a single line of input from the user (without printing any input prompt), which is expected to be a positive integer n (i.e., n will be neither zero nor negative). You can freely assume that your program will be given a positive integer, and it's not important what you do in any other case; we'll only test your program with positive integer input. You can also freely assume that n will not be greater than 999.

After reading the input, your program will print a downward block diagonal of size n. The precise format of a downward block diagonal is best demonstrated with an example. If the input to the program was 4, the output would look like this:

A few additional requirements apply:

Though I've indented the text above to set it apart from the rest of the project write-up, note that the left edge of the topmost block must begin in the leftmost column of the output (i.e., it should not be indented at all).

There must be no whitespace (e.g., spaces or tabs) at the end of each line of output.

There must be a newline on the end of each line, including the last one.

This is a complete specification of the structure of a downward block diagonal; the description is enough to solve the problem, so we will not be answering any additional questions about its structure. However, we are providing a tool that will give you a basic understanding of whether your program is reading the correct input and generating output in the correct format.

WHAT I HAVE SO FAR:

st = "+-+ | | +-+-+"
n=input("No of times to repeat:")
print(st * int(n))

but it doesn't indent like the picture.. how do i make it look like that when it repeats n times?

Explanation / Answer

main.py

value = raw_input() #user input

num=int(value) #Converting the value into string

for i in range(0,num):
  
if i == 0: #prints the first block
print "+ - +"
print "| |"
print "+ - +",
  
if i>0:
print "- +"
for j in range (0,i):
print " ",
print "| |"
for j in range (0,i):
print " ",
print "+ - +",
if i == num-1: #goes to the newline at the end of execution
print ""
  
print "just to test it's in new line.you can remove it"

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote