“dictionnaire python” Réponses codées

dictionnaire python

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

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

compréhension du dict 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

dictionnaire en python

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

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

dictionnaire python

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

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

Réponses similaires à “dictionnaire python”

Questions similaires à “dictionnaire python”

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

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code