program 1:
#string with single quotes
string1='welcome to the AI Class'
print("String with the use of single quotes")
print(string1)
#string with double quotes
string2="welcome to the AI Class"
print("String with the use of double quotes")
print(string2)
#string with triple quotes
string3='''"welcome to the AI Class"'''
print("String with the use of triple quotes")
print(string3)
#string with triple quotes allows multiple lines
string3='''"welcome
to the AI
Class"'''
print("String with the use of triple quotes allows multiple lines")
print(string3)
program 2:
#Access characters of String
String1 = "ArtificialIntelligence"
print("Initial String: ")
print(String1)
# Printing First character
print("\nFirst character of String is: ")
print(String1[0])
# Printing Last character
print("\nLast character of String is: ")
print(String1[-1])
program 3:
#String Slicing:
MyString='Learn Python'
print(MyString[0:5])
print(MyString[-12:-7],"\n")
print(MyString[6:])
print(MyString[:-7],"\n")
print(MyString[:])
program 4:
0 Comments