Question

You are required to write a program to draw dots using the data # given in...

You are required to write a program to draw dots using the data
# given in the variable coords_list below. The variable coords_list
# contains a list of (x, y) coordinate pairs. Each (x, y) pair
# specifies a position on the screen.
#
# Write a program to draw dots at the positions in the list.
# All the dots are to be of the size defined in the variable supplied.
# If x in a pair (x, y) is larger than or equal to 0, the dot should be red,
# otherwise draw a blue dot.
#
# As a result, all dots on the right side of the screen should be in red,
# and the dots on the left should be in blue.
#
# You MUST USE THE SUPPLIED LISTS by iterating over it using
# a loop. Any attempt to hard-code the coordinates in your solution
# will achieve half marks AT MOST, even if the output looks perfect.
#--------------------------------------------------------------------#

from turtle import *

# Constants
screen_size = 600 # Screen side length in pixels

speed('fastest')
# Set up the window
setup(screen_size, screen_size)
title('Display Shapes')
bgcolor('light grey')

# size for dots
dot_size = 15

# A list of x coordinates
x_coords = [-96.0, -96.0, -96.0, -92.0, -89.0, -84.0, -76.0, -72.0, -61.0, \
-53.0, -44.0, -35.0, -23.0, -14.0, -2.0, 5.0, 14.0, 23.0, 33.0, \
44.0, 53.0, 64.0, 73.0, 81.0, 86.0, 94.0, 101.0, 104.0, 106.0, \
108.0, 109.0, 111.0, 112.0, 110.0, 116.0, 124.0, 137.0, 160.0, \
175.0, 196.0, 216.0, 232.0, 234.0, 243.0, 247.0, 254.0, 256.0, \
257.0, 257.0, 259.0, 176.0, 173.0, 167.0, 160.0, 147.0, 141.0, \
129.0, 182.0, 186.0, 188.0, 191.0, 193.0, 191.0, 189.0, 187.0, \
183.0, 179.0, 168.0, 175.0, 185.0, 196.0, 206.0, 116.0, 107.0, \
-2.0, -9.0, -14.0, -25.0, -30.0, -42.0, -52.0, -60.0, -69.0, \
-82.0, -92.0, -105.0, -115.0, -126.0, -140.0, -146.0, -156.0, \
-164.0, 145.0, 184.0, 203.0, 221.0, -112.0, -121.0, -132.0, \
-143.0, -152.0, -168.0, -181.0, -191.0, -203.0, -211.0, -221.0, \
-227.0, -236.0, -243.0, -249.0, 2.0, 6.0, 12.0, 26.0, 34.0, 47.0, \
56.0, 65.0, 76.0, 89.0, 98.0, 215.0, 222.0, 233.0, 238.0, 242.0, \
246.0, 250.0, 255.0, -254.0, -256.0, -256.0, -256.0, -251.0, \
-249.0, -247.0, -242.0, -238.0, -230.0, -228.0, -216.0, -211.0, \
-200.0, -190.0, -169.0, -178.0, -187.0, -192.0, -197.0, -205.0, \
-205.0, -205.0, -208.0, -205.0, -205.0, -202.0, -200.0, -192.0, \
-173.0, -181.0, -188.0]

# A list of y coordinates
y_coords = [156.0, 165.0, 181.0, 192.0, 203.0, 210.0, 219.0, 226.0, 238.0, \
240.0, 248.0, 253.0, 259.0, 261.0, 265.0, 266.0, 265.0, 263.0, \
261.0, 256.0, 252.0, 243.0, 239.0, 231.0, 226.0, 216.0, 206.0, \
200.0, 193.0, 184.0, 178.0, 165.0, 153.0, 142.0, 139.0, 142.0, \
145.0, 147.0, 142.0, 136.0, 125.0, 110.0, 103.0, 92.0, 86.0, \
74.0, 60.0, 51.0, 44.0, 30.0, -186.0, -195.0, -204.0, -212.0, \
-217.0, -225.0, -226.0, -178.0, -165.0, -153.0, -145.0, -133.0, \
-123.0, -107.0, -100.0, -92.0, -83.0, -67.0, -59.0, -59.0, -52.0, \
-50.0, -231.0, -234.0, -186.0, -180.0, -189.0, -199.0, -209.0, \
-212.0, -218.0, -218.0, -222.0, -227.0, -227.0, -227.0, -226.0, \
-226.0, -218.0, -213.0, -206.0, -205.0, 145.0, 140.0, 130.0, \
117.0, 155.0, 158.0, 161.0, 162.0, 162.0, 161.0, 158.0, 154.0, \
154.0, 144.0, 136.0, 131.0, 120.0, 111.0, 100.0, -192.0, -203.0, \
-212.0, -218.0, -222.0, -229.0, -232.0, -237.0, -239.0, -239.0, \
-238.0, -43.0, -36.0, -31.0, -18.0, -12.0, -4.0, 7.0, 18.0, 92.0, \
81.0, 72.0, 57.0, 47.0, 35.0, 21.0, 13.0, 4.0, -5.0, -13.0, -22.0, \
-25.0, -30.0, -38.0, -44.0, -47.0, -54.0, -66.0, -69.0, -83.0, \
-96.0, -108.0, -114.0, -125.0, -138.0, -152.0, -160.0, -171.0, \
-199.0, -191.0, -181.0]

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Aug 14 05:32:40 2019

