- Home
- Course Detail
regularpython@gmail.com
You are now watching:
Python Strings / of Python String Basic Examples
# Strings name = 'Tutorialstution' print(name) name = "Tutorialstution" print(name) name = '''Tutorialstution''' print(name) # ******************************************************************** # # what is the difference between ' and " why we need thhis # 0123456789 name = 'regularpython' print('result = ',name[:-6]) print(name) name = "mother\'s \"day\"" print(name) name = '''There are many variations of passages of Lorem Ipsum available,but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn\'t anything embarrassing hidden in themiddle of text. All the Lorem Ipsum generators''' name = ''' There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators gvuikhl nlinnkml njnnkm'kbkjb"bjbjnj ''' print(name) # ******************************************************************** # # + :Concatenation - Adds values on either side of the operator name = 6+'tutorials' print(name) # ******************************************************************** # # * : Repetition - Creates new strings, concatenating multiple copies of the same string name = 3*'sai' print(name) # ******************************************************************** # # [] : Slice - Gives the character from the given index name = 'tutorialstution.com' print(name[:]) print(name[3:]) print(name[::-1]) # ******************************************************************** # # In : Membership - Returns true if a character exists in the given string name = 'tutorialstution.com' if 'tutorial' not in name: print('name found') else: print('name not found') name = 'tutorialstution.com' if 'web' not in name: print('name not found') else: print('name found') # ******************************************************************** # # % : Format - Performs String formatting # %s - String (or any object with a string representation, like numbers) # %d - Integers # %f - Floating point numbers print("hello %s your are learning %s it will take %d hours duration"%('student','python',40))