Yahoo India Web Search

Search results

  1. #n=Number of rows def get_triangle(n): space,star=" ","* " for i in range(1,n+1): print((n-i)*space + star*i) get_triangle(5) Where n is the number of rows and I is a variable for the loop, you must print spaces (n-i) times and then add it with stars I times. You'll get the desired pattern as a result.

  2. Mar 15, 2017 · here is my code to draw a right angled triangle def printTriangle(width): j = 0 for i in range(0,width): for j in range(j,i): print("*", end=" ") # single line ...

  3. Nov 1, 2021 · Repeating triangle pattern in Python. Ask Question Asked 3 years ago. Modified 2 years, 10 months ago.

  4. Apr 15, 2015 · Objective: i need to draw a right triangle of numbers. I receive this result : 1 12 123 1234 and i want to draw this shape : 1 21 321 4321 54321 654321 and my code is : ...

  5. Dec 1, 2012 · Triangle number pattern in python. 0. drawing a right angled triangle pattern using python. 5. Trying to ...

  6. Jun 7, 2014 · Indent properly , everything should be inside the function def triangle(): matrix=[[0 for i in range(0,20)]for e in range(0,10)] # This method assigns 0's to all Rows and Columns , the range is mentioned div=20/2 # it give us the most middle columns matrix[0][div]=1 # assigning 1 to the middle of first row for i in range(1,len(matrix)-1): # it goes column by column for j in range(1,20-1): # this loop goes row by row matrix[i][j]=matrix[i-1][j-1]+matrix[i-1][j+1] # this is the formula , first ...

  7. Sep 1, 2013 · This is for a CS101 type Python class. The problem asks the programmer to write for loops which will set up this pattern: 111 11 1 I have example code here which produces. 11111 11111 11111 11111 11111 for i in range(0, 5): X = 0 for j in range(0, 5): X = (X*10)+1 print(X) Here's one of my attempts. Obviously it doesn't work. Please help!

  8. Sep 7, 2019 · I want to make a function to print triangle like the following picture. User can insert the row number of the triangle. The total lenght of first row is must an odd. I try to use below code : def

  9. I solved it. In case anyone has this problem in the future, here was the solution: #Function that draws a triangle with n dots as base def drawTriangularSeries(myTurtle, n): sideLength = 10 x = 0 - sideLength y= 200 myTurtle.penup() myTurtle.goto(x, y) for i in range(n+1): y = 200 myTurtle.goto(x, y) for j in range(i): myTurtle.goto(x, y) myTurtle.dot() y += sideLength myTurtle.forward(sideLength) x += sideLength # Function that draws a series of triangles with dPS as base # def drawTriangle ...

  10. Oct 11, 2016 · drawing a right angled triangle pattern using python. 0. Drawing a right triangle (Python 3) 0.

  1. People also search for