@author: ankit
"""

from turtle import *

# Constants
screen_size = 600 # Screen side length in pixels

speed('fastest')
# Set up the window
setup(screen_size, screen_size)

title('Display Shapes')
bgcolor('light grey')

# size for dots
dot_size = 15

skk = Turtle()

skk.clear();


# A list of x coordinates
x_coords = [-96.0, -96.0, -96.0, -92.0, -89.0, -84.0, -76.0, -72.0, -61.0, \
-53.0, -44.0, -35.0, -23.0, -14.0, -2.0, 5.0, 14.0, 23.0, 33.0, \
44.0, 53.0, 64.0, 73.0, 81.0, 86.0, 94.0, 101.0, 104.0, 106.0, \
108.0, 109.0, 111.0, 112.0, 110.0, 116.0, 124.0, 137.0, 160.0, \
175.0, 196.0, 216.0, 232.0, 234.0, 243.0, 247.0, 254.0, 256.0, \
257.0, 257.0, 259.0, 176.0, 173.0, 167.0, 160.0, 147.0, 141.0, \
129.0, 182.0, 186.0, 188.0, 191.0, 193.0, 191.0, 189.0, 187.0, \
183.0, 179.0, 168.0, 175.0, 185.0, 196.0, 206.0, 116.0, 107.0, \
-2.0, -9.0, -14.0, -25.0, -30.0, -42.0, -52.0, -60.0, -69.0, \
-82.0, -92.0, -105.0, -115.0, -126.0, -140.0, -146.0, -156.0, \
-164.0, 145.0, 184.0, 203.0, 221.0, -112.0, -121.0, -132.0, \
-143.0, -152.0, -168.0, -181.0, -191.0, -203.0, -211.0, -221.0, \
-227.0, -236.0, -243.0, -249.0, 2.0, 6.0, 12.0, 26.0, 34.0, 47.0, \
56.0, 65.0, 76.0, 89.0, 98.0, 215.0, 222.0, 233.0, 238.0, 242.0, \
246.0, 250.0, 255.0, -254.0, -256.0, -256.0, -256.0, -251.0, \
-249.0, -247.0, -242.0, -238.0, -230.0, -228.0, -216.0, -211.0, \
-200.0, -190.0, -169.0, -178.0, -187.0, -192.0, -197.0, -205.0, \
-205.0, -205.0, -208.0, -205.0, -205.0, -202.0, -200.0, -192.0, \
-173.0, -181.0, -188.0]

# A list of y coordinates
y_coords = [156.0, 165.0, 181.0, 192.0, 203.0, 210.0, 219.0, 226.0, 238.0, \
240.0, 248.0, 253.0, 259.0, 261.0, 265.0, 266.0, 265.0, 263.0, \
261.0, 256.0, 252.0, 243.0, 239.0, 231.0, 226.0, 216.0, 206.0, \
200.0, 193.0, 184.0, 178.0, 165.0, 153.0, 142.0, 139.0, 142.0, \
145.0, 147.0, 142.0, 136.0, 125.0, 110.0, 103.0, 92.0, 86.0, \
74.0, 60.0, 51.0, 44.0, 30.0, -186.0, -195.0, -204.0, -212.0, \
-217.0, -225.0, -226.0, -178.0, -165.0, -153.0, -145.0, -133.0, \
-123.0, -107.0, -100.0, -92.0, -83.0, -67.0, -59.0, -59.0, -52.0, \
-50.0, -231.0, -234.0, -186.0, -180.0, -189.0, -199.0, -209.0, \
-212.0, -218.0, -218.0, -222.0, -227.0, -227.0, -227.0, -226.0, \
-226.0, -218.0, -213.0, -206.0, -205.0, 145.0, 140.0, 130.0, \
117.0, 155.0, 158.0, 161.0, 162.0, 162.0, 161.0, 158.0, 154.0, \
154.0, 144.0, 136.0, 131.0, 120.0, 111.0, 100.0, -192.0, -203.0, \
-212.0, -218.0, -222.0, -229.0, -232.0, -237.0, -239.0, -239.0, \
-238.0, -43.0, -36.0, -31.0, -18.0, -12.0, -4.0, 7.0, 18.0, 92.0, \
81.0, 72.0, 57.0, 47.0, 35.0, 21.0, 13.0, 4.0, -5.0, -13.0, -22.0, \
-25.0, -30.0, -38.0, -44.0, -47.0, -54.0, -66.0, -69.0, -83.0, \
-96.0, -108.0, -114.0, -125.0, -138.0, -152.0, -160.0, -171.0, \
-199.0, -191.0, -181.0]

skk.hideturtle();
for x in range(0,len(x_coords)):
    X =x_coords[x];
    Y = y_coords[x];
    col =""
    if X >= 0:
        col = "red"
    else:
        col = "blue"
  
    skk.goto(X,Y);
    skk.dot(dot_size,col);

==========================================

You can rearrange the points to remove these lines coming in between. the points are not contiguous

Thanks.

Add a comment
Know the answer?
Add Answer to:
You are required to write a program to draw dots using the data # given in...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT