string manipulation in python code example

Example 1: how to create string in python

string = "this is string"
#or
string = 'this is also string'

Example 2: print string python

str1 = "Hello World"
print(str1)

Example 3: how to create a string in python

var1 = "A String"

Example 4: methods in python

#Objects can also contain methods. Methods in objects are functions that belong to the object.
#Let us create a method in the Person class:

class Person:
  
  def __init__(self, name, age):
    self.name = name
    self.age = age

  def myfunc(self): # This is a method
    print("Hello my name is " + self.name)

p1 = Person("John", 36)
p1.myfunc()