[go: up one dir, main page]

0% found this document useful (0 votes)
20 views2 pages

Assignment CS GR XI - String 2

The document is a fortnightly assignment for Grade XI Computer Science at Modern School, Vasant Vihar, due on October 30, 2024. It includes various Python programming tasks such as manipulating strings, counting substrings, and formatting text. The assignment aims to enhance students' programming skills through practical exercises.

Uploaded by

jeetrc2008
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)
20 views2 pages

Assignment CS GR XI - String 2

The document is a fortnightly assignment for Grade XI Computer Science at Modern School, Vasant Vihar, due on October 30, 2024. It includes various Python programming tasks such as manipulating strings, counting substrings, and formatting text. The assignment aims to enhance students' programming skills through practical exercises.

Uploaded by

jeetrc2008
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
You are on page 1/ 2

Modern School, Vasant Vihar

Fortnightly Assignment

Grade: Gr XI Chapter: String

Subject: Computer Science Date of Submission: Oct 30, 2024

1. Write a Python program to get a string made of the first 2 and the last 2 chars from a given a string. If the string
length is less than 2, return instead of the empty string.
Sample String: 'w3resource'
Expected Result: 'w3ce'
Sample String: 'w3'
Expected Result: 'w3w3'
Sample String: ' w'
Expected Result: Empty String
2. Write a Python program to get a single string from two given strings, separated by a space and swap the first
two characters of each string.
Sample String : 'abc', 'xyz'
Expected Result : 'xyc abz'
3. Write a Python function that takes as parameter to swap each character of a given string from lowercase to
uppercase and vice versa.
4. Write a Python program to count occurrences of a substring in a string.
5. Write a Python program to count and display the vowels of a given text.

6. Write a Python program to capitalize first and last letters of each word of a given string.

7. Write a program to convert a string with more than one word into title case string where string is passed as
parameter. (Title case means that the first letter of each word is capitalized.)

8. Write a program to generate the following pattern using String “Hello” & “World”:

Hell W H
o Wo ee
Hell Wor lll
Hel Worl llll
He World ooooo
H

9.Write a program in python that counts the number of individual words ‘to’ or ‘the’ (including upper and
lower cases) present in a multiline string.

For example: If the content of the string is


‘’’All goes to the temple
The train reached to Delhi
The journey to goa
The function should display’’’
Output should be -

Page 1 of 2
Count of to/the in string :6

Page 2 of 2

You might also like