0% found this document useful (0 votes)
231 views3 pages

Exercise Questions-String 231001 212451

This document contains exercise questions on strings in Python. It includes single mark, two mark, three mark, and four mark questions. The questions cover string operations like indexing, slicing, concatenation, checking for substrings and characters, string manipulation functions, string patterns and more. Students are expected to attempt these questions to assess their understanding of strings in Python.

Uploaded by

najiyashirin7
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)
231 views3 pages

Exercise Questions-String 231001 212451

This document contains exercise questions on strings in Python. It includes single mark, two mark, three mark, and four mark questions. The questions cover string operations like indexing, slicing, concatenation, checking for substrings and characters, string manipulation functions, string patterns and more. Students are expected to attempt these questions to assess their understanding of strings in Python.

Uploaded by

najiyashirin7
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/ 3

Exercise Questions: String

1 Mark Questions
Q.No Question
1. print the string “India” 10 times.
2. What is the output of the following code
>>>‘a’ in “computer”
3. What is the output of the following code
Strg=”computer”
print(Strg[ 0: 8 : 2]
4. What is the output of the following? print('INDIA'.capitalize())

5. Which of the following is not valid string in Python?

(i) “Hello” (ii) ‘Hello’


(iii) “Hello’ (iv) None of the above
6. Suppose word = ‘amazing’, the what will
be word[: : -2]?

2 Mark Questions
Sr. Question
1. If you give the following for str1=”Hello” why does python report error
str1[2]=’p’
2. Identify the output of the following Python statements.
x="Vidyalaya"
y="Vidya"
if(y in x):
print(y)

3. Look at the code sequence and select the correct output


str="KVS RO Jaipur"
for i in str:
if(i.isupper()==True):
print(i.lower(),end="")
if(i.islower()==True):
print(i.upper(), end="")

4. Find the correct output of the following


>>>str="The planet earth looks like a blue marble from outer space"
>>>print(str.find('marble',50))

5. Find the value stored in ctr at the end of this code snippet:
mystr="Darjeeling Tea has a strong flavour"
ctr=0
for i in mystr:
if i in 'aeiouAEIOU':
ctr += 1
print(ctr)
3 Mark Questions
Sr. Question
1. Write a Python program to input a line of text and a character from user to print the
frequency of the character in the line. For example
Line entered is : this is a golden pen The character to search : e
Then output is : Frequency is 2
2. Write a Python Program to input a string to check whether it is a Palindrome string
or not. (A Palindrome string is that which is same from both ends like – NITIN,
MALAYALAM, PULLUP)

3. Using string replication techniques print the following pattern using any loop.
Hello Hello Hello
Hello Hello Hello

4 Mark Questions
Sr. Question
1. Find Output:
my_string = 'Jhunjhunu'
print(my_string[:3])
for i in range(len(my_string)):
print(my_string[i].upper(),end="@")
print()
print (my_string)
print (my_string[3:6])
2. Consider the following string mySubject: mySubject = "Computer Science"
What will be the output of the following string operations :
print(mySubject[0:len(mySubject)])
print(mySubject[-7:-1])
print(mySubject[::2])
print(mySubject[len(mySubject)-1])
print(2*mySubject)
print(mySubject[::-2])
3. Consider the following string country: country= "Great India"
What will be the output of the following string operations(Any Four):-
a) print(country[0:len(country)])
b) print(country[-7:-1])
c) print(country[::2])
d) print(country[len(country)-1])
e) print(2*country)
f) print(country[:3] + country[3:])

You might also like