Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Random night stars with python turtle

# Random night stars with python turtle 
import turtle as tu
import random


sc = tu.Screen()
sc.bgcolor("black")

bn = tu.Turtle()
bn.pensize(3)
bn.color("blue", "blue")
bn.speed(0)
li = []

def star(lenth):
      bn.begin_fill()
      for i in range(5):
            bn.fd(lenth)
            bn.rt(144)
      bn.end_fill()

for i in range(120):
      x = random.randint(-300, 300)
      y = random.randint(-300, 300)
      bn.penup()
      bn.goto(x, y)
      li.append(bn.pos())
      bn.pendown()
      fn = random.randint(5, 22)
      for j in li:
            if (abs(bn.pos()) - abs(j)) <= fn + 10 :
                  #print(f"pos >{j}")
                  continue
      
      star(fn)


sc.exitonclick()
Comment

PREVIOUS NEXT
Code Example
Python :: pandas filter rows by value 
Python :: python object of type set is not json serializable 
Python :: bar plot group by pandas 
Python :: split and only grab first part of string 
Python :: How to Use Python Glob Module 
Python :: Python Date object to represent a date 
Python :: python error handling 
Python :: maximum element in dataframe row 
Python :: line plot python only years datetime index 
Python :: sqlite operational error no such column 
Python :: python get 1st arg 
Python :: layer enable time arcpy 
Python :: Comparison of two csv file and output with differences? 
Python :: django data from many to many field in template 
Python :: is vs == python 
Python :: update xls file using python 
Python :: r named chr to dataframe 
Python :: how to filter queryset with foreign key in django 
Python :: numpy transpose 
Python :: up and down arrow matplotlib 
Python :: append a list to a list python 
Python :: Reverse an string Using Stack in Python 
Python :: cufflink install python jupyter 
Python :: py string in list 
Python :: python gzip a file 
Python :: code for merge sort 
Python :: add a new column to numpy array 
Python :: python how to sum two lists 
Python :: train_test_split from sklearn.selection 
Python :: django jinja else if template tags 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =