This python tutorial for beginners explains how to use the counter module from collections in python. The video shows how to create a counter to count the amount of characters in a python list, tuple and string. The counter module is one of several modules available from collections and this video is the first in which we focus solely on the counter module and its available methods.
In python we can create a counter object using the counter module and this counts the elements in the string, list or tuple. The first method that is explained in the most common method that takes as an argument the amount of most common elements, so for example, the user can enter 3 and this module would provide the top 3 most common elements. Some users may prefer to use a python dictionary and it is quite simple to convert the counter object to a dictionary.
The update method is self-explanatory, it can be used to add elements or even to add a second counter to the first. In an example in the video the update method adds the counts from a secondary counter to the original counter. This produces the same result as adding the two counters in the arithmetic operation to add. Other arithmetic operations that can be performed on the counter object are subtraction, intersection and union.
There is an example of how to use the counter elements option. This provides an iterable object such that the user can loop over each element. In the video you can see the use of the set operation with elements to provide each element and its count. Finally, there is an example from the web that uses a counter of characters from a file, update and most common. This provides, as you would suspect, the most common characters in the file.
0:00 video start
0:31 counter
2:05 most common
3:23 elements
4:40 counter to dictionary
5:03 update
6:07 arithmetic operations
7:28 counting file content
8:43 practice exercises
9:37 practice solutions
[ Ссылка ]
drcodie@gmail.com
#pythonfundamentals #pythontutorials #pythontutorialsforbeginners
PYTHON PLAYLISTS ON YOUTUBE:
Python Coder – Beginner
[ Ссылка ]
Python Fun & Games
[ Ссылка ]
More Simple Python Tutorials
[ Ссылка ]
Simple Python
[ Ссылка ]
Python Regular Expressions
[ Ссылка ]
WHY LEARN CODING WITH DR CODIE:
If you want to know how to learn python then these python programming tutorials are for you. Hi, my name is Dr Codie and I have helped many students to learn python, Scratch, SQL and other programming languages. In these videos you see how to learn python using your existing knowledge and gain some tips for learning python. Codie means ‘helpful person’ and we want to help you not just learn python programming but to enjoy learning python. We start with python tutorials for beginners and then move to tutorials for more advanced learning. The videos teach python 3.
In my experience, success being a python coder comes down to getting the fundamentals right. You can then move onto advanced programming concepts and skills. You will understand how to do simple coding tasks and then we will show you the simple methods of putting lines or blocks of code together using this knowledge. Practice is essential for your skills to grow but again do not fear we will help you practice as well.
Learn to understand the logic and design aspects needed to become a good programmer, let us help you practice to keep improving and don’t forget the bonus of seeing first hand how to build the code and possible stumbling blocks when we explain the answers to the tasks set within the tutorial. You do not need to watch the whole video but if you do you will improve as a python coder!
SOCIAL MEDIA
Pinterest: [ Ссылка ]
Twitter: [ Ссылка ]
Instagram: [ Ссылка ]
Linkedin: [ Ссылка ]
YouTube Channel: [ Ссылка ]
SUBSCRIBE and you will know when the videos are available! Good luck!
More Simple Python Tutorials [ Ссылка ]
List Comprehensions [ Ссылка ]
Python Enumerate [ Ссылка ]
Python Zip [ Ссылка ]
Sets [ Ссылка ]
Tuples [ Ссылка ]
Range [ Ссылка ]
Iteration [ Ссылка ]
Time [ Ссылка ]
Args kwargs [ Ссылка ]
Ещё видео!