SlideShare a Scribd company logo
1 of 22
INFORMATION
TECHNOLOGIES
Data types in Python. Lists.
Data types in Python
Python has several standard data types:
 Numbers
 Strings
 Lists
 Dictionaries
 Tuples
 Sets
 Boolean
Classification of data types in Python
Data types can be classified according to several criteria:
 mutable (lists, dictionaries and sets)
 immutable (numbers, strings and tuples)
 ordered (lists, tuples, strings and dictionaries)
 unordered (sets) types can be classified according to several criteria:
Classification of data types in Python
Data type Mutable Immutable Ordered Unordered
Numbers +
Strings + +
Lists + +
Dictionaries + +
Tuples + +
Sets + +
Lists in Python
Список в Python это:
 последовательность элементов, разделенных между собой запятой и
заключенных в квадратные скобки
 изменяемый упорядоченный тип данных
 A data structure, which in most programming languages is called an array. In
Python it is called a list. A list is a sequence of elements, numbered from 0,
like the characters in a string.
Lists in Python
 Примеры списков:
 list1 = [10,20,30,77]
 list2 = ['one', 'dog', 'seven']
 list3 = [1, 20, 4.0, 'word']
Lists in Python
A list can be created using a literal or the list() built-in function
 Creating a list with a literal:
list1 = [10,20,30,77]
Creating a list with a function list():
 list2 = list('Hello')
Empty list
There are two ways to create an empty list:
 Use empty square brackets [];
 Use the built-in function called list.
mylist = [] # empty list
mylist = list() # empty list
Lists in Python
 Since the list is an ordered data type, then, as in strings, in lists you can
access an element by number, make slices:
list3 = [1, 20, 4.0, 'word']
print(list3[1])
print(list3[1::])
print(list3[-1])
print(list3[::-1])
Lists in Python
 You can also reverse a list using the reverse() method:
list3 = [1, 20, 4.0, 'word']
print(list3)
list3.reverse()
print(list3)
Lists in Python
 Since lists are mutable, the elements of the list can be changed:
list3 = [1, 20, 4.0, 'word']
print(list3)
list3[0] = 'test'
print(list3)
Lists in Python
 You can also create a list of lists. And, just like in a regular list, you can
access elements in nested lists:
interfaces = [['FastEthernet0/0', '15.0.15.1', 'YES', 'manual', 'up', 'up'],
['FastEthernet0/1', '10.0.1.1', 'YES', 'manual', 'up', 'up'],
['FastEthernet0/2', '10.0.2.1', 'YES', 'manual', 'up', 'down']]
print(interfaces)
print(interfaces[0][0])
print(interfaces[2][0])
print(interfaces[2][1])
Lists in Python
 The len() function for a list returns the number of elements in the list:
items = [1, 2, 3]
print(len(items))
Lists in Python
 The sorted() function sorts the elements of a list in ascending order and
returns a new list with the sorted elements:
names = ['John', 'Michael', 'Antony']
print(sorted(names))
Obviously it have few parameters
sorted(iterable, key=key, reverse=reverse)
iterable - Required. The sequence to sort, list, dictionary, tuple etc.
key - Optional. A Function to execute to decide the order. Default is None
reverse - Optional. A Boolean. False will sort ascending, True will sort
descending. Default is False
Useful methods for work with lists
A list is a mutable data type, so it's important to note that most list methods
change the list “in place” without returning anything.
 append
 extend
 pop
 remove
 index
 insert
 sort
Useful methods for work with lists
 Append
The append method adds the specified element to the end of the list:
list1 = ['10', '20', '30', '100-200']
list1.append('300')
print(list1)
The append method changes the list in place and returns nothing. If in a script
you need to add an element to the list, and then print the list, you need to do
this on different lines of code.
Useful methods for work with lists
 Extend
