P YTHON
P YTHON
• print(“Hello World”)
Try!!
Age=20
Age=30
Print (Age)
Print(“age”)is different.
• Price= 19.5
• First_name = “your name”
• Print (first_name)
• Boolean(Yes or No)
• Is_online = False
• Use capital F.
Activity 1
• We check in a patient name George smith.
• He is 20 years old.
• He Is a new patient.
• Hi sam
• thank you,
• the support team.
• '''
• print(course)
We can get individual characters in a string using
square brackets [].
• course = ‘Pythons for Beginners’
• print(Course[0])
Extract few characters instead of 1
• course = ‘Pythons for Beginners’
• print(Course[0:3])
• print(Course[0:])
• print(Course[:3])
Creates A COPY of the variable
• course = ‘Pythons for Beginners’
• another = course[:]
• Print(another)
Excercise
• name=“joseph”
• print(name [1:-1])
len
• course = ‘Pythons for Beginners’
• print( len(course) )
• print (course.upper() )
• print(course)
Dot function- upper and lower case
• course = ‘Pythons for Beginners’
• print (course.upper() )
• Print(course.lower() )
• print(course)
Find operator
• course = ‘Pythons for Beginners’
• print (course.find(‘y’) )
replace
• course = ‘Pythons for Beginners’
• print (course. replace(‘for’, ‘4’) )
Arithmetic operators
•+
•-
•*
•/
• //
• **
• Augumented assignment operator
Foramtted strings
• Strings We can define strings using single (‘ ‘) or double (“ “)
quotes. To define a multi-line string, we surround our string with
tripe quotes (“””).
• We can get individual characters in a string using square brackets
[].
• course = ‘Python for Beginners’ course
• [0] # returns the first character course
• [1] # returns the second character course
• [-1] # returns the first character from the end course
• [-2] # returns the second character from the end
• We can slice a string using a similar notation: course[1:5]
• The above expression returns all the characters starting from the
index position of 1 to 5 (but excluding 5).
• The result will be ytho
• If we leave out the start index, 0 will be assumed. If we leave out
the end index, the length of the string will be assumed.