• Sign Up
• Login
• API
• FAQ
• Tools
• Trends
• Archive
daily pastebin goal
14%
SHARE
TWEET

Untitled

a guest May 19th, 2017 44 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import turtle
2. ##This Program Will Draw A Scene With a House and A Tree and A Sun/Moon
3. d_n = raw_input('day or night?: ')
4. if d_n == 'day':
5.     print 'day'
6. elif d_n == 'night':
7.         print 'night'
8. else:
9.     print 'You have selected neither, you get day.'
10.
11.
12.
13. class circle(object):
14.
15.     def __init__(self, pen, size, number, fillcolor=""):
16.         """whats in circle"""
17.         pen = turtle.Turtle()
18.         self.b= size
19.         self.c = fillcolor
20.         self.d = number
21.
22.     def __str__(self):
23.         """string of circle"""
24.         return '(' +str(self.b)+ "," + str(self.c)+ "," + str(self.d)+')'
25.
26.     def draw(self, pen, size, x, y, number, fillcolor=''):
27.         """drawing a circle"""
28.         pen.up()
29.         pen.goto(x, y)
30.         pen.fill(True)
31.         pen.pencolor = 'black'
32.         pen.down()
33.         rotation = 360/float(number)
34.
35.         for i in range(number):
36.             pen.fillcolor(fillcolor)
37.             pen.circle(size)
38.             pen.left(rotation)
39.
40.         pen.fill(False)
41.         pen.up
42.
43. class square(object):
44.
45.     def __init__(self, pen, size, fillcolor=''):
46.         """what is in square"""
47.         pen=turtle.Turtle()
48.         self.b = size
49.         self.c = fillcolor
50.
51.     def __str__(self):
52.         """string of square"""
53.         return '(' +str(self.b)+ "," + str(self.c)+')'
54.
55.
56.     def draw(self, pen, size, x, y, fillcolor=''):
57.         """drawing a square"""
58.         pen.up()
59.
60.         pen.goto(x, y)
61.         pen.fill(True)
62.         pen.pencolor = 'black'
63.         pen.down()
64.         for i in range(4):
65.
66.             pen.down()
67.             pen.forward(size)
68.             pen.left(90)
69.             pen.fillcolor(fillcolor)
70.
71.         pen.fill(False)
72.         pen.up()
73.
74.
75.
76. class tree(object):
77.     def __init__(self, pen, fillcolor=''):
78.         """what is in tree"""
79.         pen=turtle.Turtle()
80.         self.b = fillcolor
81.
82.     def __str__(self):
83.         """string of tree"""
84.         return '(' +str(self.b)+ ')'
85.
86.     def draw(self, pen, x, y, fillcolor=''):
87.         """drawing a tree"""
88.         pen.up()
89.         pen.goto(x, y)
90.         pen.fill(True)
91.         pen.pencolor='black'
92.         if d_n == 'night':
93.             a = '#330000'
94.         else:
95.             a = 'brown'
96.
97.         for i in range(2):
98.             pen.down()
99.             pen.forward(20)
100.             pen.left(-90)
101.             pen.forward(200)
102.             pen.left(-90)
103.             pen.fillcolor(a)
104.         pen.fill(False)
105.         if d_n == 'night':
106.             b = '#006600'
107.         else:
108.             b = 'green'
109.         pen.up()
110.         pen.goto(x, y+200)
111.         pen.down()
112.         c.draw(pen, 30, x-30, y+200, 6, b)
113.         pen.fill(False)
114.         pen.up()
115.         pen.goto(x+30, y+200)
116.         pen.down()
117.         pen.fill(True)
118.         c.draw(pen, 30, x+30, y+200, 6, b)
119.
120. class house(object):
121.
122.     def __init__(self, pen):
123.         """what is in house"""
124.         pen = turtle.Turtle()
125.
126.     def __str__(self):
127.         """string of house"""
128.         return '(' +str(pen)+ ')'
129.
130.     def draw(self, pen, x, y):
131.         """drawing house"""
132.         pen.up()
133.         pen.goto(x,y)
134.         pen.fill(True)
135.         pen.pencolor='black'
136.         if d_n == 'night':
137.             d = '#990000'
138.         else:
139.             d = '#FF0000'
140.         for i in range(2):
141.             pen.down()
142.             pen.forward(100)
143.             pen.left(90)
144.             pen.forward(175)
145.             pen.left(90)
146.             pen.fillcolor(d)
147.
148.         pen.fill(False)
149.         pen.up()
150.         pen.goto(x+30, y)
151.         if d_n == 'night':
152.             e = '#FFFF00'
153.         else:
154.             e = '#CCFF00'
155.         for i in range(2):
156.             pen.fill(True)
157.             pen.down()
158.             pen.forward(40)
159.             pen.left(90)
160.             pen.forward(70)
161.             pen.left(90)
162.             pen.fillcolor(e)
163.         pen.fill(False)
164.         pen.up()
165.         if d_n == 'night':
166.             f = '#6600FF'
167.         else:
168.             f = '#66CCCC'
169.         pen.fill(True)
170.         pen.goto(x-30, y+175)
171.         pen.down()
172.         pen.fillcolor(f)
173.         pen.left(60)
174.         pen.forward(160)
175.         pen.right(120)
176.         pen.forward(160)
177.         pen.right(120)
178.         pen.forward(160)
179.         pen.fillcolor(f)
180.         pen.up()
181.         pen.fill(False)
182.
183. #windows#
184.         if d_n == 'night':
185.             g = 'grey'
186.         else:
187.             g = 'white'
188.         pen.goto(-170, -50)
189.         for i in range(2):
190.             pen.fill(True)
191.             pen.down()
192.             pen.forward(20)
193.             pen.left(90)
194.             pen.forward(30)
195.             pen.left(90)
196.             pen.forward(20)
197.             pen.left(90)
198.             pen.forward(30)
199.             pen.fillcolor(g)
200.             pen.left(90)
201.             pen.up()
202.             pen.fill(False)
203.             pen.goto(-110, -50)
204.
205.         c.draw(pen, 2, -138, -170, 1, 'black')
206.
207.
208. #below: drawings
209.
210.
211. pen=turtle.Turtle()
212. c = circle(pen, 7, 'blue')
213. h = house(pen)
214. h.draw(pen, -200, -200)
215.
216.
217.
218. t = tree(pen)
219. t.draw(pen, 125, -200)
220.
221. #the SUN/MOON
222. if d_n == 'night':
223.     h = 'CCFFCC'
224. else:
225.     h = 'yellow'
226. c.draw(pen, 70, -150, 300, 1, h)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top