If you need to combine two lists, then you can use two methods: the extend
method and the addition operation.
These methods have an important difference - extend changes the list to which
the method is applied, and summing returns a new list, which consists of two.
list1 = ['10', '20', '30', '100-200']
list2 = ['15', '25', '35']
list1.extend(list2)
print(list1)
print(list1 + list2)
Useful methods for work with lists
 pop
The pop method removes the element that matches the specified number. But,
what is important, the method returns this element:
list1 = ['10', '20', '30', '100-200']
print(list1.pop(-1))
print(list1)
! Without a number, the last element of the list is removed.
Useful methods for work with lists
 remove
The remove method removes the specified element.
The remove method does not return the removed element:
list1 = ['10', '20', '30', '100-200']
print(list1.remove('20')) #return None in output, but still change a list)
print(list1)
In the remove method, you must specify the element itself to be removed, and
not its number in the list. If you specify an element number, an error will occur.
Useful methods for work with lists
 index
The index method is used to check which number an element is stored in the list:
list1 = ['10', '20', '30', '100-200']
print(list1.index('20'))
Useful methods for work with lists
 insert
The insert method allows you to insert an element at a specific position in the
list:
list1 = ['10', '20', '30', '100-200']
list1.insert(1, '2000')
print(list1)
Useful methods for work with lists
 sort
The sort method sorts the list in place:
list1 = ['190', '200', '3', '10-2']
list2 = [90, 100, 2, 0, -1]
list1.sort()
list2.sort()
print(list1)
print(list2)
Notes
 Note 1: As already mentioned, lists in Python are similar to arrays in other
programming languages. However, there is still a difference between lists and
arrays. Array elements always have the same data type and are located in the
computer's memory in a continuous block, while list elements can be
scattered in memory as you like and can have different data types.
 Note 2. Please note that when displaying the contents of the list using the
print () function, all string elements of the list are surrounded by single
quotes. If you want to output in double quotes, you need to write the output
code yourself.

More Related Content

Similar to Lecture2.pptx

Python Unit 5 Questions n Notes.pdf
Python Unit 5 Questions n Notes.pdfPython Unit 5 Questions n Notes.pdf
Python Unit 5 Questions n Notes.pdf
MCCMOTOR
 

Similar to Lecture2.pptx (20)

Module-2.pptx
Module-2.pptxModule-2.pptx
Module-2.pptx
 
Pytho lists
Pytho listsPytho lists
Pytho lists
 
Python list
Python listPython list
Python list
 
GE3151_PSPP_UNIT_4_Notes
GE3151_PSPP_UNIT_4_NotesGE3151_PSPP_UNIT_4_Notes
GE3151_PSPP_UNIT_4_Notes
 
Data structures: linear lists
Data structures: linear listsData structures: linear lists
Data structures: linear lists
 
Python Data Types.pdf
Python Data Types.pdfPython Data Types.pdf
Python Data Types.pdf
 
Python Data Types (1).pdf
Python Data Types (1).pdfPython Data Types (1).pdf
Python Data Types (1).pdf
 
The Ring programming language version 1.5.3 book - Part 22 of 184
The Ring programming language version 1.5.3 book - Part 22 of 184The Ring programming language version 1.5.3 book - Part 22 of 184
The Ring programming language version 1.5.3 book - Part 22 of 184
 
Python Unit 5 Questions n Notes.pdf
Python Unit 5 Questions n Notes.pdfPython Unit 5 Questions n Notes.pdf
Python Unit 5 Questions n Notes.pdf
 
Python lists
Python listsPython lists
Python lists
 
Python for Beginners(v3)
Python for Beginners(v3)Python for Beginners(v3)
Python for Beginners(v3)
 
Chapter 15 Lists
Chapter 15 ListsChapter 15 Lists
Chapter 15 Lists
 
Python List.ppt
Python List.pptPython List.ppt
Python List.ppt
 
python_avw - Unit-03.pdf
python_avw - Unit-03.pdfpython_avw - Unit-03.pdf
python_avw - Unit-03.pdf
 
