String Manipulation || Type A || Sumita Arora || Class 11 || Computer science || Information practices || Solution


Note :- Please click on question to get answer of that Question.


Q1 = Write a Python script that traverses through an input string and prints its characters in different lines- two characters per line..

 

 

Q2 = Out of the following operators, which ones can be used with strings? =,-,*,/,//, %, > , < >, in, not in,<=
 

 

Q 3. What is the result of following statement , if  the input is  ‘Fun’ print ( input("…" + "trial" + "Ooty" *3)
 

 

Q4. Which of the following is not a Python legal string operation? (a) 'abc’+'abc’ (b) 'abc' *3 (c) 'abc'+3 (d) 'abc’.lower () 

 

 

Q5. Can you say strings are character lists? Why? Why not?

 

Q6. Given a string S = "CARPE DIEM", If n is length/2 (length is the length of the given string),then what would following return ? 

(a)S[:n]     (b)S[n:]      (c)S[n:n]      (d)S[1:n]      (e)S[n:length-1]

 

Q7. From the string S = "CARPE DIEM", which ranges return "DIE" and "CAR"? .


 

Q8. What happens when from a string slice you skip the start and/or end values of the slice?

 

Q9. What would following expression return?

(a)"Hello World".upper().lower()     

(b) "Hello World".lower().upper()    

(c) "Hello World".find( "Wor", 1, 6)       

(d) "Hello World".find( "Wor")         

(e) "Hello World".find( “wor”)         

(f) "Hello World".isalpha()         

(g) "Hello World".isalnum()           

(h) "1234".isdigit()(i) "123FGH".isdigit()

 

 

Q10. Which functions would you choose to use to remove leading and trailing white spaces from a given string?

 

 

Q11. Try to find out if for any case, the string functions isalnum() and isalpha( ) return the same result.

 

 

Q12. Suggest appropriate functions for the following tasks:        

(i)To check whether the string contains digits       

(ii)To find for the occurrence a string within another string       

(iii)To convert the first letter of a string to upper case        

(iv) to capitalize all the letters of the string            

(v) to check whether all letters of the string are in capital letters                     

(vi) to remove from right of a string all string- combinations from a given set of letters  

 (vii) to remove all white spaces from the beginning of a string



Q13. In a string slice, the start and end values can be beyond limits. Why?



Q14. Can you specify an out of bound index when accessing a single character from a string? Why?



Q15. Can you add two strings? What effect does '+' have on strings?

2 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post