About 43,800 results
Open links in new tab
  1. How to print a Triangle Pyramid pattern using a for loop in Python ...

    I am using the following for loop code to print a star pattern and the code is working perfectly fine. Here is my code: for i in range (1,6): for j in range (i): print ("*", end=...

  2. How to print a triangle in python? - Stack Overflow

    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 …

  3. Python for-loop to print a triangle - Stack Overflow

    Apr 13, 2015 · Here is a program that I had to make for my weekend assignment. It gives a pretty decent reverse triangle as well. def reverse_triangle(n): r=n/2+1 for i in range(r-1,0,-1): print" …

  4. How to print the Triangle in Python - Stack Overflow

    May 31, 2021 · I am new to the python. I tried to print a * triangle but wasn't unable to do so. First I tried this: new = int (input ("Enter the line of stars \n")) for i in range (1, new + 1): if (ne...

  5. How do i print out a number triangle in python? - Stack Overflow

    How do i print out a number triangle in python using a loop based program? It is not a homework assignment or anything its just an exercise from the book i have been trying to do but have not …

  6. How to make a triangle of x's in python? - Stack Overflow

    Dude It's super easy: def triangle(n): for i in range(1, n +1): print ' ' * (n - i) + 'x' * i Or even: def triangle(n): for i in range(1, n +1): print ('x' * i).rjust(n, ' ') output for triangle(5): x xx xxx xxxx …

  7. Python Code for Triangles - Stack Overflow

    Dec 31, 2015 · As you're using Python 3, you have some nice options with the print () function:

  8. python - Print a numerical triangle - Stack Overflow

    Apr 26, 2022 · You are given a positive integer (example: N = 6). Print a numerical triangle of height like the one below: 1 22 333 4444 55555 Use no more than two lines of code. Use a for …

  9. Drawing a right triangle (Python 3) - Stack Overflow

    Mar 30, 2017 · I'm having a bit of an issue. I'm trying to make this program output a right triangle based on the height and symbol that is specified by the user, but whenever I enter the symbol …

  10. How do I print a list in a triangular shape in python?

    Jul 9, 2010 · I have a code that generates a list of values to form a Romberg Triangle. The list is always a triangular length (3, 6, 10, 15). How do I print a list like this in triangular form? What I …

Refresh