Ask coding questions

← Back to all posts
Patterns in Python
cheezburstpizza (0)

How can we make number patterns in python? Can someone explain code to me? codes such as/similar to this. Include explanation in comments(#) of python .I want to know about loop in a loop ,its functioning.
1
1 2
1 2 3


And

4 3 2 1
4 3 2
4 3
4

Comments
hotnewtop
RhinoRunner (692)

what do you mean by "patterns"? You could mean a million things. Please add more information to your question.

Codemen (4)

Example:

import turtle 

spiral = turtle.Turtle()
spiral.pencolor("blue")

for i in range(40):
  spiral.forward(i * 10)
  spiral.right(144)

turtle.done()

the code basically represents a dot of some sort making a star repetitively. The numbers, [144, 40, 10] are the positions it stops at. the letters, [i], represents the "thing" in an equation \ give my recent post a thumbs up if this helped!