String Introduction.py

#String Create
str1 = 'My Name is Aubdur Rob Anik'
print("1st String :: ", str1)

str2 = "My University Name is 'University of Asia Pacific'"
print("\n2nd String :: ", str2)

str3 = '''
My Roll Number is 18101073
My Contact Number is 01685946475
My Best Friend Name is Katrina Jade
'''

print("\n3rd String :: ", str3)

#Specific Index Print
str1 = "Aubdur Rob Anik"
print("\nLast Index :: ", str1[-1])
print("Specific Index :: ", str1[4 : 12])
print ("Specific Index :: ", str1[3 : -2])
print("Sprcific Index :: ", str1[-4 : -1])

# Index Print
print()

str = "Aubdur Rob Anik"
print("Indexs :: ", str[0 : 10 : 1])

str = "Bangladesh"
print("Indexs :: ", str[0 : 9 : 1])
print("Indexs :: ", str[0 : 9 : 2])

str = "Naughty America"
print("Indexs :: ", str[-7 : : 1])
print("Indexs :: ", str[ : -8 : -1])
print("Reverse String :: ", str[-1 : : -1])

# String Add
print()

str = "Aubdur Rob "
str = str + "Anik"
print("String :: ", str)

str = "Aubdur" + " Rob " + "Anik"
print("Name :: ", str)

#Individual index print
print()

str = "Pycharm" ## 0 1 2 3 4 5 6
## P y c h a r m
print("\nFirst Index :: ", str[0])
print("Last Index :: ", str[-1])
print("Middle Index :: ", str[3])
print("Middel Index :: ", str[-4])

'''
#String Delete
str = "My Name is Anik"
del str
print("String is :: ", str)

output ::
Traceback (most recent call last):
File "I:/Python/PythonCode/Basic/Test.py", line 20, in <module>
print(str1)
NameError: name 'str1' is not defined
'''

# Escape Sequencing
print()

str1 = '''I'm a student of UAP.'''
print("String 1 : ", str1)

str2 = "I'm a \"Student\""
print("String 2 :: ", str2)

str3 = "Name : \\Aubdur \\Rob \\Anik"
print(str3)

str4 = "\69x\49y\00a\11b\22c\33d\44e"
print("String 4 :: ", str4)

# Using Raw String to
# Ignore Escape Sequences
str4 = r"\69x\49y\00a\11b\22c\33d\44e"
print("String 4 :: ", str4)

#Split String
print()
str = 'Hi I am Here'


#update Running.................

Comments