Saturday, April 1, 2023

ADDING TWO STRINGS WITH SLICING METHODS USING PYTHON PROGRAMMING

                        ADDING TWO STRINGS WITH SLICING METHODS

   a="life is "

   b="beautiful"

   c=a+b

  print(c)


  #positive index

  print(c[3:15])


  #slice to the start

  print(c[:15])


  #slice to the end 

  print(c[8:])


  #negative indexing

  print(c[-10:-4])


  #first negative index and positive index

   print(c[-12:7])


  #positive index with positive interval

   print(c[2:14:3])


   #negative index with negative interval

   print(c[-2:-12:-1])


    #positive index with negative interval

   print(c[12:5:-2])


# 2 negative and 1 positive interval

print(c[-17:-5:4])


  #1 positive 1 negative and one positive interval

   print(c[12:-8:-2])


  #1 negative 1 positive and 1 negative interval

   print(c[-5:7:-1])


   #slice to the start with positive index and positive interval

   print(c[ :10:2])


   #slice to the start with negative index and negative interval

    print(c[:-10:-2])


   #without index only interval

   print(c[ : :4])


   #without index only negative interval

   print(c[ : :-1])


   #without index and interval

   print(c[ : : ])

   OUTPUT:

   life is beautiful
   e is beautif
   life is beautif
    beautiful
    beaut
    is
   fibu
  ufituaeb s
  tabs
  l b
  ta
  tuaeb
  lf sb
  lftab
  l btl
  lufituaeb si efil
  life is beautiful


USD TO INR C++ PROGRAMMING

  NALLAMUTHU GOUNDER MAHALINGAM COLLEGE                                                 POLLACHI-642001                                     ...