“dictionnaires en python” Réponses codées

dictionnaire en python

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

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

Python

# 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

dictionnaire en 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

Python

mydictionary = {'name':'python', 'category':'programming', 'topic':'examples'}

for x in mydictionary:
	print(x, ':', mydictionary[x])
David Cao

dictionnaire en python

#a dictionary
dict = {
  "key": "value",
  "other_key": "value"
}

#get a value from the dictionary using the key
print(dict["key"])

#you can also get a value from the dictionary using a normal index:
print(dict[1])
Poor Pony

dictionnaires en python

# Creating a Nested Dictionary
# as shown in the below image
Dict = {1: 'Geeks', 2: 'For',
        3:{'A' : 'Welcome', 'B' : 'To', 'C' : 'Geeks'}}
 
print(Dict)
Exuberant Eland

Réponses similaires à “dictionnaires en python”

Questions similaires à “dictionnaires en python”

Plus de réponses similaires à “dictionnaires en python” dans Python

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code