draw star

star

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import turtle
 
def draw_star(some_turtle):
    for i in range(1, 6):
        some_turtle.forward(100)
        some_turtle.right(144)
 
def draw_art():
    window = turtle.Screen()
    window.bgcolor("red")
     
    brad = turtle.Turtle()
    brad.shape("arrow")
    brad.color("blue")   
    brad.speed(5)
    for i in range(1, 11):
        draw_star(brad)
        brad.right(36)
 
    # angie = turtle.Turtle()
    # angie.shape("arrow")
    # angie.color("blue")
    # angie.circle(100)
 
    # triangle = turtle.Turtle()
    # angie.shape("arrow")
    # angie.color("blue")
     
    # for x in range(0, 3):
    #    brad.forward(100)
    #    brad.right(240)
 
    window.exitonclick()
 
draw_art()

open file and read the content from the file.
python library: https://docs.python.org/2/library/functions.html#open

below code “quotes” indicate the object another word instance.

1
2
3
4
5
6
7
def read_text():
   quotes = open(r"C:\Users\hoge\Desktop\controller\movie_quote.txt")
   contents_of_file = quotes.read()
   print(contents_of_file)
   quotes.close()
    
read_text()

using python build-in function

1
2
3
4
5
6
7
8
9
def multi_func(a, b):
    return a*b
 
items = [1,3, 5, 7]
def reduce_value():
    value = reduce(multi_func, items)
    print(value)
 
reduce_value()

105
>>>