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

Programming Exercise #3 (Recursive Lines): a.Name your Python program recursive_

ID: 3839775 • Letter: P

Question

Programming Exercise #3 (Recursive Lines):

a.Name your Python program recursive_lines.py.

b.Your program should ask the user for the number of lines to be drawn. Ensure that the number entered is 1 or greater.

c.Hint: Review pages 65-66 to see how to print something without the newline character.

d.Above is an example of what the program interaction might look like. Yours does not have to look exactly like t

his, as long as it works correctly:

Can i get code in online complier

jut put a lin of it

suh that i get a better format of the code

Explanation / Answer

def print_lines(n,noOfDashesLine): #input parameters are number of lines and number of dashes to form a line
  
   if (n >= 1): #check if the number is greater than or equal to 1
       print "-" * noOfDashesLine # print number of dashes in a line
       if n >1: # check if n is greater than 1 and stop when its 0
           print_lines(n-1, noOfDashesLine) # call the function recursively
   else:
       print "Please enter a value greater than or equal to 1" # check for value greater than or equal to 1
      
     
  
  


print_lines(8, 8) # for testing