import math
Python is CASE SENSITIVE !!
methods:
- basic
- print()
- input()
-
- len() to calculate length of a string, list element numbers, …
- find() to return the index of a character or character sequence in the string(case sensitive)
- replace() to replace a certain pattern to another(case sensitive)
- upper()
- lower()
- typecast:
- int()
- float()
- mathematical
- round()
- abs()
‘’’ ‘’’ string in several lines, without any indent(despite in structural blocks with automatically indent)
compare:
"""
this is a string
this is a string
"""
"""
this is a string
this is a string
"""
usage of ’ ’ and “”
format string:
f’ {variables}’
using curly braces to dynamically insert values
" pattern " in string variable : returns the result as a boolean value(case sensitive)
String accessing and cutting:
index could be positive and negativ.
range using [a:b]
e.g.:
abcdefgh
[0:2] : ab
[-1] : h
[-10:-1] : abcdefg
[-1:-10] : no output, no error
exponentiation: **
operator precedence
logical operators: and, or, not
comparison operators:
structural:
if
if boolean_variable:
statement
elif boolean_variable:
else:
statement
while
while boolean_variable:
statement
...
break
else:
statement //while exited normally without been breaked.