x = abs(y)
print(type(3.0))
import math
print(math.sqrt(x**2 + y**2))
from math import sqrt,
print(sqrt(x**2 + y**2))
n = trunc(x))
from math import *
print(sqrt(x**2 + y**2))
'type'
>>> type("abc")
<class 'str'>
>>> type(type("abc"))
<class 'type'>
>>> type(int)
<class 'type'>
>>> type(type(int))
<class 'type'>
>>> s = "ABCD"
>>> s.lower()
'abcd'
>>> s = "abcd"
>>> s.upper()
'ABCD'
>>> ("abc" + "def").upper()
'ABCDEF'
s.capitalize()
returns a capitalized version of s
>>> s = "abc"
>>> s.center(15)
' abc '
s.count(s1)
counts the number of occurrences of s1
in s
>>> s = "Now is the time for everyone to get a covid vaccination."
>>> s.count("t")
5
>>> s.count("on")
2
s.endswith(s1)
determines whether s
ends with s1
>>> s = "image.pdf"
>>> s.endswith(".pdf")
True
>>> s.endswith(".jpg")
False
s.find(s1)
returns the position of the first occurrence of s1
in s
or -1 if s1
does not occur>>> s = "Now is the time for everyone to get a covid vaccination."
>>> s.find("t")
7
>>> s.find("ti")
11
>>> s.find("N")
0
s.find(s1, m)
starts the search at position m
>>> s.find("t", 10)
11
s.find(s1, m, n)
only searches between positions m
and n
>>> s.find("t", 20, 30)
29
>>> s.find("t", 20, 25)
-1
s.islower
determines whether all characters in s
are lower case>>> s = "abc"
>>> s.islower()
True
s.isupper()
determines whether all characters in s
are upper case
s.isalpha()
determines whether all characters in s
are letter
s.isdigit()
determines whether all characters in s
are digits (0 - 9)
s.isspace()
determines whether all characters in s
are space, tab, or newline
s.islower()
determines whether all characters in s
are lower case
s.ljust(n)
returns a string of length n
starting with s
(left justification)
s.rjust(n)
returns a string of length n
ending with s
(right justification)
>>> s = "abd"
>>> s.ljust(10)
'abd '
>>> s.rjust(10)
' abd'
s.replace(s1, s2)
returns a string like s
but with s1
replaced by s2
>>> s="image.png";
>>> s.replace(".png", ".pdf")
'image.pdf'
s.strip()
returns a string like s but with white space removed from both ends>>> s = " foo "
>>> s.strip()
'foo'
>>> s = " foobar "
>>> s.upper().replace("FOO", "xxx").strip()
'xxxBAR'
There are special methods that are used by Python itself
Their names are surrounded with double underscores
Builtin functions are really special methods
>>> (-3).__abs__()
3
>>> "abcd".__len__()
4