“diccionarios en Python” Código de respuesta

Diccionario en Python

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

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

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

Diccionario 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 dict

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

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

Diccionario 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

diccionarios 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

Respuestas similares a “diccionarios en Python”

Preguntas similares a “diccionarios en Python”

Más respuestas relacionadas con “diccionarios en Python” en Python

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código