Thursday, 17 February 2022

Collections Library in Python



#!/usr/bin/env python
# coding: utf-8

# In[9]:


import collections


# In[10]:


counter=collections.Counter([1,1,2,2,3,3,3,3,4,5,6,7])


# In[11]:


counter


# In[12]:


counter.most_common(1)


# In[13]:


counter.most_common(2)


# In[14]:


counter.most_common(3)


# In[15]:


counter=collections.Counter("clcoding")


# In[16]:


counter


# In[18]:


counter["c"]


# In[19]:


counter.most_common(1)


# In[20]:


counter.most_common(2)


# In[21]:


counter=collections.Counter("ntirawen")


# In[22]:


counter


# In[23]:


counter2=collections.Counter("ntirawen")


# In[24]:


counter2


# In[25]:


counter3=collections.Counter("irawen")


# In[26]:


counter3


# In[27]:


counter2.subtract(counter3)


# In[28]:


counter2


# In[ ]:




0 Comments:

Post a Comment

Codecademy Code Foundations

Popular Posts

Categories

Android (23) AngularJS (1) Assembly Language (2) Books (10) C (75) C# (12) C++ (81) Course (1) Data Strucures (4) Downloads (1) Engineering (13) flutter (1) FPL (17) Hadoop (1) HTML&CSS (38) IS (25) Java (89) Leet Code (4) Pandas (1) PHP (20) Projects (17) Python (319) R (69) Selenium Webdriver (2) Software (14) SQL (27)