0% found this document useful (0 votes)
3 views1 page

String - Worksheet

The document outlines four programming tasks involving string manipulation in Python. The tasks include counting word frequency in a sentence, generating acronyms, counting vowels with case distinction, and identifying consecutive characters in a string. Each task requires specific functionality to handle string inputs and outputs.
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)
3 views1 page

String - Worksheet

The document outlines four programming tasks involving string manipulation in Python. The tasks include counting word frequency in a sentence, generating acronyms, counting vowels with case distinction, and identifying consecutive characters in a string. Each task requires specific functionality to handle string inputs and outputs.
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

Worksheet - String

1. Accept a sentence ‘S’ and a word ‘W’ from the user. Write a program that
determines how frequently W appears in S. The program should treat all
occurrences of the word equally, regardless of their case.
e.g. in the sentence 'The quick brown fox jumps over the lazy dog because the dog
was too lazy,' the word 'the' appears 3 times.

2. Create a Python script that generates an acronym from a given string. For
example, "North Atlantic Treaty Organization" should return "NATO".
3. Write a program that counts the number of vowels in a given string. The output
should distinguish between lowercase and uppercase vowels.
4. Write a Python program that scans a string and prints out all characters that
appear consecutively more than once. For example, given the string
"mississippi", the output should be "ssp" because the characters 's' and 'p'
appear consecutively more than once. Ensure the program preserves the order
and frequency of characters as they appear in the input string.

You might also like