Article directory
foreword
There are some things that may be slow to post recently . The turtle library is not used today, and the print() method is used today.
1. Rhombus
The rhombus is actually equivalent to the combination of four triangles in different directions. Drawing a rhombus is very simple, as long as you know the frame, you can write it.
n = 10
for i in range(1, 2*n, 2):
print(('*' * i).center(3 * n))
s = range(1, 2*(n-1), 2)
for i in s[::-1]:
print(('*' * i).center(3 * n))
2. Draw a triangle
1. Isosceles triangle
If you understand the code of the rhombus, then the triangle is simple.
m = 10
for i in range(1, m+1):
for x in range(1, m+1-i):
print(' ', end='')
for j in range(1, 2*i):
print('*', end='')
print()
another:
n=8
for i in range(n):
print((' * '*i))
for i in range(n, 0, -1):
print((' * '*i))
2. Right triangle
m = 9
for i in range(1, m+1):
for j in range(1, 2*i):
print('*', end='')
print()
Summarize
Therefore, as long as the framework is mastered, everything else is not difficult.
Everything is inseparable from methods, and the world cannot be separated from order. -- Swift