• Anoop me Madhu

    I was done with first semesters at IOE WRC and these guys came up , we spent time around lakeside camera ma chai ANIL GT :D

  • Mamaghar ma Saanaima

    ma sheela dd, paartha vai, pema dd ra hajuraama :) :) i hope you already found me there :D

  • Instrumentation II ko tour jada bus ma

    Life ko passenger :D yestai journey ma ubbirahexu ....seat kuriraaxu :D

  • Mahakaal mandir ma Sandesh sanga

    Sayad 11 class ko internals paxi ho jaile newroad tira ghumtheu,sundharako momo tiptop ko samosa ani matra gahr farkine :D prolly tei time ko ho

  • Nautanwa ko rail

    Train varkharai aathyo,ani yo chai first encounter ho mero train sanga,babba katti thulo awaj hune raixa,ani chadiyo photo khichiyo travel garna ta testai ho, lastai phohor thyo.

Showing posts with label tutorials. Show all posts
Showing posts with label tutorials. Show all posts

Monday, April 22, 2019

Python Bible

Data Structures in Python

List 


list.append(x)
Add an item to the end of the list.
list.extend(iterable)
Extend the list by appending all the items from the iterable. 
list.insert(i, x)
Insert an item at a given position. 
a.insert(0, x) inserts at the front of the list, and a.insert(len(a), x) is equivalent to a.append(x).
list.remove(x)
Remove the first item from the list whose value is equal to x.
list.pop([i])
Remove the item at the given position in the list, and return it. If no index is specified, a.pop() removes and returns the last item in the list. 
list.clear()
Remove all items from the list.
list.index(x[, start[, end]])
Return zero-based index in the list of the first item whose value is equal to x 
list.count(x)
Return the number of times x appears in the list.
list.sort(key=None, reverse=False)
Sort the items of the list in place
list.reverse()
Reverse the elements of the list in place.
list.copy()
     Return a shallow copy of the list


-------------------------------------------------------------------------------------------------

Tuples 

A tuple is a sequence of immutable Python objects. Tuples are sequences, just like lists. The differences between tuples and lists are, the tuples cannot be changed unlike lists, tuples use parentheses, whereas lists use square brackets.

eg
tup1 = ('physics', 'chemistry', 1997);
tup2 = (1, 2, 3 );
tup3 = "a", "b",;

-------------------------------------------------------------------------------------------------------

Dictionary 

A dictionary is a collection which is unordered, changeable and indexed. In Python dictionaries are written with curly brackets, and they have keys and values.

thisdict = {
  "brand": "Ford",
  "model": "Mustang",
  "year": 1964
}
print(thisdict)

Share:

Total Pageviews

About

Niranjan Adhikari is currently pursuing Computer Engineering in WRC IOE,Pokhara. Resident of Butwal,Niranjan's interests include Poetry, Design and Programming
Powered by Blogger.