Monday, April 20, 2020

pie chart in seaborn library using python

import pandas as pd

# --- dataset 2: 3 columns and rownames
df = pd.DataFrame({'var1':[8,3,4,2], 'var2':[1,3,4,1]}, index=['a', 'b', 'c', 'd'] )

# make the multiple plot
df.plot(kind='pie', subplots=True, figsize=(16,8))




import pandas as pd
 
# --- dataset 2: 3 columns and rownames
df = pd.DataFrame({'var1':[8,3,4,2], 'var2':[1,3,4,1]}, index=['a', 'b', 'c', 'd'] )
 
# make the multiple plot
df.plot(kind='pie', subplots=True, figsize=(16,8))
Out[3]:
array([<matplotlib.axes._subplots.AxesSubplot object at 0x000001BBCAB27408>,
       <matplotlib.axes._subplots.AxesSubplot object at 0x000001BBCAB5E1C8>],
      dtype=object)
In [7]:
import pandas as pd
 
# --- dataset 2: 3 columns and rownames
df = pd.DataFrame({'var1':[4,4,4,4], 'var2':[1,3,4,1]}, index=['a', 'b', 'c', 'd'] )
 
# make the multiple plot
df.plot(kind='pie', subplots=True, figsize=(16,8))
Out[7]:
array([<matplotlib.axes._subplots.AxesSubplot object at 0x000001BBCB0BA6C8>,
       <matplotlib.axes._subplots.AxesSubplot object at 0x000001BBCB0E8F88>],
      dtype=object)
In [8]:
import pandas as pd
 
# --- dataset 2: 3 columns and rownames
df = pd.DataFrame({'var1':[4,4,4,4], 'var2':[1,3,4,1]}, index=['a', 'b', 'c', 'd'] )
 
# make the multiple plot
df.plot(kind='pie', subplots=True, figsize=(10,8))
Out[8]:
array([<matplotlib.axes._subplots.AxesSubplot object at 0x000001BBCB17E4C8>,
       <matplotlib.axes._subplots.AxesSubplot object at 0x000001BBCB315788>],
      dtype=object)
In [9]:
import pandas as pd
 
# --- dataset 2: 3 columns and rownames
df = pd.DataFrame({'var1':[4,4,4,4], 'var2':[2,3,4,1]}, index=['a', 'b', 'c', 'd'] )
 
# make the multiple plot
df.plot(kind='pie', subplots=True, figsize=(10,8))
Out[9]:
array([<matplotlib.axes._subplots.AxesSubplot object at 0x000001BBCB554DC8>,
       <matplotlib.axes._subplots.AxesSubplot object at 0x000001BBCB57DC88>],
      dtype=object)
In [ ]:
 

Friday, April 17, 2020

write a program to count lower and upper case letter in python

string=input("Enter string:")
count1=0
count2=0
for i in string:
      if(i.islower()):
            count1=count1+1
      elif(i.isupper()):
            count2=count2+1
print("The number of lowercase characters is:")
print(count1)
print("The number of uppercase characters is:")
print(count2)

output:
Enter string:this is anil kumar
The number of lowercase characters is:
15
The number of uppercase characters is:
0

capitalize each word in python

# Complete the solve function below.
def solve(s):
    if len(s)>0 and len(s)<1000:
        capital_words = s.title()       
        return capital_words

if __name__ == '__main__':
    fptr = open(os.environ['OUTPUT_PATH'], 'w')

    s = input()

    result = solve(s)

    fptr.write(result + '\n')

    fptr.close()

output:
hello world
Hello World

LISP helloworld program

(write-line "Hello World")
(write-line "this is my first program")

output:
$clisp main.lisp
Hello World
this is my first program

python class topic video