Notizen
python
Inhalt der Notizen (1)
Seite 1
a list is written as akshay = [...]
a tuple is written as akshay = (....)
a dictionary is written as akshay = { 1: "one", 2:"two", 3:"three" }
print("list:", list)
print("dictionary:", dictionary)
print("tuple:", tuple)
print("set:", set)
Python data structures include lists, dictionaries, tuples, and sets.
The data types for a list, dictionary, tuple, and set, are 'list', 'dict', 'tuple', and 'set', respectively.
----------------------------------------------------------------------------------------------
the given format is what kind then use ::
print("list:", type(list))
print("dictionary:", type(dictionary))
print("tuple:", type(tuple))
print("set:", type(set))
-----------------------------------------------------------------------------------
The list(), dict(), tuple(), and set() functions may be used to create list, dictionary, tuple, and set objects, respectively.
print (list((1,2,3)))
print (dict((1 = one, 2 = two, 3 = three)))
------------------------------------------------------------------------------------------
List and dictionary items are mutable. Tuple and set items are immutable.
----------------------------------------------------------------------------------------------------
List and dictionary items are mutable. Tuple and set items are immutable..... (puting another element by replacment!!)
Lists and tuples allow duplication. Dictionary and set items are unique.
List and tuple items may be accessed by index. Dictionary items are accessed by key.
--------------------------------------------------------------------------------------------------------------------
replacement:
list[0] = 0
print("list: mutable")
dictionary[1] = "zero"
print("dictionary: mutable")
-------------------------------------------------------------------------------------------------------------------------------------
loops case as of now:::
for item in akshay:
print(item)
-------------------------------------------------------------------------------------------------------------------------------
for index case::
for i in range(len(list)):
print("list[%d]: %d" % (i, list[i]))
--------------------------------------------------------------
simple creation of tuple:::
x = 1
y = 2
print(x, y)
___________________________________________________________________________________________
Informationen
- Beschreibung
- python Science Notiz am python, erstellt von mission verge am 06/09/2017.
- Erstellt von
- mission verge
- Aufrufe
- 1
- Bewertung