Professional Documents
Culture Documents
Akhilesh AP 2.3
Akhilesh AP 2.3
AIM:
String Algorithms: Demonstrate the concept of string
Problem 1
Objective:
A pangram is a string that contains every letter of the alphabet. Given a sentence determine
whether it is a pangram in the English alphabet. Ignore case. Return either pangram or not
pangram as appropriate.
Code
def pangrams(s):
letter_set = set()
for char in s:
char = char.lower()
if char.isalpha():
letter_set.add(char)
if len(letter_set) == 26:
return "pangram"
return "not pangram"
user_input = input()
result = pangrams(user_input)
print(result)
Problem 2
Objective:
There is a sequence of words in CamelCase as a string of letters, s, having the following
properties:
It is a concatenation of one or more words consisting of English letters.
All letters in the first word are lowercase.
For each of the subsequent words, the first letter is uppercase and the rest of the
letters are lowercase.
Given s, determine the number of words in s.
Code:
#include <bits/stdc++.h>
#include <string>
int main() {
string s;
cin >> s;
int result = camelcase(s);
cout << result << endl;
return 0;
}
Output:
Learning Outcomes:
The learning outcomes from this coding exercise involving string algorithms include:
Practiced different algorithms to work with strings like Pangram and CamelCase.
Solved Problems related to these algorithms.