Problem Set 6(Consogram)

Consogram

Consograms are words or sentences that has every consonant( letters other than a,e,i,o,u) of the English alphabet occurring at least once. Write an algorithm and a subsequent Python code to check whether a string is a consogram or not. Write a function to check if a given string is a consogram. For example,”"The quick brown fox jumps over the lazy dog"" is a consogram.

Input format

First line contains the string to be checked

Output Format

Print Consogram or Not consogram


Input:
The string

Processing:
def consogram(s):
    con_count = {}
    s = s.lower()
    s = ''.join(s.split())
    s = set(s) - set('aeiou')
    if len(s) == 21:
        print('Consogram')
    else:
        print('Not consogram')

Output:
display whether the given string is a consogram or not

Program:
def consogram(s):
    con_count = {}
    s = s.lower()
    s = ''.join(s.split())
    s = set(s) - set('aeiou')
    if len(s) == 21:
        print('Consogram')
    else:
        print('Not consogram')

s = input()
consogram(s)

Algorithm:
Step1. define the function consogram with one parameter s
Step1.1 assign con_count as an empty dictionary
Step1.2 convert all the letters of s into lower case and remove all the whitespace characters
Step1.3 check if the number of consonants in s is 21 if yes then display the string is a consogram else display not consogram
Step2. get the string and check whether it is a consogram or not using the consogram function
Step3. End


2 comments:

  1. Replies
    1. Python works with both single quote and double quotes. I have used a pair of single quote and you must have mistaken it for a double quote. Hope it helps

      Delete

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