Creating a Dictionary
dict_1 = {}
dict_2 = {"a": 1, "b": 2, "c": 3}
Creating a Dictionary
dict_3 = {
"cat": "mammal",
"lizard": "reptile",
"goldfish": "fish",
"chickadee": "bird"
}
Adding to a Dictionary
dict_1 = {}
dict_1["Kansas"] = "Topeka"
dict_1["Nebraska"] = "Lincoln"
dict_1["Missouri"] = "Jefferson City"
Accessing Dictionary Items
dict_3 = {
"cat": "mammal",
"lizard": "reptile",
"goldfish": "fish",
"chickadee": "bird"
}
print(dict_3["cat"]) # mammal
Updating Dictionary Items
dict_3 = {
"cat": "mammal",
"lizard": "reptile",
"goldfish": "fish",
"chickadee": "bird"
}
dict_3["cat"] = "feline"
print(dict_3["cat"]) # feline
def main():
base = int(input("Enter a whole number: "))
powers = {}
for i in range(6):
powers[f"{base}^{i}"] = base ** i
print(powers)
main()