References
Difficulty
Easy - task is almost identical to listings described in this section, changes are only in variable names and values
Medium - task uses knowledge and skills acquired prior to this chapter
Hard - task requires extra skills or Python stdlib and ecosystem knowledge (check hints section below assignment)
Sub-project - task is part of bigger project completed over whole chapter
Users
Alice, Bob, Carol, Dave, Eve, Mallory
Fictional characters often used in cryptography and security literature
https://en.wikipedia.org/wiki/Alice_and_Bob#Cast_of_characters
firstname |
lastname |
age |
uid |
username |
password |
is_user |
is_staff |
is_admin |
lastlogin |
remember |
groups |
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
Alice |
Apricot |
30 |
1000 |
alice |
secret |
True |
True |
False |
2001-01-11 |
True |
users,staff |
|
Bob |
Blackthorn |
31 |
1001 |
bob |
qwerty |
True |
True |
False |
2002-02-12 |
True |
users,staff |
|
Carol |
Corn |
32 |
1002 |
carol |
123456 |
True |
False |
False |
2003-03-13 |
True |
users |
|
Dave |
Durian |
33 |
1003 |
dave |
abc123 |
True |
False |
False |
2004-04-14 |
True |
users |
|
Eve |
Elderberry |
34 |
1004 |
eve |
password1 |
True |
True |
True |
2005-05-15 |
True |
users,staff,admins |
|
Mallory |
Melon |
15 |
1005 |
mallory |
NULL |
False |
False |
False |
None |
False |
Most Common:
>>> DATA = ['Alice', 'Bob', 'Carol']
>>> DATA = ['Alice', 'Bob', 'Carol', 'Dave', 'Eve', 'Mallory']
>>> DATA = {'firstname': 'Alice', 'lastname': 'Apricot'}
>>> DATA = {'firstname': 'Alice', 'lastname': 'Apricot', 'age': 30}
>>> DATA = [
... ('firstname', 'lastname', 'age'),
... ('Alice', 'Apricot', 30),
... ('Bob', 'Blackthorn', 31),
... ('Carol', 'Corn', 32),
... ('Dave', 'Durian', 33),
... ('Eve', 'Elderberry', 34),
... ('Mallory', 'Melon', 15),
... ]
>>> DATA = [
... {'firstname': 'Alice', 'lastname': 'Apricot', 'age': 30},
... {'firstname': 'Bob', 'lastname': 'Blackthorn', 'age': 31},
... {'firstname': 'Carol', 'lastname': 'Corn', 'age': 32},
... {'firstname': 'Dave', 'lastname': 'Durian', 'age': 33},
... {'firstname': 'Eve', 'lastname': 'Elderberry', 'age': 34},
... {'firstname': 'Mallory', 'lastname': 'Melon', 'age': 15},
... ]
>>> class User:
... def __init__(self, firstname, lastname, age):
... self.firstname = firstname
... self.lastname = lastname
... self.age = age
...
... def __repr__(self):
... clsname = self.__class__.__name__
... firstname = self.firstname
... lastname = self.lastname
... age = self.age
... return f'{clsname}({firstname=}, {lastname=}, {age=})'
>>>
>>> DATA = [
... User('Alice', 'Apricot', age=30),
... User('Bob', 'Blackthorn', age=31),
... User('Carol', 'Corn', age=32),
... User('Dave', 'Durian', age=33),
... User('Eve', 'Elderberry', age=34),
... User('Mallory', 'Melon', age=15),
... ]
Sequences:
>>> DATA = ['Alice', 'Bob', 'Carol']
>>> DATA = ['Alice', 'Bob', 'Carol', 'Dave', 'Eve', 'Mallory']
Mappings:
>>> DATA = {
... 'username': 'alice',
... 'password': 'secret',
... }
>>> DATA = {
... 'username': 'alice',
... 'password': 'secret',
... 'remember': True,
... }
>>> DATA = {
... 'firstname': 'Alice',
... 'lastname': 'Apricot',
... }
>>> DATA = {
... 'firstname': 'Alice',
... 'lastname': 'Apricot',
... 'age': 30,
... }
>>> DATA = {
... 'alice': 'secret',
... 'bob': 'qwerty',
... 'carol': '123456',
... 'dave': 'abc123',
... 'eve': 'password1',
... 'mallory': 'NULL',
... }
List Tuple:
>>> DATA = [
... ('firstname', 'lastname'),
... ('Alice', 'Apricot'),
... ('Bob', 'Blackthorn'),
... ('Carol', 'Corn'),
... ('Dave', 'Durian'),
... ('Eve', 'Elderberry'),
... ('Mallory', 'Melon'),
... ]
>>> DATA = [
... ('firstname', 'lastname', 'age'),
... ('Alice', 'Apricot', 30),
... ('Bob', 'Blackthorn', 31),
... ('Carol', 'Corn', 32),
... ('Dave', 'Durian', 33),
... ('Eve', 'Elderberry', 34),
... ('Mallory', 'Melon', 15),
... ]
>>> DATA = [
... ('firstname', 'lastname', 'email'),
... ('Alice', 'Apricot', '[email protected]'),
... ('Bob', 'Blackthorn', '[email protected]'),
... ('Carol', 'Corn', '[email protected]'),
... ('Dave', 'Durian', '[email protected]'),
... ('Eve', 'Elderberry', '[email protected]'),
... ('Mallory', 'Melon', '[email protected]'),
... ]
>>> DATA = [
... ('firstname', 'lastname', 'group'),
... ('Alice', 'Apricot', 'users'),
... ('Bob', 'Blackthorn', 'users'),
... ('Carol', 'Corn', 'staff'),
... ('Dave', 'Durian', 'staff'),
... ('Eve', 'Elderberry', 'admins'),
... ('Mallory', 'Melon', None),
... ]
List Mappings:
>>> DATA = [
... {'firstname': 'Alice', 'lastname': 'Apricot', 'age': 30},
... {'firstname': 'Bob', 'lastname': 'Blackthorn', 'age': 31},
... {'firstname': 'Carol', 'lastname': 'Corn', 'age': 32},
... {'firstname': 'Dave', 'lastname': 'Durian', 'age': 33},
... {'firstname': 'Eve', 'lastname': 'Elderberry', 'age': 34},
... {'firstname': 'Mallory', 'lastname': 'Melon', 'age': 15},
... ]
>>> from datetime import date
>>>
>>> DATA = [
... {'firstname': 'Alice', 'lastname': 'Apricot', 'lastlogin': date(2000, 1, 1)},
... {'firstname': 'Bob', 'lastname': 'Blackthorn', 'lastlogin': date(2000, 2, 2)},
... {'firstname': 'Carol', 'lastname': 'Corn', 'lastlogin': date(2000, 3, 3)},
... {'firstname': 'Dave', 'lastname': 'Durian', 'lastlogin': date(2000, 4, 4)},
... {'firstname': 'Eve', 'lastname': 'Elderberry', 'lastlogin': date(2000, 5, 5)},
... {'firstname': 'Mallory', 'lastname': 'Melon', 'lastlogin': None},
... ]
>>> DATA = [
... {'username': 'alice', 'password': 'secret'},
... {'username': 'bob', 'password': 'qwerty'},
... {'username': 'carol', 'password': '123456'},
... {'username': 'dave', 'password': 'abc123'},
... {'username': 'eve', 'password': 'password1'},
... {'username': 'mallory', 'password': 'NULL'},
... ]
>>> DATA = [
... {'username': 'alice', 'password': 'secret', 'token': 'e5e9fa1ba31ecd1ae84f75caaa474f3a663f05f4'},
... {'username': 'bob', 'password': 'qwerty', 'token': 'b1b3773a05c0ed0176787a4f1574ff0075f7521e'},
... {'username': 'carol', 'password': '123456', 'token': '7c4a8d09ca3762af61e59520943dc26494f8941b'},
... {'username': 'dave', 'password': 'abc123', 'token': '6367c48dd193d56ea7b0baad25b19455e529f5ee'},
... {'username': 'eve', 'password': 'password1', 'token': 'e38ad214943daad1d64c102faec29de4afe9da3d'},
... {'username': 'mallory', 'password': 'NULL', 'token': 'eef19c54306daa69eda49c0272623bdb5e2b341f'},
... ]
>>> DATA = [
... {'username': 'alice', 'is_user': True, 'is_staff': True, 'is_admin': False},
... {'username': 'bob', 'is_user': True, 'is_staff': True, 'is_admin': False},
... {'username': 'carol', 'is_user': True, 'is_staff': False, 'is_admin': False},
... {'username': 'dave', 'is_user': True, 'is_staff': False, 'is_admin': False},
... {'username': 'eve', 'is_user': True, 'is_staff': True, 'is_admin': True},
... {'username': 'mallory', 'is_user': False, 'is_staff': False, 'is_admin': False},
... ]
Nested:
>>> DATA = {
... 'database': 'myapp',
... 'table': 'users',
... 'rows': [
... {'username': 'alice', 'email': '[email protected]'},
... {'username': 'bob', 'email': '[email protected]'},
... {'username': 'carol', 'email': '[email protected]'},
... {'username': 'dave', 'email': '[email protected]'},
... {'username': 'eve', 'email': '[email protected]'},
... {'username': 'mallory', 'email': '[email protected]'},
... ]
... }
>>> DATA = {
... 'username': 'alice',
... 'password': 'secret',
... 'age': 30,
... 'lastlogin': '2000-01-01',
... 'is_user': True,
... 'is_staff': True,
... 'is_admin': False,
... 'emails': ('[email protected]', '[email protected]'),
... 'permissions': ['auth.add_user', 'auth.change_user'],
... 'groups': {'users', 'staff', 'admins'},
... 'friends': [
... {'username': 'bob', 'email': '[email protected]'},
... {'username': 'carol', 'email': '[email protected]'},
... {'username': 'dave', 'email': '[email protected]'},
... {'username': 'eve', 'email': '[email protected]'},
... {'username': 'mallory', 'email': '[email protected]'},
... ],
... }
>>> DATA = [
... {"firstname": "Alice", "lastname": "Apricot", "groups": [
... {"gid": 1, "name": "users"},
... {"gid": 2, "name": "staff"},
... ]},
...
... {"firstname": "Bob", "lastname": "Blackthorn", "groups": [
... {"gid": 1, "name": "users"},
... {"gid": 2, "name": "staff"},
... ]},
...
... {"firstname": "Carol", "lastname": "Corn", "groups": [
... {"gid": 1, "name": "users"},
... ]},
...
... {"firstname": "Dave", "lastname": "Durian", "groups": [
... {"gid": 1, "name": "users"},
... ]},
...
... {"firstname": "Eve", "lastname": "Elderberry", "groups": [
... {"gid": 1, "name": "users"},
... {"gid": 2, "name": "staff"},
... {"gid": 3, "name": "admins"},
... ]},
...
... {"firstname": "Mallory", "lastname": "Melon", "groups": []},
... ]
List of Objects:
>>> class User:
... def __init__(self, firstname, lastname):
... self.firstname = firstname
... self.lastname = lastname
...
... def __repr__(self):
... clsname = self.__class__.__name__
... firstname = self.firstname
... lastname = self.lastname
... return f'{clsname}({firstname=}, {lastname=})'
>>>
>>>
>>> DATA = [
... User('Alice', 'Apricot'),
... User('Bob', 'Blackthorn'),
... User('Carol', 'Corn'),
... User('Dave', 'Durian'),
... User('Eve', 'Elderberry'),
... User('Mallory', 'Melon'),
... ]
>>> class User:
... def __init__(self, firstname, lastname, age):
... self.firstname = firstname
... self.lastname = lastname
... self.age = age
...
... def __repr__(self):
... clsname = self.__class__.__name__
... firstname = self.firstname
... lastname = self.lastname
... age = self.age
... return f'{clsname}({firstname=}, {lastname=}, {age=})'
>>>
>>>
>>> DATA = [
... User('Alice', 'Apricot', age=30),
... User('Bob', 'Blackthorn', age=31),
... User('Carol', 'Corn', age=32),
... User('Dave', 'Durian', age=33),
... User('Eve', 'Elderberry', age=34),
... User('Mallory', 'Melon', age=15),
... ]
>>> class User:
... def __init__(self, firstname, lastname, email):
... self.firstname = firstname
... self.lastname = lastname
... self.email = email
...
... def __repr__(self):
... clsname = self.__class__.__name__
... firstname = self.firstname
... lastname = self.lastname
... age = self.age
... return f'{clsname}({firstname=}, {lastname=}, {email=})'
>>>
>>>
>>> DATA = [
... User('Alice', 'Apricot', email='[email protected]'),
... User('Bob', 'Blackthorn', email='[email protected]'),
... User('Carol', 'Corn', email='[email protected]'),
... User('Dave', 'Durian', email='[email protected]'),
... User('Eve', 'Elderberry', email='[email protected]'),
... User('Mallory', 'Melon', email='[email protected]'),
... ]
>>> class User:
... def __init__(self, firstname, lastname, groups=None):
... self.firstname = firstname
... self.lastname = lastname
... self.groups = groups if groups else []
...
... def __repr__(self):
... clsname = self.__class__.__name__
... firstname = self.firstname
... lastname = self.lastname
... groups = self.groups
... return f'{clsname}({firstname=}, {lastname=}, {groups=})'
>>>
>>> class Group:
... def __init__(self, name):
... self.name = name
...
... def __repr__(self):
... clsname = self.__class__.__name__
... name = self.name
... return f'{clsname}({name=})'
>>>
>>>
>>> DATA = [
... User(firstname='Alice', lastname='Apricot', groups=[
... Group('users'),
... Group('staff'),
... ]),
...
... User(firstname='Bob', lastname='Blackthorn', groups=[
... Group('users'),
... Group('staff'),
... ]),
...
... User(firstname='Carol', lastname='Corn', groups=[
... Group('users'),
... ]),
...
... User(firstname='Dave', lastname='Durian', groups=[
... Group('users'),
... ]),
...
... User(firstname='Eve', lastname='Elderberry', groups=[
... Group('users'),
... Group('staff'),
... Group('admins'),
... ]),
...
... User(firstname='Mallory', lastname='Melon', groups=[]),
... ]
Strings:
>>> DATA = 'Alice,Apricot,30'
>>> DATA = 'firstname,lastname,age;Alice,Apricot,30'
>>> DATA = 'firstname,lastname,age;Alice,Apricot,30;Bob,Blackthorn,31;Carol,Corn,32;Dave,Durian,33;Eve,Elderberry,34;Mallory,Melon,15'
CSV:
>>> DATA = """Alice,Apricot,30"""
>>> DATA = """firstname,lastname,age
... Alice,Apricot,30
... """
>>> DATA = """firstname,lastname,age
... Alice,Apricot,30
... Bob,Blackthorn,31
... Carol,Corn,32
... Dave,Durian,33
... Eve,Elderberry,34
... Mallory,Melon,15
... """
>>> DATA = """firstname,lastname,age,email,lastlogin,is_active,groups
... Alice,Apricot,30,[email protected],2000-01-01,True,users;staff
... Bob,Blackthorn,31,[email protected],2000-01-02,True,users;staff
... Carol,Corn,32,[email protected],2000-01-03,True,users
... Dave,Durian,33,[email protected],2000-01-04,True,users
... Eve,Elderberry,34,[email protected],2000-01-05,True,users;staff;admins
... Mallory,Melon,15,[email protected],,False,
... """
JSON:
>>> DATA = """[{"firstname":"Alice","lastname":"Apricot","groups":[{"gid":1,"name":"users"},{"gid":2,"name":"staff"}]},{"firstname":"Bob","lastname":"Blackthorn","groups":[{"gid":1,"name":"users"},{"gid":2,"name":"staff"}]},{"firstname":"Carol","lastname":"Corn","groups":[{"gid":1,"name":"users"}]},{"firstname":"Dave","lastname":"Durian","groups":[{"gid":1,"name":"users"}]},{"firstname":"Eve","lastname":"Elderberry","groups":[{"gid":1,"name":"users"},{"gid":2,"name":"staff"},{"gid":3,"name":"admins"}]},{"firstname":"Mallory","lastname":"Melon","groups":[]}]"""
>>> DATA = """[{"firstname":"Alice","lastname":"Apricot","age":30,"email":"[email protected]","lastlogin":"2000-01-01","is_active":"True","groups":"users;staff"},{"firstname":"Bob","lastname":"Blackthorn","age":31,"email":"[email protected]","lastlogin":"2000-01-02","is_active":"True","groups":"users;staff"},{"firstname":"Carol","lastname":"Corn","age":32,"email":"[email protected]","lastlogin":"2000-01-03","is_active":"True","groups":"users"},{"firstname":"Dave","lastname":"Durian","age":33,"email":"[email protected]","lastlogin":"2000-01-04","is_active":"True","groups":"users"},{"firstname":"Eve","lastname":"Elderberry","age":34,"email":"[email protected]","lastlogin":"2000-01-05","is_active":"True","groups":"users;staff;admins"},{"firstname":"Mallory","lastname":"Melon","age":15,"email":"[email protected]","lastlogin":"","is_active":"False","groups":""}]"""
Schemaless:
>>> DATA = [
... {'firstname': 'Alice', 'lastname': 'Apricot'},
... {'firstname': 'Bob', 'age': 31},
... {'lastname': 'Corn', 'firstname': 'Carol'},
... {'lastname': 'Durian', 'age': 33},
... {'age': 34, 'firstname': 'Eve'},
... {'age': 15, 'lastname': 'Mallory'},
... ]
Unix Files
Fictional users and groups on a Unix system
Format is based on typical Linux distribution, but the data is fictional
/etc/passwd/etc/shadow/etc/group/etc/hosts
>>> DATA_PASSWD = """# File: /etc/passwd
... root:x:0:0:root:/root:/bin/bash
... daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
... bin:x:2:2:bin:/bin:/usr/sbin/nologin
... sys:x:3:3:sys:/dev:/usr/sbin/nologin
... alice:x:1000:1000:Alice:/home/alice:/bin/bash
... bob:x:1001:1001:Bob:/home/bob:/bin/bash
... carol:x:1002:1002:Carol:/home/carol:/bin/bash
... dave:x:1003:1003:Dave:/home/dave:/bin/bash
... eve:x:1004:1004:Eve:/home/eve:/bin/bash
... mallory:x:1005:1005:Mallory:/home/mallory:/bin/bash
... """
>>> DATA_SHADOW = """# File: /etc/shadow
... root:*:10957:0:99999:7:::
... daemon:*:10957:0:99999:7:::
... bin:*:10957:0:99999:7:::
... sys:*:10957:0:99999:7:::
... alice:$6$5H0QpwprRiJQR19Y$bXGOh7dIfOWpUb/Tuqr7yQVCqL3UkrJns9.7msfvMg4ZO/PsFC5Tbt32PXAw9qRFEBs1254aLimFeNM8YsYOv.:10957:0:99999:7:::
... bob:$6$P9zn0KwR$tgfvvFWJJ5FKmoXiP5rXWOjwoEBOEoAuBi3EphRbJqqjWYvhEM2wa67L9XgQ7W591FxUNklkDIQsk4kijuhE50:10957:0:99999:7:::
... carol:!$1$.QKDPc5E$SWlkjRWexrXYgc98F.:10957:0:99999:7:::
... dave:!$6$wXtY9ZoG$MxaKfj3Z8F9G8wKz7LU0:10957:0:99999:7:::
... eve:!!:10957:0:90:5:30:10988:
... mallory: :::::::
... """
>>> DATA_GROUP = """# File: /etc/group
... root::0:root
... daemon::1:root,daemon
... bin::2:root,bin,daemon
... sys::3:root
... sudo::4:
... users::1001:alice,bob,carol,dave,eve
... staff::1002:alice,bob,eve
... admins::1003:eve
... """
>>> DATA_GROUP = [
... # File: /etc/group
... ('root', '', '0', 'root'),
... ('daemon', '', '1', 'root,daemon'),
... ('bin', '', '2', 'root,bin,daemon'),
... ('sys', '', '3', 'root'),
... ('sudo', '', '4', ''),
... ('users', '', '1001', 'alice,bob,carol,dave,eve'),
... ('staff', '', '1002', 'alice,bob,eve'),
... ('admins', '', '1003', 'eve'),
... ]
>>> DATA_HOSTS = """# File: /etc/hosts
... 127.0.0.1 localhost
... 127.0.0.1 mycomputer
... 172.16.0.1 example.com
... 192.168.0.1 example.edu example.org
... 10.0.0.1 example.net
... 255.255.255.255 broadcasthost
... ::1 localhost
... """
>>> DATA = {
... '127.0.0.1': ['localhost'],
... '127.0.0.1': ['mycomputer'],
... '172.16.0.1': ['example.com'],
... '192.168.0.1': ['example.edu', 'example.org'],
... '10.0.0.1': ['example.net'],
... '255.255.255.255': ['broadcasthost'],
... '::1': ['localhost']
... }
Shop
>>> DATA_CUSTOMERS = [
... {
... "firstname": "Alice",
... "lastname": "Apricot",
... "birthdate": "2001-01-11",
... "gender": "female",
... "tax_number": "777-286-18-01",
... "email": "[email protected]",
... "phone": "+1 (234) 555-0000"
... },
... {
... "firstname": "Bob",
... "lastname": "Blackthorn",
... "birthdate": "2002-02-12",
... "gender": "male",
... "tax_number": "777-286-18-02",
... "email": "[email protected]",
... "phone": "+1 (234) 555-0001"
... },
... {
... "firstname": "Carol",
... "lastname": "Corn",
... "birthdate": "2003-03-13",
... "gender": "female",
... "tax_number": "777-286-18-03",
... "email": "[email protected]",
... "phone": "+1 (234) 555-0010"
... },
... {
... "firstname": "Dave",
... "lastname": "Durian",
... "birthdate": "2004-04-14",
... "gender": "male",
... "tax_number": "777-286-18-04",
... "email": "[email protected]",
... "phone": "+1 (234) 555-0011"
... },
... {
... "firstname": "Eve",
... "lastname": "Elderberry",
... "birthdate": "2005-05-15",
... "gender": "female",
... "tax_number": "777-286-18-05",
... "email": "[email protected]",
... "phone": "+1 (234) 555-0100"
... },
... {
... "firstname": "Mallory",
... "lastname": "Melon",
... "birthdate": "",
... "gender": "",
... "tax_number": "",
... "email": "[email protected]",
... "phone": ""
... }
... ]
>>> DATA_PRODUCTS = [
... {"barcode": "5039271113244", "name": "Alfa", "price": "123.00"},
... {"barcode": "5202038482222", "name": "Bravo", "price": "312.22"},
... {"barcode": "5308443764554", "name": "Charlie", "price": "812.00"},
... {"barcode": "5439667086587", "name": "Delta", "price": "332.18"},
... {"barcode": "5527865721147", "name": "Echo", "price": "114.00"},
... {"barcode": "5535686226512", "name": "Foxtrot", "price": "99.12"},
... {"barcode": "5721668602638", "name": "Golf", "price": "123.00"},
... {"barcode": "5776136485596", "name": "Hotel", "price": "444.40"},
... {"barcode": "5863969679442", "name": "India", "price": "674.21"},
... {"barcode": "5908105406923", "name": "Juliet", "price": "324.00"},
... {"barcode": "5957751061635", "name": "Kilo", "price": "932.20"},
... {"barcode": "6190780033092", "name": "Lima", "price": "128.00"},
... {"barcode": "6512625994397", "name": "Mike", "price": "91.00"},
... {"barcode": "6518235371269", "name": "November", "price": "12.00"},
... {"barcode": "6565923118590", "name": "Oscar", "price": "43.10"},
... {"barcode": "6650630136545", "name": "Papa", "price": "112.00"},
... {"barcode": "6692669560199", "name": "Quebec", "price": "997.10"},
... {"barcode": "6711341590108", "name": "Romeo", "price": "1337.00"},
... {"barcode": "6816011714454", "name": "Sierra", "price": "998.10"},
... {"barcode": "7050114819954", "name": "Tango", "price": "123.00"},
... {"barcode": "7251625012784", "name": "Uniform", "price": "564.99"},
... {"barcode": "7251925199277", "name": "Victor", "price": "990.50"},
... {"barcode": "7283004100423", "name": "Whisky", "price": "881.89"},
... {"barcode": "7309682004683", "name": "X-Ray", "price": "123.63"},
... {"barcode": "7324670042560", "name": "Zulu", "price": "311.00"}
... ]
>>> DATA_ORDERS = [
... {"customer": "[email protected]", "product": "Sierra"},
... {"customer": "[email protected]", "product": "Victor"},
... {"customer": "[email protected]", "product": "Delta"},
... {"customer": "[email protected]", "product": "November"},
... {"customer": "[email protected]", "product": "Mike"},
... {"customer": "[email protected]", "product": "Bravo"},
... {"customer": "[email protected]", "product": "Kilo"},
... {"customer": "[email protected]", "product": "Victor"},
... {"customer": "[email protected]", "product": "Romeo"},
... {"customer": "[email protected]", "product": "Whisky"},
... {"customer": "[email protected]", "product": "Zulu"},
... {"customer": "[email protected]", "product": "Romeo"},
... {"customer": "[email protected]", "product": "Romeo"},
... {"customer": "[email protected]", "product": "Victor"},
... {"customer": "[email protected]", "product": "Whisky"},
... {"customer": "[email protected]", "product": "Whisky"},
... {"customer": "[email protected]", "product": "Mike"},
... {"customer": "[email protected]", "product": "November"},
... {"customer": "[email protected]", "product": "Kilo"},
... {"customer": "[email protected]", "product": "Bravo"},
... {"customer": "[email protected]", "product": "X-Ray"},
... {"customer": "[email protected]", "product": "Romeo"},
... {"customer": "[email protected]", "product": "Victor"},
... {"customer": "[email protected]", "product": "India"},
... {"customer": "[email protected]", "product": "Juliet"},
... {"customer": "[email protected]", "product": "Foxtrot"},
... {"customer": "[email protected]", "product": "Victor"},
... {"customer": "[email protected]", "product": "Romeo"},
... {"customer": "[email protected]", "product": "Whisky"},
... {"customer": "[email protected]", "product": "Zulu"},
... {"customer": "[email protected]", "product": "Alfa"},
... {"customer": "[email protected]", "product": "Romeo"},
... {"customer": "[email protected]", "product": "Quebec"},
... ]
Martian
Fictional NASA and ESA astronauts
Characters from "The Martian" book and movie
Book author: Andy Weir
Movie director: Ridley Scott
Ares 3 mission crew members:
Melissa Lewis (top left)
Alex Vogel (top center)
Mark Watney (top right)
Chris Beck (bottom left)
Beth Johanssen (bottom center)
Rick Martinez (bottom right)
>>> USERS = [
... ('firstname', 'lastname', 'age'),
... ('Mark', 'Watney', 41),
... ('Melissa', 'Lewis', 40),
... ('Rick', 'Martinez', 39),
... ('Alex', 'Vogel', 40),
... ('Chris', 'Beck', 36),
... ('Beth', 'Johanssen', 29),
... ]
>>> USERS = [
... {'firstname': 'Mark', 'lastname': 'Watney', 'age': 41},
... {'firstname': 'Melissa', 'lastname': 'Lewis', 'age': 40},
... {'firstname': 'Rick', 'lastname': 'Martinez', 'age': 39},
... {'firstname': 'Alex', 'lastname': 'Vogel', 'age': 40},
... {'firstname': 'Chris', 'lastname': 'Beck', 'age': 36},
... {'firstname': 'Beth', 'lastname': 'Johanssen', 'age': 29},
... ]
>>> class Account:
... def __init__(self, firstname, lastname):
... self.firstname = firstname
... self.lastname = lastname
...
... def __repr__(self):
... clsname = self.__class__.__name__
... firstname = self.firstname
... lastname = self.lastname
... return f'{clsname}({firstname=}, {lastname=})'
>>>
>>> class User(Account):
... pass
>>>
>>> class Admin(Account):
... pass
>>>
>>>
>>> ACCOUNTS = [
... User('Mark', 'Watney'),
... Admin('Melissa', 'Lewis'),
... User('Rick', 'Martinez'),
... User('Alex', 'Vogel'),
... User('Chris', 'Beck'),
... User('Beth', 'Johanssen'),
... ]
>>> MISSION = {
... "name": "Ares 3",
... "planet": "Mars",
... "launch": "2035-06-29",
... "landing": "2035-11-07",
... "location": "Acidalia Planitia",
... "longitude": +31.3, # North
... "latitude": -331.3, # East
... "crew": [{"name": "Melissa Lewis", "email": "[email protected]"},
... {"name": "Rick Martinez", "email": "[email protected]"},
... {"name": "Alex Vogel", "email": "[email protected]"},
... {"name": "Chris Beck", "email": "[email protected]"},
... {"name": "Beth Johanssen", "email": "[email protected]"},
... {"name": "Mark Watney", "email": "[email protected]"},
... ],
... }
Pan Twardowski
Wizard from Polish legend who escaped from the devil to the Moon
Modern Film Adaptation by Allegro: https://www.youtube.com/watch?v=hRdYz8cnOW4
https://www.youtube.com/watch?v=hRdYz8cnOW4&list=PLv4THqSPE6me9Y_57EsCYjBcBMXdRz3Kp
Monty Python
onty Python's Flying Circus https://en.wikipedia.org/wiki/Monty_Python%27s_Flying_Circus
Spanish Inquisition: https://people.csail.mit.edu/paulfitz/spanish/script.html
Iris Dataset
Iris flower species:
Iris dataset:
>>> IRIS = [
... ('sepal_length', 'sepal_width', 'petal_length', 'petal_width', 'species'),
... (5.8, 2.7, 5.1, 1.9, 'virginica'),
... (5.1, 3.5, 1.4, 0.2, 'setosa'),
... (5.7, 2.8, 4.1, 1.3, 'versicolor'),
... (6.3, 2.9, 5.6, 1.8, 'virginica'),
... (6.4, 3.2, 4.5, 1.5, 'versicolor'),
... (4.7, 3.2, 1.3, 0.2, 'setosa'),
... (7.0, 3.2, 4.7, 1.4, 'versicolor'),
... (7.6, 3.0, 6.6, 2.1, 'virginica'),
... (4.6, 3.1, 1.5, 0.2, 'setosa'),
... ]
Dates and Timezones
1957-10-04 19:28:34 UTC- Sputnik launch1961-04-12 06:07:00 UTC- Yuri Gagarin's launch1969-07-21 02:56:15 UTC- Apollo 11 Neil Armstrong's first step on the Moon
>>> from datetime import datetime, date, timezone
>>>
>>>
>>> DATA = {
... 'mission': 'Ares 3',
... 'launch_date': datetime(2035, 6, 29),
... 'destination': 'Mars',
... 'destination_landing': datetime(2035, 11, 7),
... 'destination_location': 'Acidalia Planitia',
... 'crew': [{'name': 'Melissa Lewis', 'birthdate': date(1995, 7, 15), "age": 40},
... {'name': 'Rick Martinez', 'birthdate': date(1996, 1, 21), "age": 39},
... {'name': 'Alex Vogel', 'birthdate': date(1994, 11, 15), "age": 40},
... {'name': 'Chris Beck', 'birthdate': date(1999, 8, 2), "age": 36},
... {'name': 'Beth Johanssen', 'birthdate': date(2006, 5, 9), "age": 29},
... {'name': 'Mark Watney', 'birthdate': date(1994, 10, 12), "age": 41}]
... }
{"mission": "Ares 3",
"launch_date": "2035-06-29T00:00:00",
"destination": "Mars",
"destination_landing": "2035-11-07T00:00:00",
"destination_location": "Acidalia Planitia",
"crew": [{"name": "Melissa Lewis", "birthdate": "1995-07-15", "age": 40},
{"name": "Rick Martinez", "birthdate": "1996-01-21", "age": 39},
{"name": "Alex Vogel", "birthdate": "1994-11-15", "age": 40},
{"name": "Chris Beck", "birthdate": "1999-08-02", "age": 36},
{"name": "Beth Johanssen", "birthdate": "2006-05-09", "age": 29},
{"name": "Mark Watney", "birthdate": "1994-10-12", "age": 41}]}
[{"model":"authorization.user","pk":1,"fields":{"firstname":"Melissa","lastname":"Lewis","role":"commander","username":"mlewis","password":"pbkdf2_sha256$120000$gvEBNiCeTrYa0$5C+NiCeTrYsha1PHogqvXNiCeTrY0CRSLYYAA90=","email":"[email protected]","birthdate":"1995-07-15","last_login":"1970-01-01T00:00:00.000+00:00","is_active":true,"is_staff":true,"is_superuser":false,"user_permissions":[{"eclss":["add","modify","view"]},{"communication":["add","modify","view"]},{"medical":["add","modify","view"]},{"science":["add","modify","view"]}]}},{"model":"authorization.user","pk":2,"fields":{"firstname":"Rick","lastname":"Martinez","role":"pilot","username":"rmartinez","password":"pbkdf2_sha256$120000$aXNiCeTrY$UfCJrBh/qhXohNiCeTrYH8nsdANiCeTrYnShs9M/c=","birthdate":"1996-01-21","last_login":null,"email":"[email protected]","is_active":true,"is_staff":true,"is_superuser":false,"user_permissions":[{"communication":["add","view"]},{"eclss":["add","modify","view"]},{"science":["add","modify","view"]}]}},{"model":"authorization.user","pk":3,"fields":{"firstname":"Alex","lastname":"Vogel","role":"chemist","username":"avogel","password":"pbkdf2_sha256$120000$eUNiCeTrYHoh$X32NiCeTrYZOWFdBcVT1l3NiCeTrY4WJVhr+cKg=","email":"[email protected]","birthdate":"1994-11-15","last_login":null,"is_active":true,"is_staff":true,"is_superuser":false,"user_permissions":[{"eclss":["add","modify","view"]},{"communication":["add","modify","view"]},{"medical":["add","modify","view"]},{"science":["add","modify","view"]}]}},{"model":"authorization.user","pk":4,"fields":{"firstname":"Chris","lastname":"Beck","role":"crew-medical-officer","username":"cbeck","password":"pbkdf2_sha256$120000$3G0RNiCeTrYlaV1$mVb62WNiCeTrYQ9aYzTsSh74NiCeTrY2+c9/M=","email":"[email protected]","birthdate":"1999-08-02","last_login":"1970-01-01T00:00:00.000+00:00","is_active":true,"is_staff":true,"is_superuser":false,"user_permissions":[{"communication":["add","view"]},{"medical":["add","modify","view"]},{"science":["add","modify","view"]}]}},{"model":"authorization.user","pk":5,"fields":{"firstname":"Beth","lastname":"Johanssen","role":"sysop","username":"bjohanssen","password":"pbkdf2_sha256$120000$QmSNiCeTrYBv$Nt1jhVyacNiCeTrYSuKzJ//WdyjlNiCeTrYYZ3sB1r0g=","email":"[email protected]","birthdate":"2006-05-09","last_login":null,"is_active":true,"is_staff":true,"is_superuser":false,"user_permissions":[{"communication":["add","view"]},{"science":["add","modify","view"]}]}},{"model":"authorization.user","pk":6,"fields":{"firstname":"Mark","lastname":"Watney","role":"botanist","username":"mwatney","password":"pbkdf2_sha256$120000$bxS4dNiCeTrY1n$Y8NiCeTrYRMa5bNJhTFjNiCeTrYp5swZni2RQbs=","email":"[email protected]","birthdate":"1994-10-12","last_login":null,"is_active":true,"is_staff":true,"is_superuser":false,"user_permissions":[{"communication":["add","modify","view"]},{"science":["add","modify","view"]}]}}]
Addresses
POLSA - Polish Space Agency
ESA - European Space Agency
NASA - National Aeronautics and Space Administration, USA
name |
street |
city |
postcode |
state |
country |
|---|---|---|---|---|---|
Kosmodrom Bajkonur |
Wochod |
Bajkonur |
101503 |
Kyzyłordyński |
Kazachstan |
Johnson Space Center |
2101 E NASA Pkwy |
Huston |
77058 |
Texas |
USA |
Kennedy Space Center |
None |
Cape Canaveral |
32899 |
Floryda |
USA |
NASA Jet Propulsion Laboratory |
4800 Oak Grove Dr |
Pasadena |
91109 |
California |
USA |
NASA Armstrong Research Center |
2825 E Ave P |
Palmdale |
93550 |
California |
USA |
ESA EAC |
Linder Hoehe |
Cologne |
51147 |
North Rhine-Westphalia |
Germany |
[
{"firstname": "Alice", "lastname": "Apricot", "addresses": [
{"street": "2101 E NASA Pkwy", "city": "Houston", "postcode": "77058", "region": "Texas", "country": "USA"}
]},
{"firstname": "Bob", "lastname": "Blackthorn", "addresses": [
{"street": "", "city": "Kennedy Space Center", "postcode": "32899", "region": "Florida", "country": "USA"}
]},
{"firstname": "Carol", "lastname": "Corn", "addresses": [
{"street": "4800 Oak Grove Dr", "city": "Pasadena", "postcode": "91109", "region": "California", "country": "USA"},
{"street": "2825 E Ave P", "city": "Palmdale", "postcode": "93550", "region": "California", "country": "USA"}
]},
{"firstname": "Dave", "lastname": "Durian", "addresses": [
{"street": "Linder Hoehe", "city": "Cologne", "postcode": "51147", "region": "North Rhine-Westphalia", "country": "Germany"}
]},
{"firstname": "Eve", "lastname": "Elderberry", "addresses": [
{"street": "", "city": "Космодро́м Байкону́р", "postcode": "", "region": "Кызылординская область", "country": "Қазақстан"},
{"street": "", "city": "Звёздный городо́к", "postcode": "141160", "region": "Московская область", "country": "Россия"}
]},
{"firstname": "Mallory", "lastname": "Melon", "addresses": []}
]
CSV
>>> USERS = """firstname,lastname,birthdate,gender,ssn,email,phone
... Mark,Watney,1994-10-12,male,94101212345,[email protected],+1 (234) 555-0000
... Melissa,Lewis,1995-07-15,female,95071512345,[email protected],+1 (234) 555-0001
... Rick,Martinez,1996-01-21,male,96012112345,[email protected],+1 (234) 555-0010
... Alex,Vogel,1994-11-15,male,94111512345,[email protected],+49 (234) 555-0011
... Beth,Johanssen,2006-05-09,female,06250912345,[email protected],+1 (234) 555-0100
... Chris,Beck,1999-08-02,male,99080212345,[email protected],+1 (234) 555-0101"""
>>> ADDRESSES = """user,type,street,city,postcode,region,country
... [email protected],billing,2101 E NASA Pkwy,Houston,77058,Texas,USA
... [email protected],shipment,,Kennedy Space Center,32899,Florida,USA
... [email protected],shipment,Kamienica Pod św. Janem Kapistranem,Kraków,31008,Małopolskie,Poland
... [email protected],billing,,Звёздный городо́к,141160,Московская область,Россия
... [email protected],shipment,,Космодро́м Байкону́р,,Кызылординская область,Қазақстан
... [email protected],shipment,Linder Hoehe,Cologne,51147,North Rhine-Westphalia,Germany
... [email protected],shipment,2825 E Ave P,Palmdale,93550,California,USA
... [email protected],shipment,4800 Oak Grove Dr,Pasadena,91109,California,USA"""
>>> PRODUCTS = """ean13,name,price
... 5039271113244,Alfa,123.00
... 5202038482222,Bravo,312.22
... 5308443764554,Charlie,812.00
... 5439667086587,Delta,332.18
... 5527865721147,Echo,114.00
... 5535686226512,Foxtrot,99.12
... 5721668602638,Golf,123.00
... 5776136485596,Hotel,444.40
... 5863969679442,India,674.21
... 5908105406923,Juliet,324.00
... 5957751061635,Kilo,932.20
... 6190780033092,Lima,128.00
... 6512625994397,Mike,91.00
... 6518235371269,November,12.00
... 6565923118590,Oscar,43.10
... 6650630136545,Papa,112.00
... 6692669560199,Quebec,997.10
... 6711341590108,Romeo,1337.00
... 6816011714454,Sierra,998.10
... 7050114819954,Tango,123.00
... 7251625012784,Uniform,564.99
... 7251925199277,Victor,990.50
... 7283004100423,Whisky,881.89
... 7309682004683,X-Ray,123.63
... 7324670042560,Zulu,311.00"""
>>> ORDERS = """user,product
... [email protected],Sierra
... [email protected],Victor
... [email protected],Delta
... [email protected],November
... [email protected],Mike
... [email protected],Bravo
... [email protected],Kilo
... [email protected],Victor
... [email protected],Romeo
... [email protected],Whisky
... [email protected],Zulu
... [email protected],Romeo
... [email protected],Romeo
... [email protected],Victor
... [email protected],Whisky
... [email protected],Whisky
... [email protected],Mike
... [email protected],November
... [email protected],Kilo
... [email protected],Bravo
... [email protected],X-Ray
... [email protected],Romeo
... [email protected],Victor
... [email protected],India
... [email protected],Juliet
... [email protected],Foxtrot
... [email protected],Victor
... [email protected],Romeo
... [email protected],Whisky
... [email protected],Zulu
... [email protected],Alfa
... [email protected],Romeo
... [email protected],Quebec"""