Python-List.pptx
Python-List.pptxPython-List.pptx
Python-List.pptx
 
8 python data structure-1
8 python data structure-18 python data structure-1
8 python data structure-1
 
The Ring programming language version 1.6 book - Part 24 of 189
The Ring programming language version 1.6 book - Part 24 of 189The Ring programming language version 1.6 book - Part 24 of 189
The Ring programming language version 1.6 book - Part 24 of 189
 
Unit - 4.ppt
Unit - 4.pptUnit - 4.ppt
Unit - 4.ppt
 
GE3151 PSPP UNIT IV QUESTION BANK.docx.pdf
GE3151 PSPP UNIT IV QUESTION BANK.docx.pdfGE3151 PSPP UNIT IV QUESTION BANK.docx.pdf
GE3151 PSPP UNIT IV QUESTION BANK.docx.pdf
 
The Ring programming language version 1.10 book - Part 30 of 212
The Ring programming language version 1.10 book - Part 30 of 212The Ring programming language version 1.10 book - Part 30 of 212
The Ring programming language version 1.10 book - Part 30 of 212
 

Recently uploaded

Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
gajnagarg
 
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Klinik kandungan
 
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
nirzagarg
 
怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制
怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制
怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制
vexqp
 
Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...
Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...
Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...
gajnagarg
 
Gartner's Data Analytics Maturity Model.pptx
Gartner's Data Analytics Maturity Model.pptxGartner's Data Analytics Maturity Model.pptx
Gartner's Data Analytics Maturity Model.pptx
chadhar227
 
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
gajnagarg
 
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
nirzagarg
 
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...
nirzagarg
 
Diamond Harbour \ Russian Call Girls Kolkata | Book 8005736733 Extreme Naught...
Diamond Harbour \ Russian Call Girls Kolkata | Book 8005736733 Extreme Naught...Diamond Harbour \ Russian Call Girls Kolkata | Book 8005736733 Extreme Naught...
Diamond Harbour \ Russian Call Girls Kolkata | Book 8005736733 Extreme Naught...
HyderabadDolls
 
Kalyani ? Call Girl in Kolkata | Service-oriented sexy call girls 8005736733 ...
Kalyani ? Call Girl in Kolkata | Service-oriented sexy call girls 8005736733 ...Kalyani ? Call Girl in Kolkata | Service-oriented sexy call girls 8005736733 ...
Kalyani ? Call Girl in Kolkata | Service-oriented sexy call girls 8005736733 ...
HyderabadDolls
 

Recently uploaded (20)

Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
 
Vadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book now
Vadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book nowVadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book now
Vadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book now
 
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
 
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
 
7. Epi of Chronic respiratory diseases.ppt
7. Epi of Chronic respiratory diseases.ppt7. Epi of Chronic respiratory diseases.ppt
7. Epi of Chronic respiratory diseases.ppt
 
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
 
怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制
怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制
怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制
 
Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...
Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...
Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...
 
Gartner's Data Analytics Maturity Model.pptx
Gartner's Data Analytics Maturity Model.pptxGartner's Data Analytics Maturity Model.pptx
Gartner's Data Analytics Maturity Model.pptx
 
💞 Safe And Secure Call Girls Agra Call Girls Service Just Call 🍑👄6378878445 🍑...
💞 Safe And Secure Call Girls Agra Call Girls Service Just Call 🍑👄6378878445 🍑...💞 Safe And Secure Call Girls Agra Call Girls Service Just Call 🍑👄6378878445 🍑...
💞 Safe And Secure Call Girls Agra Call Girls Service Just Call 🍑👄6378878445 🍑...
 
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
 
Statistics notes ,it includes mean to index numbers
Statistics notes ,it includes mean to index numbersStatistics notes ,it includes mean to index numbers
Statistics notes ,it includes mean to index numbers
 
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
 
