Jed Rembold & Fred Agbo
March 6, 2025
Which of the below blocks of code will create the image to the right?
The window measures 500 x 200 pixels and the value of
d is 150.
x, y = 250 - d / 2, 100 - d / 2
a1 = GArc(x, y, d, d, 90, -180)
gw.add(a1)x, y = 250 - d, 100 - d
a1 = GArc(x, y, d, d, -180, 90)
gw.add(a1)x, y = 250 - d / 2, 100 - d / 2
a1 = GArc(x, y, d, d, 90, 180)
gw.add(a1)x, y = 250 - d / 2, 100 - d / 2
a1 = GArc(x, y, d, 180, -90)
gw.add(a1)cool = ['blue', 'violet']
warm = ['red', 'orange']
colors = [cool, warm]
other_colors = [['blue', 'violet'],
                ['red', 'orange']]
print(colors == other_colors)
print(colors is other_colors)
cool[0] = 'indigo'
warm = ['orange', 'yellow']
print(colors)
print(other_colors).copy() list methodlist() function will return a
new object| Method | Description | 
|---|---|
| list.copy() | Returns a new list whose elements are the same as the original | 
| list.append(value) | Adds valueto the end of the list | 
| list.insert(idx, val) | Inserts valbefore the specifiedidx | 
| list.remove(value) | Removes the first instance of valuefrom
the list, or errors | 
| list.reverse() | Reverses the order of the elements in the list | 
| list.sort() | Sorts the elements of the list. Can take an optional argument keyto specify how to sort | 
.sort and
.reverse methods reorder the list in
place and do not return anythingreversed() function creates a new
iterable object that returns its elements in the opposite ordersorted() function creates a new
iterable object that returns its elements in ascending orderCommonly will make lists with a simple:
even_digits = [ 2, 4, 6, 8 ]But in many cases, it is easier to specify the elements of a list
using a sequence of values generated by a
for loop. For instance
even_digits = [ ]
for i in range(0, 10, 2):
    even_digits.append(i)Python gives us a shorthand notation to achieve this:
even_digits = [ i for i in range(0, 10, 2) ]del statementlist1 =[2,4,6,5,3]
del list1[3]
print(list1)list1 = [2,4,6,5,3]
list2 =[] #to store ele
for i in range(len(list1)):
      if list1[i]%2==0: #remove odd
            list2.append(list1[i])
            
print(list1)
print(list2)