Out[15]: int


In [16]: type(1.5)

Out[16]: float


In [17]: c = 42.42


In [18]: type("Hello World")

Out[18]: str


In [19]: d = 1 + 2j


In [20]: abs(10)

Out[20]: 10


In [21]: abs(-10)

Out[21]: 10


In [22]: help(abs)

Help on built-in function abs in module builtins:


abs(x, /)

Return the absolute value of the argument.



In [23]: dir()

Out[23]:

['In',

'Out',

'_',

'_10',

'_12',

'_13',

'_15',

'_16',

'_18',

'_2',

'_20',

'_21',

'_3',

'_4',

'_5',

'_6',

'_8',

'__',

'___',

'__builtin__',

'__builtins__',

'__doc__',

'__loader__',

'__name__',

'__package__',

'__spec__',

'_dh',

'_i',

'_i1',

'_i10',

'_i11',

'_i12',

'_i13',

'_i14',

'_i15',

'_i16',

'_i17',

'_i18',

'_i19',

'_i2',

'_i20',

'_i21',

'_i22',

'_i23',

'_i3',

'_i4',

'_i5',

'_i6',

'_i7',

'_i8',

'_i9',

'_ih',

'_ii',

'_iii',

'_oh',

'_sh',

'a',

'b',

'c',

'd',

'exit',

'get_ipython',

'quit']


In [24]: d

Out[24]: (1+2j)


In [25]: dir(d)

Out[25]:

['__abs__',

'__add__',

'__bool__',

'__class__',

'__delattr__',

'__dir__',

'__divmod__',

'__doc__',

'__eq__',

'__float__',

'__floordiv__',

'__format__',

'__ge__',

'__getattribute__',

'__getnewargs__',

'__gt__',

'__hash__',

'__init__',

'__int__',

'__le__',

'__lt__',

'__mod__',

'__mul__',

'__ne__',

'__neg__',

'__new__',

'__pos__',

'__pow__',

'__radd__',

'__rdivmod__',

'__reduce__',

'__reduce_ex__',

'__repr__',

'__rfloordiv__',

'__rmod__',

'__rmul__',

'__rpow__',

'__rsub__',

'__rtruediv__',

'__setattr__',

'__sizeof__',

'__str__',

'__sub__',

'__subclasshook__',

'__truediv__',

'conjugate',

'imag',

'real']


In [26]: d.imag

Out[26]: 2.0


In [27]: d.real

Out[27]: 1.0


In [28]: d

Out[28]: (1+2j)


In [29]: d.conjugate

Out[29]: <function complex.conjugate>


In [30]: d.conjugate()

Out[30]: (1-2j)


In [31]: help(d.conjugate)

Help on built-in function conjugate:


conjugate(...) method of builtins.complex instance

complex.conjugate() -> complex


Return the complex conjugate of its argument. (3-4j).conjugate() == 3+4j.



In [32]: (3-4j)

Out[32]: (3-4j)


In [33]: 3-4j

Out[33]: (3-4j)


In [34]: (3-4j).conjugate()

Out[34]: (3+4j)


In [35]: s = "test"


In [36]: del a


In [37]: del b


In [38]: s

Out[38]: 'test'


In [39]: s

Out[39]: 'test'


In [40]: type(s)

Out[40]: str


In [41]: dir(s)

Out[41]:

['__add__',

'__class__',

'__contains__',

'__delattr__',

'__dir__',

'__doc__',

'__eq__',

'__format__',

'__ge__',

'__getattribute__',

'__getitem__',

'__getnewargs__',

'__gt__',

'__hash__',

'__init__',

'__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',

'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']


In [42]: help(s.replace)

Help on built-in function replace:


replace(...) method of builtins.str instance

S.replace(old, new[, count]) -> str


Return a copy of S with all occurrences of substring

old replaced by new. If the optional argument count is

given, only the first count occurrences are replaced.



In [43]: s.replace('t', 'T')

Out[43]: 'TesT'


In [44]: s.capitalize()

Out[44]: 'Test'


In [45]: s = s.replace('t', 'T')


In [46]: s

Out[46]: 'TesT'


In [47]: s.islower()

Out[47]: False


In [48]: type(False)

Out[48]: bool


In [49]: help(s.replace)

Help on built-in function replace:


replace(...) method of builtins.str instance

S.replace(old, new[, count]) -> str


Return a copy of S with all occurrences of substring

old replaced by new. If the optional argument count is

given, only the first count occurrences are replaced.



In [50]: s.replace?

Docstring:

S.replace(old, new[, count]) -> str


