Python Data Structures

  • 2 days ago
DEAR SIR/MADAM, I NEED THIS CHANNEL SPONSORSHIP FROM YOU TOO IF POSSIBLE https://www.dailymotion.com/mokkamodina19

DEAR SIR/MADAM, PLEASE ACCEPT AND PERMISSION DAILY MOTION, VIMEO AND RUMBLE.COM IN BANGLADESH.
Mohammad Ali Ashraf, [6/29/2024 7:07 PM]
https://ea.ebs.bankofchina.com/contactUs_en.html

ashrafm703@gmail.com IS MY EMAIL AND
DEAR SIR/MADAM, I NEED SUPPORT AND LOAN FROM CHINESE PRESIDENT AND GOVT.

DEAR SIR/MADAM, I WANT LOAN FROM YOU TO LEARN AND EARN MONEY BY THE SUPER AFFILIATE MARKETING OF JOHN CRESTANI.

DEAR SIR/MADAM.I AM FROM BANGLADESH MY PAYONEER ID IS mokkamodina19@gmail.com , IN ANY BANK ACCOUNTS OF BANGLADESH IS NOT SAFE FOR MY MONEY YOU KNOW THAT. WILL PAYONEER BANK ACCOUNTS OF MINE WILL BE SAFE FOR MY MONEY.? ALL OF MY ASSETS OR PROPERTIES ARE SEIZED BY FAKE WAYS IN BANGLADESH. I WANT TO LOAN FROM YOU TO BUY READYMADE HOUSES OR HOMES FOR ME. ALSO NEED LOANS FROM YOU WORK OR JOB VISA FOR USA/CANADA. ALSO NEED LOAN FROM YOU TO SETTLE AND STUDY IN THE USA/CANADA.. I WANT TO HANDOVER ALL OF MY ASSETS OR PROPERTIES WHICH ARE SEIZED BY FAKE WAYS TO THE USA/CANADA UNIVERSITIES.

https://www.aiddata.org/how-china-lends

mokkamodina19@gmail.com is my payoneer id. i want my youtube channel sponsorship from you.https://www.youtube.com/channel/UCrNbtmpYbyYMgmzD9aPtGMQ
and also help me to monetize my tiktok https://www.tiktok.com/@mohammadaliashr3


