StudenteCare mission is to give people the power to build educational community and bring the Educators, Students, Parents, Consultant, University, Colleges, Schools and Coachings closer together
Ncert Solution | Ncert Solution for class 11th | Ncert Solutions for class 11 Computer Science Python | NCERT COMPUTER SCIENCE PYTHON CHAPTER 12 STRINGS
by   Pooja Singla
Files Overall Price:    0.00
Videos Overall Price:    0.00
Total Overall Price:    0
Sold By:    Pooja Singla

Description Above File

NCERT Solutions for Class 11 Computer Science (Python) Chapter 12 Strings

Ncert solutions for class 11 Computer Science Python Chapter 12 Strings are prepared by CBSE student eCARE expert to score good marks in class 11. Classes 11 Computer Science Python Chapter 12 Strings contain many topics which are very important to score good in class 11. There are some important topic mentioned below:

Traversing a string means accessing all the elements of the string one after the other by using the subscript. A string can be traversed using for loop or while loop.

Strings are immutable means that the contents of string cannot be chrnged after it is created.
For example :
>>> str = ‘Meney’
>>> str [3] = ‘h’
Type Error : ‘str’ object not support item assignment Python does not allow to change a character in a string. So an attempt to replace ‘e’ in the string by ‘h’ displays a Type Error.

Write a program that reads email id of a person in the form of a string and ensures that it belongs to domain
email = raw_input (“Enter email ID :”)
domain = “”
lendo = len(domain)
lenm = len(email)
sub = email [lenm – lendo:]
if sub = = domain :
if lendo ! = lenm :
print “It is a valid email ID”
else :
print “It is an invalid email ID”
else :
print “It’s domain is different”

Description Below File

Some questions are asked by class 11 students related to Computer Science (Python)

Question 1:
What do you mean by string in Python ?
Strings are amongst the most popular types in Python. We can create them simply by characters in quotes. Python treats single quotes the same as double quotes.
Creating strings is as simple as assigning a value to a variable. For example :
var1 = ‘Waltons Technology!’
var2 = “Python Programming”

Question 2:
What is indexing in context to Python strings ? J Why is it also called two-way indexing ?
In Python strings, each individual character is ! given a location number, called “index” and this process is called “indexing”. Python allocates indices in two directions :

  1. in forward direction, the indexes are numbered as 0,1, 2,    length-1.
  2. in backward direction, the indexes are numbered as -1, -2, -3,…. length.
    This is known as “two-way indexing”.

Question 3:
What is a string slice ? How is it useful ?
A sub-part or a slice of a string, say s, can be obtained using s[n : m] where n and m are integers. Python returns all the characters at indices n, n+1, n+2,…. m-1.
For example,
‘Oswaal Books’ [1 : 4] will give ‘swa’

Question 4:
How you can “update” an existing string ?
You can “update” an existing string by (re) assigning a variable to another string.
The new value can be related to its previous value or to a completely different string altogether.
Following is a simple example :
# !/usr/bin/python
var1 = ‘Hello World!’
print”Updated String:-“,var i[:6] + ‘Python’

Question 5:
Describe Triple Quotes in Python.
Python’s triple quotes comes to the rescue by allowing strings to span multiple lines, including verbatim NEWLINEs, TABs, and any other special characters. The syntax for triple quotes consists of three consecutive single or double quotes.
# !/usr/bin/py thon
para str = “””this is a long string that is made up of several lines and non-printable characters such as
TAB ( \t ) and they will show up that way when displayed.
NEWLINEs within the string, whether explicitly given like this within the brackets [ \n ], or just a NEWLINE within the variable assignment will also show up.
” ” ”
print para_str;

Question 6:
Define raw string with example.
Raw strings don’t treat the backslash as a special character at all. Every character you put into a raw string stays in the way you wrote it :
# !/usr/bin/python
print ‘C:\\nowhere’
When the above code is executed, it produces the following result :
Now let’s make use of raw string. We would put expression in r’expression’ as follows :
# !/usr/bin/python
print r’C:\\nowhere’
When the above code is executed, it produces the following result :

Question 7:
Explain Unicode String with example.
Normal strings in Python are stored internally as 8-bit ASCII, while Unicode strings are stored as 16- bit Unicode. This allows for a more varied set of characters, including special characters from most languages in the world.
print u’Hello, world!’

Question 8:
Describe isdecimal( ) with example.
The method isdecimal( ) checks whether the string consists of only decimal characters. This method is present only on Unicode objects.
Note : To define a string as Unicode, one simply prefixes a ‘u’ to the opening quotation mark of the assignment.
Below is the example.
Syntax :
Following is the syntax for isdecimal( ) method :
str.isdecimal( )

Question 9:
Explain zfill (width) with Syntax and Return Value
The method zfill( ) pads string on the left with zeros to fill width.
Syntax : str.zfill(width)
Parameters: This is final width of the string. This is the width which we would get after filling zeros. Return Value: This method returns padded string

Question 10:
Write the output of the following code
# !/usr/bin/python
str = “this is string example….wow!!!”;
print str.zfill(40);
print str.zfill(50);
On compiling and running the above program, this will produce the following result :
OOOOOOOOthis is string example….wow!!! 000000000000000000this is string example…. wow!!!