Python program to count total number of vowel,consonant,lowercase,uppercase

Image
Q)Python program to count total no vowel,consonant,lowercase,uppercase. Ans: def ayush(str):     vowels = 0     consonant = 0     lower = 0     upper= 0     for i in range(0, len(str)):          ch = str[i]          if ch.isupper():         upper+=1         elif ch.islower():         lower+=1         if ( (ch >= 'a' and ch <= 'z') or (ch >= 'A' and ch <= 'Z') ):          ch = ch.lower()         if (ch == 'a' or ch == 'e' or ch == 'i' or ch == 'o' or ch == 'u'):         vowels += 1         else:         consonant += 1         else:         pass     print("Vowels:", vowels)     print("Consonant:", consonant)     print("lowercase:", lower)     print("uppercase:", upper)  str=input('enter the string:') ayush(str) Output:

Python Program for Stack

 1) Write Python Program for simple Stack operation ? 

Ans:

#Program for Stack

import sys

s=[]

def push():

     a=int(input("enter the num:"))

     s.append(a)

     print("\nPush Operation successfully")

def pop():

     if s==[]:

          print("stack is empty:")

     else:

          print("Poped values is",s.pop())

def display():

     if s==[]:

          print("Stack is empty!")

     else:

          print("your entered stack is ",s)

while True:

     print('\n1:Push()\n2:pop()\n3:display()\n4:Exit\n')

     ch=int(input("Enter ur choice:"))

     if ch==1:

          push()

     elif ch==2:

          pop()

     elif ch==3:

          display()

     elif ch==4:

          sys.exit()

     else:

          print("u made a wrong choice:")


    


       THANKS FOR VISITING...


Comments

Popular posts from this blog

Python Program to rotate the screen of your PC

Python program to reverse a string

Python program to read a text file and display a no of vowels, consonant, uppercase, lowercase character in file