Python Notes
Python Notes
python str
""
''
''' ''' - used for big messages
print(course[0])- returns characters from the string
print(course[-1])- returns characters from the end of the string
print(course[0:3])- returns characters from 0 position uptil two but excludes the 3
position,
print(course[:]) - returns from 0 to the whole string, can be used to make copies
of the string
print(course[0:])- returns the entire string,
print(1:-1) = returns characters from 1 position to the end of the string excluding
the last character
example
course= ("Python learning")
1. return = P
2. return = g
3. return = Pyt
4. return = Python learning
for formatted strings prefix the string with f'{first variable} [{second variable}]
__________________________________________________________________________________
IF STATEMENTS
If variable:
printer("")
else
printer("")
else:
printer("")
elif variable
printer("")
__________________________________________________________
points to note:
-you can only concatenate str with +
-if using placeholder {} while printing start the statment with 'f'
-placeholder should be placed with the " "
for ex: print(f"New Price after down payment is ${new_price}")
_______________________________________________
and/or operator
not= converts true boolean value to false