Here is a python program for checking whether a string is a Pangram or not. A pangram is a sentence that includes all the alphabets in the English language. This means that string must have all the alphabets in the English language. Let us take a popular example of Pangram " The quick brown fox jumps over a lazy dog" It has all the alphabets in the English language.
Now let us check how that is implemented in this python language. After accepting the user's string, we have to import all the ASCII values of the alphabets and save that to a variable. We call a function to check the pangram. Inside the function, we subtract the total letters in the alphabets and the set of letters in the string, which is converted to lower case and check the result is zero, then its a pangram, else it's not a pangram.
STEP 1: Import the ASCII values of all lower case letters and store them in a variable in python language.
STEP 2: Accept the string from the user using the input method in a python programming language.
STEP 3: Call the function inside an
if condition and check the return value from the function and if that is true or zero.
STEP 4: Print the string is a pangram
else not pangram using print statement in python programming
STEP 1: Accept the string as a parameter to the function to check the pangram or not.
STEP 2: Calculate the difference between the lower case ASCII values of the total alphabets and the ASCII values of lower case letters of the string and return the result to the calling function.
from string import ascii_lowercase as asc_lower def check(s): return set(asc_lower) - set(s.lower()) == set() string=input("Enter string:") if(check(string)==True): print("The string is a pangram") else: print("The string isn't a pangram")
Enter string:The quick brown fox jumps over the lazy dog The string is a pangram