
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.
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
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
>>>