Topics:

  1. String Indexing and Reverse Indexing
  2. String Slicing
  3. Using Operators with String ( String Concatenation and Multiplication )
  4. F-String
  5. input function in python - take input from user

Notes Explained in Session

# data types - 4 
# int , float , string , boolean 
# string manipulation 
# string is combination of charactesr 

word = "pineapple" 

# string indexing 

print( word[0] )

# negative indexing 

print( word[-2] )

# string slicing 

print( word[0:3] )
print( word[:3] ) # start from 0 if start is not defined

print( word[3:] ) # if upperlimit is not defined then it goes till end

print( word[1:6:2] ) # with start , end , step 

# format : stringvariable[start:end:step]

print( word[6:1:-1] ) # example of negative step 

print( word[::-1] ) # reverse the whole word 

# operators 
# + ( only possible between two string )

word1 = "pine" 
word2 = "apple"

print(word1+word2) # concatination
print(word2+word1)

# print( word1 + 5 ) invalid

# * ( only possible between a string and an int )
# print(word1*word2)  invalid 

print(word1 * 5)

# F- string - use variables directly inside string 

time = "7 am " 

print( "I will meet you at " , time )
print( f"I will meet you at {time}" )

Doubts

# comments 

'''
This is a block comment
Here in thi program we are 
going to do this and that
and this is so long explanation
'''

# f - string 

word = "apple"

print(f"the word is [word]")

word = "TLE" 

print(word[:3:1]) # start : stop : step

print(word[::-1])

How to Take Input from user


word = input("Enter a word : ")

print("----------------------------------")
print("The given word is : " )
print(word)