Fun all Day Call Girls in Jaipur 9332606886 High Profile Call Girls You Ca...
Fun all Day Call Girls in Jaipur   9332606886  High Profile Call Girls You Ca...Fun all Day Call Girls in Jaipur   9332606886  High Profile Call Girls You Ca...
Fun all Day Call Girls in Jaipur 9332606886 High Profile Call Girls You Ca...
 
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...
 
Vastral Call Girls Book Now 7737669865 Top Class Escort Service Available
Vastral Call Girls Book Now 7737669865 Top Class Escort Service AvailableVastral Call Girls Book Now 7737669865 Top Class Escort Service Available
Vastral Call Girls Book Now 7737669865 Top Class Escort Service Available
 
Diamond Harbour \ Russian Call Girls Kolkata | Book 8005736733 Extreme Naught...
Diamond Harbour \ Russian Call Girls Kolkata | Book 8005736733 Extreme Naught...Diamond Harbour \ Russian Call Girls Kolkata | Book 8005736733 Extreme Naught...
Diamond Harbour \ Russian Call Girls Kolkata | Book 8005736733 Extreme Naught...
 
Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...
Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...
Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...
 
Kalyani ? Call Girl in Kolkata | Service-oriented sexy call girls 8005736733 ...
Kalyani ? Call Girl in Kolkata | Service-oriented sexy call girls 8005736733 ...Kalyani ? Call Girl in Kolkata | Service-oriented sexy call girls 8005736733 ...
Kalyani ? Call Girl in Kolkata | Service-oriented sexy call girls 8005736733 ...
 
Ranking and Scoring Exercises for Research
Ranking and Scoring Exercises for ResearchRanking and Scoring Exercises for Research
Ranking and Scoring Exercises for Research
 

