Monday, January 14, 2019

Learn Python from Zero to Hero

This is the 6 part of Python tutorial series, Learn Python from Zero to Hero. If you want to learn Python from scratch you can check our previous tutorials on Python. If you want to read from starting click the given link below.

Learn Python from Zero to Hero Part 1.

Learn Python from Zero to Hero Part 2.

Learn Python from Zero to Hero Part 3.

Learn Python from Zero to Hero Part 4.

and the Last one Learn Python from Zero to Hero Part 5.



We all know Python is the rich programming language for data science, If have dream like many of others to become a data scientist in future or want to learn data science, Python is the best way to start with, Python have many libraries which makes Python most popular programming language for data science, Python's libraries makes data science easy to learn.

In this part we will learn What is list or tuples in Python ?, Python support four type of collections List, Tuples, Set and Dictionary, Now you are exited to know what are these collections ?, If you are exited it means you love programming like me. But if you are NOT exited than you are Lazy Person.


 Don't be sad i have a little bit Motivation for You. #Hahahaha.

I will always choose a lazy person to do a difficult job because a lazy person will find an easy way to do it.
Whenever there is a hard job to be done I assign it to a lazy man; he is sure to find an easy way of doing it.

                                                  Bill Gates.
So if you are exited to know what is List, Tuples, Set or Dictionary ?, than Stay with me and keep calm, We will learn all of them one by one, So let me start with List or Tuples in this post we will cover remains Set or Dictionary in next post.

So Let's Begin

List :

                      As I told you before list is a part of collections, This List is ordered or unchangeable in Python, This List is also allow the duplicate members, In Python List written around the square bracket, This list in Python is very important to understand.

If you do programming before than you already know about what is array ?, These array's are very important in programming. Because Python does not support data type than python have this List feature, This List works similar to array's.

Example :

list = [ 'Apple', 'Banana', 'Mango', 'Papaya', 'Orange' ]
print ( list )

List also contains list or tuple inside list and List able to contains all kind of data types in a single list, You can better understand it by the given example below.


list = [ 'Hello', 'First List', [ 'Hey', 'Second List' ], 3, 66.78, 'A',99.12, 'C' ]
print ( list )
list [4] = "Syntaxios"        # you can change list at any time, Because list is changeable.
print ( list )

Tuples :

                                Tuples are also the part of collections, Tuples are ordered or unchangeable, and Tuples also allow the duplicate member, Tuples should be written around the brackets that is rounded bracket.

Example

tuple = ( 'Apple', 'Banana', 'Mango' )
print ( tuple )

Tuple also contains the tuples or list inside the tuple, Let's understand tuple by the given example below.


tuple = ( 'Tuple', 56, 66.7, [ 'list', 7, 11.7 ], 'A', 75, ( 'Another', 'Tuple', 'G', 77 ), 'End' )
print ( tuple )
tuple [3] = " Integer 56 "       # you can not do this because tuples are Unchangeable.
print ( tuple )         # error

As you can see the given example of List and Tuples. The list and Tuple both are able to contains each others. List is Changeable or Tuples are Unchangeable in Python.

, , , ,

No comments:

Post a Comment