Problem Set 6(Pangram)

Pangrams are words or sentences containing every letter of the English alphabet at least once. Write an algorithm and a subsequent Python code to check whether a string is a pangram or not. Write a function to check if a given string is pangram. For example, “The quick brown fox jumps over the lazy dog” is a panagram.

Input format
First line contains the string to be checked

Output Format
Print Pangram or Not pangram

Input:
the string

Processing:
def Pangram(s):
    s = ''.join(s.split())
    s = s.lower()
    if len(set(s))>= 26:
        print('Pangram')
    else:
        print('Not pangram')

Output:
Display if the number is a Pangram or not

Program:
def Pangram(s):
    s = ''.join(s.split())
    s = s.lower()
    if len(set(s))>=26:
        print('Pangram')
    else:
        print('Not pangram')
s = input().rstrip()
Pangram(s)

Algorithm:
Step1. define the function Pangram with one parameter s
Step1.1 remove all the whitespace characters in the string and join the words.
Step1.2 convert all the letters to lowercase to make the string case insensitive
Step1.3 check if length of the string s is equal to all the unique letters in the string s if yes then display the string is a Pangram else display not Pangram
Step2. get the string s
Step3. call the function Pangram with s as the actual parameter to check whether its a Pangram or not
Step4. End

No comments:

Post a Comment

Bonus Practice Problems(GMT To IST)

IST (Indian Standard Time) is 5 hours 30 minutes ahead of GMT(Greenwich Mean Time). Develop an algorithm and write the Python code to find...