Week 10
Week 10
primes = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37}
teens = set([13, 14, 15, 16, 17, 18, 19])
print(primes - teens)
print(primes & teens)
print(primes | teens)
print(primes ^ teens)
cast = {"Cardinal Ximenez" : "Michael Palin", "Cardinal Biggles" : "Terry Jones", "Cardinal Fang" : "Terry
Gilliam"}
cast["customer"] = "John Cleese"
cast["shopkeeper"] = "Michael Palin"
print(cast["shopkeeper"])
print(cast["Cardinal Ximenez"])
print(cast["Cardinal Fang"])
Activity 2
a) You have a list of sizes which should not be change or alter. How would you prevent the list
from being changed
a. sizes = ['XS’, 'S’, 'M’, 'L’, 'XL’, 'XXL']
b) Read data from the text clothing_stock.txt , count how many of the specific sizes are in the
text file and print out the solution.
Activity 3
Write a program to create two list: one with numbers: 0,1,2,3,4,5, second: 0,1,3,5,1,0
- Change both to be a sets.
- Add numbers: 0,1,2,7 into set1.
- Print the intersection of the two sets
- Print the union of the two sets
- Print the difference between set 1 and set 2
Activity 4
SciPy in practice.