Problem Set 6(Pengram)

Pengrams are words or sentences containing every letter of the English alphabet at the most once. Write an algorithm and a subsequent Python code to check whether a string is a pengram or not. Write a function to check if a given string is a pengram. For example, "He is at work" is a pengram. Since every letter of the english alphabet occurs at the most once

Input format

First line contains the string to be checked

Output Format

Print Pengram or Not pengram


Input:
the string

Processing:
def pengram(s):
    s = ''.join(s.split())
    s = s.lower()
    if len(s) == len(set(s)):
        print('Pengram')
    else:
        print('Not pengram')

Output:
Display if the number is a pengram or not

Program:
def pengram(s):
    s = ''.join(s.split())
    s = s.lower()
    if len(s) == len(set(s)):
        print('Pengram')
    else:
        print('Not pengram')
s = input().rstrip()
pengram(s)

Algorithm:
Step1. define the function pengram 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 pengram else display not pengram
Step2. get the string s
Step3. call the function pengram with s as the actual parameter to check whether its a pengram 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...