“Słownik Python” Kod odpowiedzi

Słownik Python

human = {
  "code": "Python",
  "name": "John",
  "age": 32
}

print(human["age"])
#32 :D
The Cat Coder

Dict rozumie Python

# dict comprehension we use same logic, with a difference of key:value pair
# {key:value for i in list}

fruits = ["apple", "banana", "cherry"]
print({f: len(f) for f in fruits})

#output
{'apple': 5, 'banana': 6, 'cherry': 6}
Handsome Hamster

Słownik w Python

Polygon = {
	"PolygonName" : "Tetrahectaseptadecagon"
	"PolygonSides" : 417
}

print("A", (Polygon["PolygonName"]) "has", (Polygon["PolygonSides"]), "sides")
Rick Astley

Słownik Python

dictionary = {
    "name": "Elie",
    "family name": "Carcassonne",
    "date of born": "01/01/2001",
    "list": ["hey", "hey"]
}
moi_crn

Python Dict

# A dict (dictionary) is a data type that store keys/values

myDict = {"name" : "bob", "language" : "python"}
print(myDict["name"])

# Dictionaries can also be multi-line
otherDict {
	"name" : "bob",
    "phone" : "999-999-999-9999"
}
codingiscool

Słownik w Python

myDict = {
    "Fast": "In a Quick Manner",
    "Hasya": "A Coder",
    "Marks": [1, 2, 5],
    "anotherdict": {'hasya': 'Player'}
}

# print(myDict['Fast'])
# print(myDict['Hasya'])
myDict['Marks'] = [45, 78]
print(myDict['Marks'])
print(myDict['anotherdict']['hasya'])
Coding boy Hasya

Odpowiedzi podobne do “Słownik Python”

Pytania podobne do “Słownik Python”

Więcej pokrewnych odpowiedzi na “Słownik Python” w Python

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu