an index operator

A.How to create a string using a constructor of the str class?

 

B. What is an index operator? How does it help in accessing characters? Give an example.

C.  Consider Str1, Str2, Str3, Str4 – the four different strings given as

Str1=“Welcome to Python Programming”

Str2 =”Welcome to Python Programming”

Str3=Str1

Str4=”to”

C. What are the results of the following expressions?

a. len(Str1)      e. Str1[5:10]

b. Str1[-7]       f. Str1.count(‘m’)

c. Str1[-3-1]        g. Str1[8].capitalize()

d. Str3==Str1 h. Str1+” “+Str1

D. Write a procedure to traverse every third character of a string.

Leave a Reply

Your email address will not be published.