This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import collections | |
rgbvalue = collections.namedtuple("rgb", ["red", "green", "blue"]) | |
htmlcolour = collections.namedtuple("htmlcolour", ["name", "rgbvalue"]) | |
colours:set = set() | |
htmltuple = htmlcolour("Red", rgbvalue(red=0xff, green=0x00, blue=0x00)) | |
colours.add(htmltuple) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
recorded_birds = ["crow", "sparrow", "sparrow", "sparrow", "crow", "robin"] | |
recorded_species:set = set(recorded_birds) | |
print(recorded_birds) | |
print(recorded_species) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mytext:str = "Hello, World!" | |
characters:list = list(mytext) | |
print(len(characters)) | |
print(characters[7]) | |
characters.insert(6, "-") | |
characters.append("!!") | |
print(characters) | |
mytext = "".join(characters) | |
print(mytext) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mytext:str = "Hello, World!" | |
characters:list = [current_letter.title() for current_letter in mytext if current_letter.isalpha()] | |
my_new_text:str = "".join(characters) | |
print(my_new_text) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import collections | |
import pprint | |
facilities:list = list() | |
medicare_facility:collections.namedtuple = collections.namedtuple("facility", | |
["id", "facility_name", "address", "city", "state", "zip"]) | |
facilities.append( | |
medicare_facility( | |
id="30084", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
A module illsutrating storing a key-value pair in a dictionary. | |
""" | |
import collections | |
Book: collections.namedtuple = collections.namedtuple("Book", ["isbn", "title"]) | |
books_as_list: list = list() | |
books_as_dict: dict = dict() | |
books_as_list.append( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
A module illsutrating storing a key-value pair in a dictionary. | |
""" | |
import collections | |
Book: collections.namedtuple = collections.namedtuple("Book", ["isbn", "title", "author"]) | |
books_as_list: list = list() | |
books_as_dict: dict = dict() | |
books_as_list.append( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
A module illsutrating storing a key-value pair in a dictionary. | |
""" | |
import collections | |
Book: collections.namedtuple = collections.namedtuple("Book", ["isbn", "title", "author"]) | |
books_as_list: list = list() | |
books_as_dict: dict = dict() | |
books_as_list.append( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
A module illsutrating storing a key-value pair in a dictionary. | |
""" | |
import collections | |
import json | |
Book: collections.namedtuple = collections.namedtuple("Book", ["isbn", "title", "author"]) | |
books_as_list: list = list() | |
books_as_dict: dict = dict() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fruits_dict: dict = dict() | |
citrusfruit: set = {"oranges", "lemons", "limes", "satsumas", "nectarines"} | |
treefruit: set = {"apples", "pears", "cherries", "plums", "peaches", "plums", | |
"cherries", "oranges", "lemons", "limes"} | |
stonefruit: set = {"cherries", "plums", "peaches", "nectarines"} | |
for fruit in citrusfruit.union(stonefruit).union(treefruit): | |
fruits_dict.setdefault(fruit, []) |