Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 41e3ebd

Browse files
Merge pull request avinashkranjan#225 from Ayush7614/master
Creating a spiral star using Python
2 parents e22b90b + 4b7eaab commit 41e3ebd

File tree

6 files changed

+84
-0
lines changed

6 files changed

+84
-0
lines changed
9.05 MB
Binary file not shown.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
### This is python programs to create a spiral star and colourful spiral star using python
2+
3+
### First go to your text editor and click on termianl and after clicking on terminal click on the new terminal and write
4+
### First Method Simple Spiral Method
5+
`pip install turtles` this will install turtle module in you system then right program [program 1](https://github.com/Ayush7614/Amazing-Python-Scripts/blob/master/Creating%20a%20spiral%20star%20using%20Python/program1.py)then it succesfully runs.
6+
7+
<img align="center" alt="JPEG" src="https://github.com/Ayush7614/Amazing-Python-Scripts/blob/master/Creating%20a%20spiral%20star%20using%20Python/Spiral%20Star.jpeg?raw=true" width="400" height="420" />
8+
9+
10+
11+
### Second Method Colourful Spiral Method
12+
`pip install turtles` this will install turtle module in you system then right program [program 2](https://github.com/Ayush7614/Amazing-Python-Scripts/blob/master/Creating%20a%20spiral%20star%20using%20Python/program2.py)then it succesfully runs.
13+
14+
<img align="center" alt="JPEG" src="https://github.com/Ayush7614/Amazing-Python-Scripts/blob/master/Creating%20a%20spiral%20star%20using%20Python/WhatsApp%20Image%202021-01-10%20at%20190031.jpeg?raw=true" width="400" height="420" />
29.8 KB
Loading[フレーム]
44.4 KB
Loading[フレーム]
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# importing turtle module
2+
import turtle
3+
4+
# number of sides
5+
n = 20
6+
7+
# creating instance of turtle
8+
pen = turtle.Turtle()
9+
10+
# loop to draw a side
11+
for i in range(n):
12+
# drawing side of
13+
# length i*10
14+
pen.forward(i * 20)
15+
16+
# changing direction of pen
17+
# by 144 degree in clockwise
18+
pen.right(144)
19+
20+
# closing the instance
21+
turtle.done()
22+
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
from turtle import *
2+
import random
3+
4+
speed(speed ='fastest')
5+
6+
def draw(n, x, angle):
7+
# loop for number of stars
8+
for i in range(n):
9+
10+
colormode(255)
11+
12+
# choosing random integers
13+
# between 0 and 255
14+
# to generate random rgb values
15+
a = random.randint(0, 255)
16+
b = random.randint(0, 255)
17+
c = random.randint(0, 255)
18+
19+
# setting the outline
20+
# and fill colour
21+
pencolor(a, b, c)
22+
fillcolor(a, b, c)
23+
24+
# begins filling the star
25+
begin_fill()
26+
27+
# loop for drawing each star
28+
for j in range(5):
29+
30+
forward(5 * n-5 * i)
31+
right(x)
32+
forward(5 * n-5 * i)
33+
right(72 - x)
34+
35+
# colour filling complete
36+
end_fill()
37+
38+
# rotating for
39+
# the next star
40+
rt(angle)
41+
42+
43+
# setting the parameters
44+
n = 30 # number of stars
45+
x = 144 # exterior angle of each star
46+
angle = 18 # angle of rotation for the spiral
47+
48+
draw(n, x, angle)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /