“wie man ein Wörterbuch in Python definiert” Code-Antworten

Wörterbuch in Python

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

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

Wörterbuch in 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

wie man ein Wörterbuch in Python definiert

population = {"Shanghai":17.8, "Istanbul":13.3, "Karachi":13.0, "Mumbai":12.5}

#Consider the following when creating a dictionary
#	1. Must be inside {}
#	2. Have two parts in an item 
#			Key - e.g. Istanbul and Value - e.g. 13.3
#	3. There must be a colon ":" between the key and the value
#	4. Item must be seperated by commas ","
#	3. Any immutable type can be used as keys (not only integers like in lists)
Rajitha Amarasinghe

Wörterbuch in Python

Dict = {"name": 'Izhaan', "salary": 1234, "age": 23} 
print("\nDictionary with the use of string Keys: ") 
print(Dict)
Bored Buzzard

Ähnliche Antworten wie “wie man ein Wörterbuch in Python definiert”

Fragen ähnlich wie “wie man ein Wörterbuch in Python definiert”

Weitere verwandte Antworten zu “wie man ein Wörterbuch in Python definiert” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen