Calvin (Deutschbein)
W11Wed: 06 Nov
>>> x = 1,2
>>> x
(1, 2)
>>> x,y = 1,2
>>> x
1
>>> y
2
>>> x + x,y
(2, 2)
def to_color(rgbs:list[int]) -> str:
hexes = [hex(brightness) for brightness in rgbs]
hexes = [color.replace('x','0') for color in hexes]
hexes = [color[-2:] for color in hexes] # last two
return '#' + "".join(hexes)
>>> to_color([100,0xff,255])
'#64ffff'
pix = 800 # number of pixels
gw = GWindow(pix, pix)
image = GImage("cat.png")
gw.add(image)
pixels = image.get_pixel_array()
print(type(pixels))
if type(data) == int:
self._val = data
else:
self._val = 0
>>> films = {"Alien","Aliens", "Alien 3", "Alien Resurrection"}
>>> films
{'Aliens', 'Alien', 'Alien 3', 'Alien Resurrection'}
>>> films[0]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'set' object is not subscriptable
>>>
s = { }
s = set()
>>> alien_orig # films prior to 2000
{'Aliens', 'Alien', 'Alien 3', 'Alien Resurrection'}
>>> alien_preq # films after 2000
{'Alien: Covenant', 'Alien Romulus', 'Promethous'}
>>> alien_orig | alien_preq # the alien series is composed of both "trilogies"
{'Aliens', 'Alien Resurrection', 'Alien: Covenant', 'Alien 3', 'Alien Romulus', 'Alien', 'Promethous'}
>>> alien_all = alien_orig | alien_preq
>>> avp = {"Alien vs Predator", "Alien vs Predator: Requiem"}
>>> alien_both = alien_orig | alien_preq
>>> alien_all = alien_both | avp
>>> alien_all - alien_orig # all films since 2000
{'Alien: Covenant', 'Alien Romulus', 'Alien vs Predator: Requiem', 'Alien vs Predator', 'Promethous'}
>>> pred_all = {"Predator", "Predator 2", "Predators", "Prey"} | avp
>>> pred_all & alien_all
{'Alien vs Predator: Requiem', 'Alien vs Predator'}
>>> pred_all ^ alien_all
{'Predators', 'Alien: Covenant', 'Alien Romulus', 'Alien', 'Predator 2', 'Predator', 'Aliens', 'Alien Resurrection', 'Alien 3', 'Prey', 'Promethous'}
>>> "Alien vs Predator" in pred_all ^ alien_all
False
{ x for x in range(0,100,2) }
Function | Description |
---|---|
len(s) |
Returns the number of elements in a set |
x in s |
True if the value of x is contained in the set denoted by s |
s.copy() |
Creates and returns a copy of the set |
s.add(x) |
Adds the the value of x to the set denoted by s |
s.remove(x) |
If the value of x is in s, removes it, or raises an error |
s.discard(x) |
Removes without the error case. |