Return a copy of S with all occurrences of substring

old replaced by new. If the optional argument count is

given, only the first count occurrences are replaced.

Type: builtin_function_or_method


In [51]: del c


In [52]: del d


In [53]: del s


In [54]: runfile('/Users/progprim/Desktop/spyder-example1.py', wdir='/Users/progprim/Desktop')

30


In [55]: a

Out[55]: 10


In [56]: c = 100


In [57]: runfile('/Users/progprim/Desktop/spyder-example1.py', wdir='/Users/progprim/Desktop')

130


In [58]: %reset


Once deleted, variables cannot be recovered. Proceed (y/[n])? y


In [59]: runfile('/Users/progprim/Desktop/spyder-example1.py', wdir='/Users/progprim/Desktop')

Traceback (most recent call last):


File "<ipython-input-59-5991ee8debb4>", line 1, in <module>

runfile('/Users/progprim/Desktop/spyder-example1.py', wdir='/Users/progprim/Desktop')


File "/Users/progprim/anaconda/lib/python3.5/site-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 714, in runfile

execfile(filename, namespace)


File "/Users/progprim/anaconda/lib/python3.5/site-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 89, in execfile

exec(compile(f.read(), filename, 'exec'), namespace)


File "/Users/progprim/Desktop/spyder-example1.py", line 10, in <module>

print(a + b + c)


NameError: name 'c' is not defined



In [60]: mysum(10, 20)

Traceback (most recent call last):


File "<ipython-input-60-01c43d13a810>", line 1, in <module>

mysum(10, 20)


NameError: name 'mysum' is not defined



In [61]: runfile('/Users/progprim/Desktop/funcexample1.py', wdir='/Users/progprim/Desktop')


In [62]: mysum(10, 20)

Out[62]: 30


In [63]: dir(mysum)

Out[63]:

['__annotations__',

'__call__',

'__class__',

'__closure__',

'__code__',

'__defaults__',

'__delattr__',

'__dict__',

'__dir__',

'__doc__',

'__eq__',

'__format__',

'__ge__',

'__get__',

'__getattribute__',

'__globals__',

'__gt__',

'__hash__',

'__init__',

'__kwdefaults__',

'__le__',

'__lt__',

'__module__',

'__name__',

'__ne__',

'__new__',

'__qualname__',

'__reduce__',

'__reduce_ex__',

'__repr__',

'__setattr__',

'__sizeof__',

'__str__',

'__subclasshook__']


In [64]: dir(mysum)

Out[64]:

['__annotations__',

'__call__',

'__class__',

'__closure__',

'__code__',

'__defaults__',

'__delattr__',

'__dict__',

'__dir__',

'__doc__',

'__eq__',

'__format__',

'__ge__',

'__get__',

'__getattribute__',

'__globals__',

'__gt__',

'__hash__',

'__init__',

'__kwdefaults__',

'__le__',

'__lt__',

'__module__',

'__name__',

'__ne__',

'__new__',

'__qualname__',

'__reduce__',

'__reduce_ex__',

'__repr__',

'__setattr__',

'__sizeof__',

'__str__',

'__subclasshook__']


In [65]: help(mysum)

Help on function mysum in module __main__:


mysum(a, b)

Return a + b



In [66]: mysum.__doc__

Out[66]: 'Return a + b'


In [67]: runfile('/Users/progprim/Desktop/funcexample1.py', wdir='/Users/progprim/Desktop')

The sum of 10 and 20 is 30


In [68]: print(10,20,30)

10 20 30


In [69]: print("{}{}{}".format(10, 20, 30))

102030


In [70]: runfile('/Users/progprim/Desktop/funcexample1.py', wdir='/Users/progprim/Desktop')

The sum of 10 and 20 is 30.


In [71]: runfile('/Users/progprim/Desktop/funcexample1.py', wdir='/Users/progprim/Desktop')

The sum of 10 and 20 is 30.


In [72]: runfile('/Users/progprim/Desktop/funcexample1.py', wdir='/Users/progprim/Desktop')

The sum of 10 and 20 is 30.


In [73]: greetings()

Hello World


In [74]: ret = greetings()

Hello World


In [75]: ret


In [76]: type(ret)

Out[76]: NoneType


In [77]: print(ret)

None


In [78]: runfile('/Users/progprim/Desktop/funcexample1.py', wdir='/Users/progprim/Desktop')

in mysum 0

in mysum 1

The sum of 10 and 20 is 30.


In [79]: mysum(100, 200)

in mysum 0

in mysum 1

Out[79]: 300


In [80]: