[15] 6. Complete the function definition. from graphics import * import random d
ID: 3906611 • Letter: #
Question
[15] 6. Complete the function definition. from graphics import * import random def randomPoints (n, win) "Here n is a positive integer, and win is a GraphWin. Draw n randomly placed Points in win so all x and y coordinates could be any integers in the range 0-100, including 0 and 100. For example, if n is 4, you might draw Point(22, 79), Point(86, 0), Point(100, 55), Point(17,90)." [15] 7. Complete the function definition. def allNeg (nums): "nums is a list of numbers. Return, not print, a new list of all the negative numbers from nums. Examples: allNeg (I-3, 5, 0, -9, 42, 8]) returns [-3, 9, -42] allNeg ([O, 1, 2, 3]) returns [IExplanation / Answer
If you have any doubts, please give me comment...
[15] 6)
from graphics import *
import random
def randomPoints(n, win):
# iterating upto n for generating random points
for i in range(n):
#generating point using Point class with argument random numbers from 0 to 100 inclusive
pt = Point(random.rand(0, 100), random.rand(0, 100))
#draw point with reference of win parameter
pt.draw(win)
[15] 7)
def allNegs(nums):
#declaring empty list to store negs
l = []
#iterating numbers along with in nums list
for i in nums:
#checking whether number is positive or negative
if i<0:
#if number is negative, appending into list
l.append(i)
#returning list
return l
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.