About 540,000 results
Open links in new tab
  1. python - For/While Loops to make *-triangles - Stack Overflow

    Dec 6, 2015 · For an assignment in a coding class, I was supposed to find a way to have Python make a triangle of asterisks, looking like this: xxx . Whatever I do with my code, however, I can't manage to pull that off. The best I can get is: All of this has to be using only for-loops and while-loops, like what I'm using here. The code I'm using is.

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

    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, ' ')

  3. Create a Triangle Using Python for Loop - Online Tutorials Library

    Learn how to create a triangle shape using a for loop in Python with this easy-to-follow guide.

  4. How to make a triangle using a for loop in Python

    Aug 6, 2013 · def triangle(c, n): for i in xrange(n, 0, -1): print c * i triangle("X", 5) prints: XXXXX XXXX XXX XX X

  5. How to Draw a Triangle in Python Turtle - Quick Programming …

    How to Draw a Triangle in Python Turtle Python has a simple pen drawing library called turtle. Using simple movement commands, we can draw shapes using the python turtle library.

  6. Python Tutorial: How to Use turtle Library in Python to Draw Triangles

    Oct 24, 2024 · Learn to draw triangles in Python using the turtle library. This tutorial covers step-by-step instructions for beginners. Perfect for usavps users!

  7. Draw Triangle In Python Using Turtle Module - Pythondex

    Jul 3, 2023 · In this tutorial we will see how to draw a triangle in python turtle, turtle module is a GUI python library which can be used to draw anything from characters, cartoons, shapes and other objects. Python Code To Draw Triangle

  8. Make Triangle With Python - DEV Community

    Jun 8, 2019 · First, let's take a value from the user and make a triangle that extends by the given value. To do this, we will use the input function, a method provided by python. "input" function allows you to receive input from the user.

  9. How to Draw a Triangle in Python — Quick Guide - Maschituts

    Oct 1, 2023 · To draw a triangle in Python, use this code: import turtle . turt = turtle.Turtle() . #instantiate a new object . turt.fillcolor("cyan") #set the color of the triangle to cyan . turt.left(120) . turt.forward(150) . turt.end_fill() . Initially, we create a new turtle object. Then, we set the shape’s color to cyan and call the begin_fill () method.

  10. Create a triangle - Introduction to Python - profound.academy

    Create a triangle Modify the function to return a 2D list which itself represents a triangle filled with the same symbol passed to the function. The function should accept two arguments - the height of the triangle and the symbol which needs to be filled in that triangle.

  11. Some results have been removed
Refresh