0% found this document useful (0 votes)
3 views8 pages

String Programs

The document lists various string and list programs for Class XI Computer Science at The New Indian School in Bahrain. It includes tasks such as calculating string statistics, removing characters, checking for palindromes, counting words and vowels, and validating email domains. Each program is accompanied by sample outputs to illustrate expected results.

Uploaded by

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

String Programs

The document lists various string and list programs for Class XI Computer Science at The New Indian School in Bahrain. It includes tasks such as calculating string statistics, removing characters, checking for palindromes, counting words and vowels, and validating email domains. Each program is accompanied by sample outputs to illustrate expected results.

Uploaded by

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

THE NEW INDIAN SCHOOL W.L.L.

KINGDOM OF BAHRAIN
COMPUTER SCIENCE
LIST OF PROGRAMS ON STRING, LIST
CLASS : XI

String Programs:
1. Program that reads a line and prints its statistics like:
 Number of uppercase letters
 Number of lowercase letters
 Number of alphabets
 Number of symbols
 Number of digits

Sample Output:
Enter a line of text: I Love Python 3.1
Number of uppercase letters: 3

Page 1 of 8
Number of lowercase letters: 8
Number of alphabets: 11
Number of digits: 2
Number of symbols: 4
2. Write a program which takes two inputs one is a string and other is a character. The
function should create a new string after deleting all occurrences of the character from the
string and return the new string.

Sample Output:
Enter a string: I Love Python
Enter a character to remove: o
String after removing o , I Lve Pythn

3. Write a program that takes a string containing some digits as input and calculates the sum of

all digits present in the string.


Sample Output:
Enter a string with digits: nis@123
Sum of digits in the string: 6
4. Write a program that reads a string and then prints a string that capitalizes every other
letter in the string eg: passion becomes pAsSiOn

Sample output:
Enter a string: passion
pAsSiOn
Page 2 of 8
5. Write a program that reads a string and checks whether it is a palindrome string or not
without using string slicing.
Method: I

Text=’liril’
Method: II

Sample output:
Enter a string: liril
It is a palindrome.

6. Write a program that reads a string and checks whether it is a palindrome string or not by
using string slicing.

Page 3 of 8
Sample Output:
Enter a string: liril
The string is a palindrome.

7. Write a program that input a line of text and print its each word in a separate line also, print
the no. of words in a line.

Sample Output:
Enter a line of text: I Love Python
['I', 'Love', 'Python']
Words in the line:
I
Love
Python
Number of words in the line: 3
8. Write a program that input a line of text and print no. of spaces in a line.

line = input("Enter a line of text: ")


space_count = [Link](" ")
print("Number of spaces in the line:", space_count)
Sample Output:

Page 4 of 8
Enter a line of text: I Love Python
Number of spaces in the line: 2

9. Write a program that input a line of text and print no. of words which starts with “S”
Method: I

Sample Output:
Enter a line of text: She saw a cat sitting under the tree
Number of words starting with 'S': 1
Method : II

Sample Output:
Enter a line of text: She saw a cat sitting under the tree
Number of words starting with 'S': 3
10. Write a program that input a line of text and print no. of words which starts with vowels

Page 5 of 8
Sample Output:
Enter a line of text: She saw a cat sitting under the tree
Number of words starting with a vowel: 2

11. Write a program that input a line of text and print no. of vowels

Sample output:
Enter a line of text: She saw a cat sitting under the tree
Number of vowels: 11
12. Write a program to input a string and print each individual word of it along with its length.

Sample Output:
Enter a string: She saw a cat sitting under the tree
['She', 'saw', 'a', 'cat', 'sitting', 'under', 'the', 'tree']
She : 3
saw : 3
a:1
cat : 3
sitting : 7
under : 5
the : 3
tree : 4

Page 6 of 8
13. Write a program to input a string and check it contains digit or not.

Sample Output:
Enter a string: Python 3.0
The string contains a digit.
14. Write a program that reads email-id of a person in the form of a string and ensures that it
belongs to domain @[Link] (Assumption: No invalid characters are there in email-id)

Sample output:
Enter an email-id: cbsenews@[Link]
Valid: The email belongs to the @[Link] domain.

15. Write a program that inputs individual words of our school motto and joins them to make string.
It should also input day, month and year of our school’s foundation date and print the complete date.
(P 334)
Method: I

Method: II

Page 7 of 8
Sample Output:
Enter first word of the motto: In
Enter second word of the motto: Pursuit
Enter third word of the motto: of
Enter third word of the motto: Excellence
School Motto: In Pursuit of Excellence
Enter day of foundation: 08
Enter month of foundation: 05
Enter year of foundation: 1990
Foundation Date: 08/05/1990

Page 8 of 8

You might also like