Tushar AP 5.
Tushar AP 5.
Experiment 5(A)
Student Name: Tushar Singh UID: 22BCS15923
Branch: CSE Section/Group: 622/B
Semester: 5 Date of Performance: 3/09/24
Subject Name: Advanced Programming Lab-1 Subject Code: 22CSP-314
1. Title: Pangrams
2. Aim: 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 program as appropriate
3. Objective:
Complete the function pangrams in the editor below. It should return the string
pangram if the input string is a pangram. Otherwise, it should return not
pangram.pangrams has the following parameter(s):
string s: a string to test
It returns either pangram or not pangram
4. Algorithm:
Input: A String.
Compare Sets: Check if the set of lowercase letters is subset of the character in the input
string.
Output: If all alphabet letters are present, return “pangram”; otherwise, return “not
pangram”.
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
5. Implementation/Code
import math
import os
import random
import re
import sys
def pangrams(s):
s = s.lower()
alphabet_set = set('abcdefghijklmnopqrstuvwxyz')
s_set = set(s)
if alphabet_set <= s_set:
return "pangram"
else:
return "not pangram"
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
s = input()
result = pangrams(s)
fptr.write(result + '\n')
fptr.close()
6. Output:
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
7. Learning Outcomes:
Experiment 5(B)
Student Name: Tushar Singh UID: 22BCS15923
Branch: CSE Section/Group: 622/B
Semester: 5 Date of Performance:03/09/24
Subject Name: Advanced Programming Lab-1 Subject Code: 22CSP-314
2. Aim: You have to print the number of times that the substring occurs in the given
string. String traversal will take place from left to right, not from right to left.
NOTE: String letters are case-sensitive.
Input Format: The first line of input contains the original string. The next
line contains the substring.
3. Objective:
In this challenge, the user enters a string and a substring. You have to print
the number of times that the substring occurs in the given string. String
traversal will take place from left to right, not from right to left.
4. Algorithm:
Iterate through the string up to the point where there’s still enough space
left to check for the substring.
if __name__ == '__main__':
string = input().strip()
sub_string = input().strip()
count =
count_substring(string,
sub_string)
print(count)
6. Output:
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
7. Learning Outcomes: