Colab

print("hello "+" world!")


hello  world!
2**8

256
2+3*4

14
2+3+4*10

45
(10+2)*3

36
2.0

2.0
2.18

2.18
"hello"

'hello'
"hello" + ' world'

'hello world'
# comment

[1, 2, 3] + [4, 5, 6]

[1, 2, 3, 4, 5, 6]
[1, "hello", [2, 3, 4], 4.5]

[1, 'hello', [2, 3, 4], 4.5]
cities = {
    "UK" : "London",
    "France" : "Paris",
    "Israel" : "Jerusalem"
}

cities

{'UK': 'London', 'France': 'Paris', 'Israel': 'Jerusalem'}
cities.items()

dict_items([('UK', 'London'), ('France', 'Paris'), ('Israel', 'Jerusalem')])
cities.keys()

dict_keys(['UK', 'France', 'Israel'])
cities.values()

dict_values(['London', 'Paris', 'Jerusalem'])
proxies = {
    "proxy1" : ["192.168.100.1", "192.168.100.2", "192.168.100.3"],
    "proxy2" : ["192.168.101.1", "192.168.101.2", "192.168.101.3"],
}

proxies

{'proxy1': ['192.168.100.1', '192.168.100.2', '192.168.100.3'],
 'proxy2': ['192.168.101.1', '192.168.101.2', '192.168.101.3']}
x=10

type(x)

int
x="hello"

type(x)

str
x

'hello'
y = x.upper()

y

'HELLO'
type(y)

str
the_upper_function = x.upper

the_upper_function

<function str.upper()>
type(the_upper_function)

builtin_function_or_method
the_upper_function()

'HELLO'
type(x)

str
str

str
str.upper

<method 'upper' of 'str' objects>
another_name_for_str = str

xxx = str("blah")

type(xxx)

str
xxx + "hello"

'hello'
xxx

'blah'
another_name_for_str("blah")

'blah'
str = 10

str("blah")


    ---------------------------------------------------------------------------

    TypeError                                 Traceback (most recent call last)

    <ipython-input-52-5f422df1b846> in <module>
    ----> 1 str("blah")
    

    TypeError: 'int' object is not callable


str = another_name_for_str

str("blah")

'blah'
dir("blah")

['__add__',
 '__class__',
 '__contains__',
 '__delattr__',
 '__dir__',
 '__doc__',
 '__eq__',
 '__format__',
 '__ge__',
 '__getattribute__',
 '__getitem__',
 '__getnewargs__',
 '__gt__',
 '__hash__',
 '__init__',
 '__init_subclass__',
 '__iter__',
 '__le__',
 '__len__',
 '__lt__',
 '__mod__',
 '__mul__',
 '__ne__',
 '__new__',
 '__reduce__',
 '__reduce_ex__',
 '__repr__',
 '__rmod__',
 '__rmul__',
 '__setattr__',
 '__sizeof__',
 '__str__',
 '__subclasshook__',
 'capitalize',
 'casefold',
 'center',
 'count',
 'encode',
 'endswith',
 'expandtabs',
 'find',
 'format',
 'format_map',
 'index',
 'isalnum',
 'isalpha',
 'isascii',
 'isdecimal',
 'isdigit',
 'isidentifier',
 'islower',
 'isnumeric',
 'isprintable',
 'isspace',
 'istitle',
 'isupper',
 'join',
 'ljust',
 'lower',
 'lstrip',
 'maketrans',
 'partition',
 'replace',
 'rfind',
 'rindex',
 'rjust',
 'rpartition',
 'rsplit',
 'rstrip',
 'split',
 'splitlines',
 'startswith',
 'strip',
 'swapcase',
 'title',
 'translate',
 'upper',
 'zfill']
dir(the_upper_function)

['__call__',
 '__class__',
 '__delattr__',
 '__dir__',
 '__doc__',
 '__eq__',
 '__format__',
 '__ge__',
 '__getattribute__',
 '__gt__',
 '__hash__',
 '__init__',
 '__init_subclass__',
 '__le__',
 '__lt__',
 '__module__',
 '__name__',
 '__ne__',
 '__new__',
 '__qualname__',
 '__reduce__',
 '__reduce_ex__',
 '__repr__',
 '__self__',
 '__setattr__',
 '__sizeof__',
 '__str__',
 '__subclasshook__',
 '__text_signature__']
print(help(str.upper)
type(str.upper)

Help on method_descriptor:

upper(self, /)
    Return a copy of the string converted to uppercase.

None
method_descriptor
print(help("blah".upper()))
type("blah".upper())

No Python documentation found for 'BLAH'.
Use help() to get the interactive help utility.
Use help(str) for help on the str class.

None
str
dir
help
type