Posts

Showing posts from April, 2021

Python List, Tuple and Dictionary

Image
  Python List List in python is implemented to store the sequence of various type of data. However, python contains six data types that are capable to store the sequences but the most common and reliable type is list. A list can be defined as a collection of values or items of different types. The items in the list are separated with the comma (,) and enclosed with the square brackets []. A list can be defined as follows. L1 = [ "John" ,  102 ,  "USA" ]   L2 = [ 1 ,  2 ,  3 ,  4 ,  5 ,  6 ]   L3 = [ 1 ,  "Ryan" ]   If we try to print the type of L1, L2, and L3 then it will come out to be a list. Lets consider a proper example to define a list and printing its values. emp = [ "John" ,  102 ,  "USA" ]    Dep1 = [ "CS" , 10 ];   Dep2 = [ "IT" , 11 ];   HOD_CS = [ 10 , "Mr. Holding" ]   HOD_IT = [ 11 ,  "Mr. Bewon" ]   print ( "printing employee data..." );   print ( "Name : %s, ID: %d,