Bot-Tech - online Programming Learning Platform.

Python tutorial, Online learning, SEO mastery, Blogging, Youtube, latest tech news, Web development, How to fix, Best of and Programming languages learning for free.

Friday, June 21, 2019

List in Python | Python tutorial for beginners | Python Basics #5


List in Python | Python tutorial:

in this tutorial, we will learn everything about Python list. how they are created, slicing of the list, adding and remove elements from them and lots of.

#5 Python tutorial for beginners | list in Python:



in this Python video tutorial we will see:

  • working with list
  • what is list in Python
  • How to use list in Python
  • Assign multiple values to the variable
  • Printing value for list
  • Printing value for list By index number
  • String list
  • list of different types of data types
  • creating a list with the list: nested list
  • Append function
  • insert function
  • remove function
  • Pop function
  • delete function
  • extend function
  • the inbuilt function of the list: min, max, sum
  • sort function

what is list in Python?

The lists are python's most versatile data structures, as they are unchangeable and their values can be updated with the slice and assignor. Python offers an append ( ) function that allows us to add an item to the list.
Python, however, contains six types of data capable of storing sequences, but the most common and reliable type is a list.


>>Get Python course for free.>>what is variables in Python?>>Python basics.

how to use list in Python?Python has a great built-in list type named "list". List literals are written within square brackets [ ]. Lists work similarly to strings -- use the len() function and square brackets [ ] to access data, with the first element at index 0.example:
companies  = ['apple', 'google', 'ford']
Print companies[0]
result: apple
Print companies[2]  
result: ford
Print len(compnaies)
result: 3

Assign multiple values to the variable:

if you can see one array which numbers. we have the second derivative names. which are of string we can get a different list of different types. now can I get a list of different types? I will simply call it values equal to and I want to have a double value. here example the first one I would say is 9.5. which is a float value then I want to go forward a string go with my name and then let's say another one. which is 25 which is number right. so we have a float number we have a string and integer number.
example:
values =[9.5, 'Navin', 25]
Print(values)
result: 9.5, Navin, 25

Python list functions:


Method           Description

append() Adds an element at the end of the list
clear()  Removes all the elements from the list
copy()         Returns a copy of the list
count()         Returns the number of elements with the specified value
extend() Add the elements of a list (or any iterable), to the end of the
current list
index()    Returns the index of the first element with the specified value
insert() Adds an element at the specified position
pop()         Removes the element at the specified position
remove() Removes the first item with the specified value
reverse() Reverses the order of the list

sort()         Sorts the list

use key "ctrl+space" to get list function(by pop-up) suggestions.

append() function:

in append function, you can add elements at the end of the list.
example:
marks = [88, 76, 45, 34]
marks.append(69)
result: [88, 76, 45, 34, 69]
2nd
number = [67, 56, 42, 19]
number.append(96)
result: [67, 56, 42, 19, 96] 

extend() function:

in this function, you can Add the elements of a list (or any iterable), to the end of the current list.
example:
marks = [88, 76, 45, 34]
marks.extend([59, 62, 69, 90])
result: [88, 76, 45, 34, 59, 62, 69, 90]

 more examples for Python list function:

number = [99, 67, 52, 19]
min(number)
result: 19
max(number)
result: 99
sum(number)
result: 237

<<-What is variables in Python?

 Conclusion:

I hope you liked the post. And all the points you told me will come to understand. If you have a question similar to that, then you can ask us by commenting. If you liked the post, please share this post with all your friends on social media. Also, B-T to Follow aware of all the new posts and can continue to receive. 


1 comment: