GoConqr has a new look! Let us know what you think.

Notes

python

mission verge Science python English 1 page

Content of the notes (1)

Page 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)

___________________________________________________________________________________________

Information

Description
python Science Note on python, created by mission verge on 06/09/2017.
Created by
mission verge
Views
1
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?