AFTER MONETIZATION I WANT THIS LINK SPONSORSHIP FROM YOU TOO. https://rutube.ru/channel/37901720/ ,,,,mokkamodina19@gmail.com is my payoneer id.
Transcript
00:00Hello everyone, welcome to this session about python data structures where you will be studying
00:14about tuples, how can insert the values in a tuple, deleting, modifying, all these kind
00:21of arrays, list, then different dictionaries, how all these concepts can be included in
00:27the data structure, so let's move on.
00:31So first we will be learning about the python tuple, tuple matching in python is a method
00:36of grouping the tuples by matching the second element in a tuple, it is basically a set
00:43of array or list that you have formed, now it is achieved by using a dictionary by checking
00:49the second element in each tuple of a python program.
00:54Now we have a syntax here, you can use the short form of tuple as tup which is equal
01:01to you can say x, y, z, now here I have mentioned the months June, July, August, so this is
01:08how generally the syntax looks like, you are giving tup and the list or the elements that
01:15is required, now to empty a tuple basically if you don't want anything in your tuple
01:21you can just give the word tup and just keep it blank inside the braces, now if you want
01:28to include just one element this is how the syntax looks like, you can just include one
01:34element put a comma and just keep it blank and close the braces, so this is how the general
01:41form of a tuple syntax look like.
01:45Now how to assign values in the tuple, the tuple assignment, this feature basically enables
01:52us to assign more than one variable at a time, so look at our program here, we have two tuples
02:00tup1 and tuple2, so the first tuple includes the list of certain things like the name,
02:09the color, the designation and to where she belongs, then the next tuple includes a list
02:18of numbers such as 1, 2, 3, 4, 5, 6, 7, now what I want is from the tuple1 I want to print
02:27the value that is being assigned in 1 and the value assigned for the third, now for
02:33the tuple2 I want the value to be printed from 0 and 5, so basically you see the tuple1
02:43here Krishma it is in the position of 0, karta is in the position of 1, 1988 is the position
02:51of 2, so this is how it has been assigned.
02:54Now for the tuple2 the value 1 is in the position of 0, 2 in the position of 1, so this is how
03:00it goes, so when I am saying from the tuple1 I need to print the values of 1 and 3, so
03:07definitely which values will come, the value karta and the value 1998, now if I want to
03:19print the value of from tuple2 the value which is therefore 0 to 5, definitely the values
03:28will come from 1, 2, 3, 4, 5, so this is how the values will be ranging, you can print
03:38the values that stands from, so when 1 is to 3 means you are printing the values that
03:44are coming from 1 is to 3 that is from 0, 1, 2 you count in that way, so just run this
03:51code you will understand how this tuple concept works.
03:56Now basically we will be learning about the packing and unpacking technique here used
04:00for tuple, packing you are placing a value into a new tuple, unpacking is basically extracting
04:08those values back into the variable, so now I am using the variable x here and I am assigning
04:15the tuple packing values such as uni, athena, 500, education, now tuple unpacking is basically
04:24you are taking the same, you are assigning some values related to it and you are assigning
04:29a variable, for example it is a company that you are having an employee ID and the profile
04:35of that company, so basically you are unpacking it, so now here I am printing the company
04:43name, printing the employee ID and I am printing the employee profile, so that is when the
04:51variables will come that is uni, athena, 500, education, so this is how the tuple packing
04:58and unpacking takes place that is you are placing a value into a new tuple and you are
05:03extracting the values from the tuple, so this is how the packing and unpacking technique
05:09works.
05:10Now you are comparing a tuple, so basically a comparison is basically between two tuples
05:17where you can find if the value is equal to 1, tuple 1 to tuple 2 is equal to or greater
05:23than or less than, so all this concept can be applied, so comparison operators in python
05:29can work with tuples, okay the comparison starts with the first element of each tuple,
05:36if they do not compare to equal to less than or greater than then it proceeds to the second
05:43element, so always remember the first elements are compared, if it does not match then only
05:49it will proceed to the second element or so on, so it starts comparing basically with
05:56the first element.
05:57So here I have given an example, I am taking a tuple A, I am assigning a value A, 5 and
06:036 then B, 1 and 4, so basically I am programming it in such a way that if the A is greater
06:10than B print A, if B is greater than A print B, so just run this program and you will find
06:17out exactly, so here from with this we can understand that tuple A is greater than the
06:23value of tuple B that is the first element here is being compared that is 5 and 1, if
06:30it does not, if it did not work out definitely you will compare the second element.
06:37Now you can even delete the entire tuple, deleting optional tuple always remember you
06:43can delete the entire tuple, you cannot delete the one variable that is required, okay so
06:50tuples are immutable and cannot be deleted, you cannot delete or remove items from a tuple,
06:58but deleting the tuple entirely is possible using the DEL command, okay.
07:05Now even slicing can be applied for tuple to fetch specific sets of sub elements from
07:11tuple or a list we use this unique function called slicing, okay slicing is not only applicable
07:18for tuple, but it could also be used for arrays or list, now I have given an example here
07:26you can use this for how slicing can be applied.
07:30Now we learn the advantages of tuples over a list, so we know tuples are immutable basically
07:36we cannot delete or insert any kind of elements inside it, if we want to delete the tuple
07:42we have to delete the tuple in entire form, so iterating to the tuple is much faster when
07:48compared with the list because tuples are immutable.
07:52Now tuple consist of since it is immutable we can use this as a key elements for dictionary
07:59which is not possible with the list, now if you have a data a set of data that is immutable
08:06implementing it in a tuple will help us to generate the output as desired and it is quite
08:13protected, okay.
08:14So, we need not worry about any such kinds of you know missing value issues or anybody
08:22altering with the data because since the tuples are immutable if we use data's that are
08:29immutable it will be helpful for us in the case of tuple listing rather than listing
08:34issues.
08:36Now we will come to the python dictionary, okay it is an unordered and changeable collection
08:42of data values that holds key value pairs, now each key value pair in the dictionary
08:50maps the key to its associated value making it more optimized, now a dictionary in python
08:57can be declared by enclose by enclosing it in a bracket in a comma separated list of
09:03a key value pairs using curly braces.
09:07Now python dictionary is classified into two elements here one is keys and values, keys
09:14will be a single element and values can be a list or list within a list numbers etcetera,
09:21okay so this is how the syntax looks here, we can use DICT it is a short form of dictionary
09:28and you can just implement it for example I am specifying a name for specifying the
09:34age then any details that I can I want, so it can be implement within a list or a list
09:42within a list, so this is how the python dictionary works.
09:47Now what are the properties of a python dictionary keys, okay there are two important points
09:53while using dictionary keys, first one is more than one entry per key is not allowed
09:59that is no list within a list, so this is how the python dictionary works.
10:09Now what are the properties of a python dictionary keys, okay there are two important points
10:14while using dictionary keys, first one is more than one entry per key is not allowed
10:20that is no duplication is allowed, now values in the dictionary can be of any type, okay
10:27now while the key must be immutable like numbers, tuples or strings always remember values can
10:35be of any type but the keys should be immutable just as in the case of tuple.
10:42Now dictionary keys are very case sensitive, okay same key name but with the different
10:47cases are treated as different keys in python dictionary, okay case sensitive means spellings
10:55you know the capital letters, small letters, so all these kind of things that should be
11:00it should be noted when we are using the dictionary keys.
11:05Now this is certain examples here that is the method descriptions and the syntax for
11:11the list included, first one is copy basically you know we are copying the entire dictionary
11:16to a new dictionary and the syntax uses dig.copy and the this is, now then you are using update
11:23basically you are updating a dictionary by adding a new entry or you know deleting anything
11:29and for that for the syntax here is dig.update.
11:33Now the items you know basically returning a list of tuple pairs, okay for this we are
11:38using dictionary.items, now sorting if you can sort the elements within for that you
11:44are using dig.sort, dictionary.sort and for the length that is the number of pairs in
11:50the dictionary, okay number of pairs of elements in the dictionary for that you will be using
11:56length of dig.
11:58Now next is comparison that is cmp, comparing the values or the keys of the dictionary for
12:06that you can use cmp of dictionary 1, dictionary 2 etc.
12:10Now string, okay that is we are making a string format we need a specific format make a dictionary
12:17into a string printable string format for that we are using str of dig, okay so these
12:26are the methods that have been included in our dictionary.
12:31Now we are example here is merging two dictionaries using update method, okay so now I am giving
12:37a dictionary name I have two dictionary list here that is dictionary 1 consisting of certain
12:42location, dictionary 2 consisting of certain other list.
12:46Now I basically want to update my dictionary 1 and dictionary 2 list, okay so I am asking
12:53them to print the dictionary 1, okay after updating I am asking them to print the dictionary
13:001 that is you are merging the dictionary 1 element and dictionary 2 together and forming
13:06it into dictionary 1 element.
13:07So what is happening here?
13:09Dictionary 1 is merged with dictionary 2 and you are getting a single list so this is one
13:16of the example of how you are merging two dictionaries together using update function.
13:23Now certain inbuilt methods that have been used in dictionary 1 is the clear function,
13:29okay clear is already inbuilt in a dictionary then you have appending so before clearing
13:34it removes all the elements from the dictionary.
13:37Now what is append?
13:39It is an inbuilt function in python that helps to update the values for the keys in the dictionary.
13:46Now other method is update function it helps us to merge one dictionary into another.
13:54Now next one is swap function it removes the elements from the dictionary.
13:59So these are all the built-in methods of a dictionary.
14:03Now we have python operators, okay python operators such as you know arithmetic operators
14:09and comparison operators.
14:11So arithmetic operators I need not say it is basically adding you know deleting or minusing
14:17or anything or subtracting anything of the arithmetic form that is for that reason we
14:22are using arithmetic operators.
14:25Comparison operators definitely you know larger than, less than, equal to all this is comparison
14:30operators.
14:31Now how do you assign in a python assignment of the operators, assigning operators in a
14:37python are used for assigning the value of the right operand to the left operand, okay.
14:43So for that you know you can use all these kind of simple plus or equal to minus equal
14:48to you know division, multiplication etc.
14:52So this is one of an example here where you are assigning the value to number 1 and number
14:582, you are adding the values that is of number 1 and number 2 to generate a result you are
15:04giving this procedure and finally you are getting an end result.
15:08So this is an example that you can run in your python and you can find the end result.
15:13Now logical operators such as AND operator, OR operator, NOT operator, okay.
15:19For AND operator it returns true if both the operands are true that is both the left and
15:26the right is true.
15:27Now for OR operator it returns true if either that is either left or the right is true.
15:34Now for NOT operator it is basically if it returns true if the operand is false.
15:41So this is how the function the program here looks like if you are saying A and B you are
15:47asking them to print if A and B then print A or print NOT A so what is it false, okay.
15:55So this is how the logical operator works.
15:59So this is how you can program and you can try and run it.
16:03Now there is a other thing called membership operator.
16:06So these operators test for membership in a sequence such as list, strings or tuple.
16:12There are two membership operators that are used in python IN and NOT IN.
16:17It gives the result based on the variables present in the specified sequence or string.
16:25Please note this IN and NOT IN.
16:29So there is an example here we are assigning the variables, okay for x is equal to 10 and
16:34y is equal to 5 and you are giving a list and how the IN and NOT IN membership operator
16:41works for this program.
16:44Now we have identity operators, okay.
16:47Identity operators in python are used to compare the memory location of two objects.
16:53This is the memory location of two objects.
16:56Now to identify the operators used in python are IS, ISNOT, okay.
17:03So the operator IS here, it returns true if two variables point the same object and false
17:10otherwise.
17:11Operator ISNOT, it returns false if two variables point the same object and true otherwise.
17:20So this is how the identity operator works.
17:23Now next we have operator precedence, okay.
17:27The operator precedence determines which operators needs to be evaluated first.
17:33To avoid ambiguity in values, the precedence operators are necessary just like in a normal
17:40multiplication method which has higher precedence than addition.
17:45I hope you are familiar with the term board mass, okay.
17:49So we are applying for long equations where you have all the operators, arithmetic operators
17:56and arithmetics together.
17:57You are applying the rules of board mass.
17:59The same thing you can use here in operator precedence.
18:03So declaring the value of variable, then now you apply the formula and you run the code
18:08and finally you give the output.
18:12Now we are coming to the python array, a collection of common type of data structures having element
18:20with same data type.
18:21That is called array.
18:22It is used to store a collections of data.
18:25Now in python programming, array can be handled by the array module.
18:31If you create arrays using the array module, elements of the array must be of the same
18:36numeric type, okay.
18:38Now what are the uses of array in python?
18:41Python arrays are used when you need to use many variables which are of the same type.
18:46Now it can also be used to store a collection of data.
18:52Now arrays are especially useful when you have to process the data dynamically.
18:58Now python arrays are much faster than list as it uses less memory.
19:03So these are the advantages of array in python.
19:07Now this is the syntax here of array.
19:09You have to name an array, then you give array.array, then type of, you know, data type and array
19:15items, whatever.
19:16So here identifier, it specifies a name like usually you do for the variables, okay.
19:23Now module here, python has a special module for creating array in python, okay, called
19:30array.
19:31You must import it.
19:32So that is why you are using this array here.
19:35Now the method, the array module has a method for initializing the array.
19:41It takes two arguments that is type code for data type.
19:45So this is the method used here.
19:48This is the module and this is the identifier.
19:52Now the type code is to specify the data type using the type of codes of available and definitely
19:59elements.
20:00It is especially useful when you have to process the data dynamically.
20:08Now python arrays are much faster than list as it uses less memory.
20:14So these are the advantages of array in python.
20:18Now this is the syntax here of array.
20:20You have to name an array, then you give array.array, then type of, you know, data type and array
20:25items, whatever.
20:27So here identifier, it specifies a name like usually you do for the variables, okay.
20:33Now module here, python has a special module for creating array in python, okay, called
20:40array.
20:41You must import it.
20:43Now this is the method, the array module has a method for initializing the array.
20:52It takes two arguments that is type code for data type.
20:55So this is the method used here.
20:58This is the module and this is the identifier.
21:02Now the type code is to specify the data type using the type of codes of available and definitely
21:09elements you know specify the array elements here inside the bracket.
21:15So this is how type code and method module and identify, so this is how you built in
21:21the array for a python language.
21:26Now creating of arrays in python, so this is a class array dot array then you are giving
21:31the type code your initializer, so this is an example here of how you basically you name
21:38an array ok, so this is the array name or you can say identifier, you are giving a module,
21:45you are giving a method and you are listing out the array list, so this is an example
21:51here.
21:52So identifier again specify a name like you usually do, module here you has a special
21:57module that is array you must use array, then you are specifying the method that is array
22:03module has a method for initializing the array that is d and type of code that is a type
22:09of data type data code which is available and the list of elements that are inside the
22:15square bracket.
22:18Now this is the type of code ok, you need to understand what type of elements you are
22:24listing out, so if you are using u you have a unicode character ok and the type and the
22:31minimum byte available size available, if you are using b it is for integer and it's
22:37called signed char, if you are using capital b it is unsigned char, if you are using h
22:43it is signed short, so this is the list ok for float you are using b, for float double
22:50floor just for float value using f, for i is for int that is signed integer value, so
22:57this is the type which you need to remember when you are listing it in an array.
23:04Now array access of array elements ok, so this is how you can access an array element
23:09you are using the syntax array name and the index number ok, so this is an example here
23:17that you have if you just run this you can find out how you can access an array ok, so
23:24just run this and you can find out the balance output of a, so for this also you have an
23:29identifier module method in the type of code and the element.
23:36Now last here is inserting of an element and how do you modify an element, so insertion
23:42of an element python array insert operation enables you to insert one or more items into
23:48an array at the beginning, end or at the even given any given index of an array ok,
23:55this method expects two arguments that is the index and the value, so you have the syntax
24:01here is array name dot insert you can have the index and the value, so this is an example
24:07here again of how you can insert an element.
24:12Now to modify this you use this syntax that is object name index and the value to be modified,
24:20so this is the basic of python array for you to understand, please run these codes generate
24:26your own program run it for your better understanding, with this we conclude the session thank you
24:32so much.