Thursday, May 6, 2021

String

 String (data type) : 

Strings are arrays of bytes representing Unicode characters.

》A string is a collection of one or more characters put in a single quote, double-quote or triple quote. In python there is no character data type, a character is a string of length one. 

It is represented by str class.

Example :-

1.var1 = 'Hello World!' .

2. var2 = 'RhinoPython' 

  •  print var1[0] # this will print the first character in the string an `H`

  • print var2[1:5] # this will print the substring 'hinoP`

Simple question for you :

Find output  for following code 

>>>String = 'Python programming'
>>>Print(string[3:7])
       
Options

1. Error
2. Python p
3. hon program
4.none

No comments:

Post a Comment

String

  String (data type) :  》 Strings are arrays of bytes representing Unicode characters. 》A string is a collection of one or more characters p...