Lecture2.pptx

  • 2. Data types in Python Python has several standard data types:  Numbers  Strings  Lists  Dictionaries  Tuples  Sets  Boolean
  • 3. Classification of data types in Python Data types can be classified according to several criteria:  mutable (lists, dictionaries and sets)  immutable (numbers, strings and tuples)  ordered (lists, tuples, strings and dictionaries)  unordered (sets) types can be classified according to several criteria:
  • 4. Classification of data types in Python Data type Mutable Immutable Ordered Unordered Numbers + Strings + + Lists + + Dictionaries + + Tuples + + Sets + +
  • 5. Lists in Python Список в Python это:  последовательность элементов, разделенных между собой запятой и заключенных в квадратные скобки  изменяемый упорядоченный тип данных  A data structure, which in most programming languages is called an array. In Python it is called a list. A list is a sequence of elements, numbered from 0, like the characters in a string.
  • 6. Lists in Python  Примеры списков:  list1 = [10,20,30,77]  list2 = ['one', 'dog', 'seven']  list3 = [1, 20, 4.0, 'word']
  • 7. Lists in Python A list can be created using a literal or the list() built-in function  Creating a list with a literal: list1 = [10,20,30,77] Creating a list with a function list():  list2 = list('Hello') Empty list There are two ways to create an empty list:  Use empty square brackets [];  Use the built-in function called list. mylist = [] # empty list mylist = list() # empty list
  • 8. Lists in Python  Since the list is an ordered data type, then, as in strings, in lists you can access an element by number, make slices: list3 = [1, 20, 4.0, 'word'] print(list3[1]) print(list3[1::]) print(list3[-1]) print(list3[::-1])
  • 9. Lists in Python  You can also reverse a list using the reverse() method: list3 = [1, 20, 4.0, 'word'] print(list3) list3.reverse() print(list3)
  • 10. Lists in Python  Since lists are mutable, the elements of the list can be changed: list3 = [1, 20, 4.0, 'word'] print(list3) list3[0] = 'test' print(list3)
  • 11. Lists in Python  You can also create a list of lists. And, just like in a regular list, you can access elements in nested lists: interfaces = [['FastEthernet0/0', '15.0.15.1', 'YES', 'manual', 'up', 'up'], ['FastEthernet0/1', '10.0.1.1', 'YES', 'manual', 'up', 'up'], ['FastEthernet0/2', '10.0.2.1', 'YES', 'manual', 'up', 'down']] print(interfaces) print(interfaces[0][0]) print(interfaces[2][0]) print(interfaces[2][1])
  • 12. Lists in Python  The len() function for a list returns the number of elements in the list: items = [1, 2, 3] print(len(items))
  • 13. Lists in Python  The sorted() function sorts the elements of a list in ascending order and returns a new list with the sorted elements: names = ['John', 'Michael', 'Antony'] print(sorted(names)) Obviously it have few parameters sorted(iterable, key=key, reverse=reverse) iterable - Required. The sequence to sort, list, dictionary, tuple etc. key - Optional. A Function to execute to decide the order. Default is None reverse - Optional. A Boolean. False will sort ascending, True will sort descending. Default is False
  • 14. Useful methods for work with lists A list is a mutable data type, so it's important to note that most list methods change the list “in place” without returning anything.  append  extend  pop  remove  index  insert  sort
  • 15. Useful methods for work with lists  Append The append method adds the specified element to the end of the list: list1 = ['10', '20', '30', '100-200'] list1.append('300') print(list1) The append method changes the list in place and returns nothing. If in a script you need to add an element to the list, and then print the list, you need to do this on different lines of code.
  • 16. Useful methods for work with lists  Extend If you need to combine two lists, then you can use two methods: the extend method and the addition operation. These methods have an important difference - extend changes the list to which the method is applied, and summing returns a new list, which consists of two. list1 = ['10', '20', '30', '100-200'] list2 = ['15', '25', '35'] list1.extend(list2) print(list1) print(list1 + list2)
  • 17. Useful methods for work with lists  pop The pop method removes the element that matches the specified number. But, what is important, the method returns this element: list1 = ['10', '20', '30', '100-200'] print(list1.pop(-1)) print(list1) ! Without a number, the last element of the list is removed.
  • 18. Useful methods for work with lists  remove The remove method removes the specified element. The remove method does not return the removed element: list1 = ['10', '20', '30', '100-200'] print(list1.remove('20')) #return None in output, but still change a list) print(list1) In the remove method, you must specify the element itself to be removed, and not its number in the list. If you specify an element number, an error will occur.
  • 19. Useful methods for work with lists  index The index method is used to check which number an element is stored in the list: list1 = ['10', '20', '30', '100-200'] print(list1.index('20'))
  • 20. Useful methods for work with lists  insert The insert method allows you to insert an element at a specific position in the list: list1 = ['10', '20', '30', '100-200'] list1.insert(1, '2000') print(list1)
  • 21. Useful methods for work with lists  sort The sort method sorts the list in place: list1 = ['190', '200', '3', '10-2'] list2 = [90, 100, 2, 0, -1] list1.sort() list2.sort() print(list1) print(list2)
  • 22. Notes  Note 1: As already mentioned, lists in Python are similar to arrays in other programming languages. However, there is still a difference between lists and arrays. Array elements always have the same data type and are located in the computer's memory in a continuous block, while list elements can be scattered in memory as you like and can have different data types.  Note 2. Please note that when displaying the contents of the list using the print () function, all string elements of the list are surrounded by single quotes. If you want to output in double quotes, you need to write the output code yourself.

Editor's Notes

  1. Part 1 for lists probably
  2. Check with list1 = [10,20,30,77] Print(list1) list2 = list('Hello') Print(list2)
  3. Check output with this examples
  4. Check output with this examples
  5. Check output with this examples
  6. Check output with this examples
  7. Check output with this examples
  8. Check output with this examples
  9. Check output with this examples
  10. Check output with this examples
  11. Please note that when summing lists, the result of the summation can be assigned to a variable. With append result will be more interesting list1 = ['190', '200', '3', '10-2'] list2 = [90, 100, 2, 0, -1] list3 = list1 + list2 list4 = list1.append(list2) print(list3) print(list4) print(list1)