0% found this document useful (0 votes)
21 views4 pages

String Practise

Uploaded by

samirafrid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views4 pages

String Practise

Uploaded by

samirafrid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Assignment on Strings

Problem 1: Awesh's Phonetic Analyzer


Awesh is developing a phonetic analyzer to determine the ratio of
vowels to consonants in English text. He wants to analyze a string
and count the number of vowels and consonants to understand
the phonetic structure of a given text. Your task is to help him by
creating a function that takes a string and returns the counts of
vowels and consonants.

Problem Statement

Given a string, write a function that counts the number of vowels


and consonants. Consider vowels as 'a', 'e', 'i', 'o', 'u' (both
uppercase and lowercase), and consonants as any other
alphabetic characters. Return the counts of vowels and
consonants as a tuple.

Input

A single string text.

Output

A tuple (vowels, consonants), where vowels is the count of


vowels and consonants is the count of consonants in the given
text

Input Output
"Hello, World!" (3, 7)
"Vowel Consonant Finder" (6,13)
“Python Programming” (3,13)
“Counting vowels and consonants" (8, 17)

1 Programming Course Batch Recursion


Problem 2: Awesh's Anagram Challenge
Awesh is playing a word game that involves creating anagrams.
An anagram is a rearrangement of the letters of a word to form
another word or phrase, typically using all the original letters
exactly once. Awesh wants to know if two given strings are
anagrams of each other.

Problem Statement

Given two strings, determine if they are anagrams of each other.


Two strings are anagrams if they contain the same characters
with the same frequency, regardless of the order.

Input Output
"listen", "silent" True
"triangle", "integral" True
"hello", "world" FALSE
"cinema", "iceman" True

Problem 3: Awesh's Email Validator


Awesh is working on a contact management system, and he
needs a way to validate email addresses. An email address is
considered valid if it has exactly one '@' symbol, a domain with at
least one '.', and contains no spaces. Awesh asks you to write a

2 Programming Course Batch Recursion


function that checks if a given email address is valid based on
these criteria.

Problem Statement

Given a string representing an email address, write a function to


determine if it is valid. A valid email address must:

1) Contain exactly one '@' symbol.

2) Have a domain with at least one '.' following the '@'.

3) Contain no spaces.

Input Output
[email protected] TRUE
example@com FALSE
invalid@ example.com FALSE
user@[email protected] FALSE

Problem 4: Awesh's Secret Message Decryption


Awesh has received an encrypted message from his friend, but he
doesn't know the shift used for encryption. The message needs to
be decrypted to understand its content. He asks you to create a
function that can decrypt an encrypted message that was
encrypted using the Caesar cipher.

Problem Statement

Given an encrypted message cipher_text, write a function to


decrypt the message using a Caesar cipher. The function should
determine the shift used for encryption and decrypt the message.

3 Programming Course Batch Recursion


The decrypted message should be in its original form before
encryption.

Input Output
Fuxlwbwlrq Vxffhvvixo Find Yourself
Lqrfn ph li brx vroyhg wklv zlwk vroxwlrq Find Yourself

Iluvwb Vrpyhu zloo uhfhlyh d sulch Find Yourself


Kdssb frglqj Find Yourself

4 Programming Course Batch Recursion

You might also like