Friday, 8 July 2016

What is List: in Python programming?

List is a data type in python .we define the list using square brackets [], in this we can put  the different-different  types of value like, int, float, string . And we can modify the list also , you can delete,  insert,  add operations in list .You can add two list also using + operator , Using + operator you can concatenate two  list . In list if you want to fetch any item in list that time you use indexing . Indexing would be start from 0 .In list  there is a function called range this is used to define a particular  data.
Say we need to get twenty test scores from a user and and do something with them, like put them
in order. We could create thirty variables, score1, score2, . . . ,score 30, but that would be very
tedious. To then put the scores in order would be extremely difficult. The solution to use lists .you can define the list like this:
 a=[2,3,,5,6]
print a
output:  [2,3,5,6]
There are many functions in list, find the below example of range function in list:
*range():--
The value we put in the range function determines how many times we will loop, it produces a list of numbers from zero to the value minus one. For  instance range
produces five values: 0, 1, 2, 3, and 4, Find the below example for range function:
if you provide the 10 inside range() finction like this:
range(10): then output would be ..   0,1,2,3,4,5,6,7,8,9
range(1, 10),  1,2,3,4,5,6,7,8,9
range(2, 15, 2):   2,4,6,8,10,12,14         
range(9,2,-1):   9, 8, 7, 6, 5, , 3

Learn more about to python. For furthermore information update about python and other technology you can get in touch with Softcrayons' Blog.  Softcrayons is one of the leading python training institute in India. To get more updates, news, and experience about python technology; keep update with our blog.

No comments:

Post a Comment