# syntax error 1
print('I am missing a quote here)
SyntaxError: EOL while scanning string literal (<ipython-input-1-c1712e68cd5a>, line 3)
# syntax error 2
max(1, 3, 5, 8
SyntaxError: unexpected EOF while parsing (<ipython-input-2-5602d7a5f0eb>, line 3)
# no syntax error
my_tuple = 1, 2, 3
tuple_1 = (1, 2, 3)
my_tuple == tuple_1
# syntax error 3
my_list = [1, 2 3]
SyntaxError: invalid syntax (<ipython-input-8-9a8d5aa3fb80>, line 3)
# Exception 1
a = 10
b
NameError: name 'b' is not defined
# Exception 2
1 + 'two'
TypeError: unsupported operand type(s) for +: 'int' and 'str'
# Exception 3
num = int(input('Enter a number: '))
print('<3' * num)
ValueError: invalid literal for int() with base 10: 'two'
# i am using incorrect type
# first operand is int
# second operand is string
1 + 'two'
TypeError: unsupported operand type(s) for +: 'int' and 'str'
# correct type
# wrong value
int('20') # this is ok
int('two hundred')
ValueError: invalid literal for int() with base 10: 'two hundred'
assert 1 == 2
AssertionError:
my_list = [1, 2, 3]
my_list[3]
IndexError: list index out of range
# heart.py
# the exclamation syntax is for executing linux commands, but this is not interactive
# if the program asks for input, you can't give it interactively
!python heart.py
Enter a number: ^C
Traceback (most recent call last):
File "heart.py", line 2, in <module>
num = int(input('Enter a number: '))
KeyboardInterrupt
%lsmagic
%pwd
%matplotlib inline
%matplotlib --list
Available matplotlib backends: ['tk', 'gtk', 'gtk3', 'wx', 'qt4', 'qt5', 'qt', 'osx', 'nbagg', 'notebook', 'agg', 'svg', 'pdf', 'ps', 'inline', 'ipympl', 'widget']
import math
math.pi
%precision 3
math.pi
%run heart.py
<3<3<3<3<3<3<3<3<3<3
%time sum(range(10000000))
CPU times: user 203 ms, sys: 0 ns, total: 203 ms
Wall time: 202 ms
%who
a math my_list my_tuple num tuple_1
my_list
%reset
Once deleted, variables cannot be recovered. Proceed (y/[n])? y
%run heart.py
ValueError: invalid literal for int() with base 10: 'ten'
%run heart.py
Sorry, I don't understand your input.
NameError: name 'num' is not defined
%run heart.py
Sorry, I don't understand your input.
Sorry, I don't understand your input.
%run heart.py
Sorry, I don't understand your input.
%run heart.py
Sorry, I don't understand your input.
Sorry, I don't understand your input.
<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3
%%writefile demo.txt
Hello There
I am awesome
Writing demo.txt
!pip
Usage:
pip <command> [options]
Commands:
install Install packages.
download Download packages.
uninstall Uninstall packages.
freeze Output installed packages in requirements format.
list List installed packages.
show Show information about installed packages.
check Verify installed packages have compatible dependencies.
config Manage local and global configuration.
search Search PyPI for packages.
wheel Build wheels from your requirements.
hash Compute hashes of package archives.
completion A helper command used for command completion.
debug Show information useful for debugging.
help Show help for commands.
General Options:
-h, --help Show help.
--isolated Run pip in an isolated mode, ignoring
environment variables and user configuration.
-v, --verbose Give more output. Option is additive, and can be
used up to 3 times.
-V, --version Show version and exit.
-q, --quiet Give less output. Option is additive, and can be
used up to 3 times (corresponding to WARNING,
ERROR, and CRITICAL logging levels).
--log <path> Path to a verbose appending log.
--proxy <proxy> Specify a proxy in the form
[user:passwd@]proxy.server:port.
--retries <retries> Maximum number of retries each connection should
attempt (default 5 times).
--timeout <sec> Set the socket timeout (default 15 seconds).
--exists-action <action> Default action when a path already exists:
(s)witch, (i)gnore, (w)ipe, (b)ackup, (a)bort.
--trusted-host <hostname> Mark this host as trusted, even though it does
not have valid or any HTTPS.
--cert <path> Path to alternate CA bundle.
--client-cert <path> Path to SSL client certificate, a single file
containing the private key and the certificate
in PEM format.
--cache-dir <dir> Store the cache data in <dir>.
--no-cache-dir Disable the cache.
--disable-pip-version-check
Don't periodically check PyPI to determine
whether a new version of pip is available for
download. Implied with --no-index.
--no-color Suppress colored output
import emoji
ModuleNotFoundError: No module named 'emoji'
!pip install emoji
Collecting emoji
Downloading emoji-1.2.0-py3-none-any.whl (131 kB)
|████████████████████████████████| 131 kB 26.8 MB/s
Installing collected packages: emoji
Successfully installed emoji-1.2.0
WARNING: You are using pip version 20.1.1; however, version 21.0.1 is available.
You should consider upgrading via the '/root/venv/bin/python -m pip install --upgrade pip' command.
from emoji import emojize
emojize(":thumbs_up:")
emojize(":red_heart:")
emojize(":broken_heart:")
emojize(":alien:")