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)   ...

Python Program to calculate the factorial of number

 1)write a python Program to calculate the factorial of number?

Ans:

def factorial(a):

    f=1

    for i in range(1,a+1):

        f*=i                           # f=f*i

    return f

a=int(input("Enter the number: "))

print(factorial(a))




                                                                                            Or
import math
n=int(input("enter the number: "))
print("factorial of ",n, 'is', math.factorial(n))




                                          Thanks for Visiting...

Comments

Popular posts from this blog

Python Program to rotate the screen of your PC

Python Program for Calculator

program for Max of three number in Python