Posts

Showing posts from July, 2019

Python List

We have already seen What List is? and how to write elements in List. To follow that post visit Python Data Types . Where you will get all the different data types available into Python programming. In this blog we will see different methods to work on list, this can be like appending a item to list, removing item from list, How to find length of a list and so on.... What is Method? Method is basically a function which is written for specific object.  Syntax: name_of_an_object . name_of_the_method example: x = [2,5,3,8,6,9] x.sort ( ) Here you can see x is the object of type 'List' and sort is the method to perform on object. Below given is the list of methods that can be executed on list type of object. We will see each one with an example. list.append(x) Add an item to the end of the list. Equivalent to a[len(a):] = [x]. list.extend(L) Extend the list by appending all the items in the given list. Equivalent to a[len(a):] = L. list.inse...

Python Function

When you want your program to be more efficient and easy to manage than use functions in your program. What is Functions? There are many situations in a program when you want to execute a same set of code many times at different positions in a code or task. At such time if you start writing same set of code repeatedly in a same code, program becomes more complex and such codes are not easy to manage and is not a efficient solution for any task. Even you will be confused when you see your own code in future. What is the Solution?  So, to overcome such problem functions comes into picture. The code that is repeated various times in your program name that code and whenever required just refer that set of code. In technical terms a piece of code that you have named, which performs one operation is called Function . Write this Function outside of your main code. And where ever  required refer this function. Referring a Function i...