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

Worksheet Strings in Python

The document is a worksheet focused on strings in Python, consisting of multiple-choice questions, very short questions, and programming tasks. It covers topics such as string methods, string manipulation, and practical programming exercises related to strings. The aim is to assess understanding and application of string concepts in Python.

Uploaded by

Abhipsita Sarkar
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)
26 views1 page

Worksheet Strings in Python

The document is a worksheet focused on strings in Python, consisting of multiple-choice questions, very short questions, and programming tasks. It covers topics such as string methods, string manipulation, and practical programming exercises related to strings. The aim is to assess understanding and application of string concepts in Python.

Uploaded by

Abhipsita Sarkar
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
You are on page 1/ 1

Worksheet: Strings in Python

Section A: MCQs (1 Mark Each)

1. What is the output of the following code? s = "Python" print(s[1:4])


a) Pyt b) yth c) tho d) ytho
2. Which of the following methods is used to remove any whitespace from the beginning or
the end of a string?
a) strip() b) split() c) replace() d) find()
3. What will be the output of the following code?
s = "hello"
print(s.upper())
a) HELLO b) hello c) error d) hELLO
4. Which of the following is not a valid string method in Python?
a) upper() b) reverse() c) split() d) join()
5. What is the result of the following expression?
"Python" * 2
a) Python2 b) Python Python c) PythonPython d) Error

Section B: Very Short Questions (2 Marks Each)

1. What is a string in Python?


2. How can you access the last character of a string?
3. Explain the use of the find() method.
4. What does the split() method do in a string?
5. What is string slicing in Python? Give an example.

Section C: Programming Questions (3 Marks Each)

1. Write a Python program to check if a string is a palindrome.


2. Write a Python program to count the number of vowels in a given string.
3. Write a Python program to reverse a given string.
4. Write a Python program to replace all spaces in a string with an underscore (_).
5. Write a Python program to find the length of a string without using the len() function.

You might also like