Unit-2 - Jupyter Notebook
Unit-2 - Jupyter Notebook
ipynb
In [15]:
pip install jupyterthemes
Requirement already satisfied: jupyterthemes in c:\users\acer\anaconda3\lib\site-packages (0.20.0)Note: you may need to restart the
kernel to use updated packages.
In [16]:
Available Themes:
chesterish
grade3
gruvboxd
gruvboxl
monokai
oceans16
onedork
solarizedd
solarizedl
In [6]:
2 of 14 27-08-2024, 17:17
Unit-2 - Jupyter Notebook http://localhost:8888/notebooks/Unit-2.ipynb
In [18]:
In [19]:
In [9]:
In [10]:
In [11]:
In [13]:
In [14]:
print ('hello')
3 of 14 27-08-2024, 17:17
Unit-2 - Jupyter Notebook http://localhost:8888/notebooks/Unit-2.ipynb
print ('hello')
print('hello')
In [1]: In [3]:
2*3
Out[1]:
6
In [2]:
hii
( )
6
first python code
4 of 14 27-08-2024, 17:17
Unit-2 - Jupyter Notebook http://localhost:8888/notebooks/Unit-2.ipynb
In [5]:
Bold text
Level 1 Heading
1. Ordered list item 1
2. Ordered list item 2
3. Ordered list item 3
1. Ordered list
item 1 2. Ordered
In [ ]: list item 2
In [6]: "C:\Users\ACER\AppData\Local\Temp/ipykernel_1
<p style="font-family: 'Courier New', 964/3841431978.py", line 1 <p
monospace; font-size: 20px;"> This is a style="font-family: 'Courier New', monospace;
custom font style for this cell. font-size: 20px;"> ^
</p> SyntaxError: invalid syntax
File
5 of 14 27-08-2024, 17:17
Unit-2 - Jupyter Notebook http://localhost:8888/notebooks/Unit-2.ipynb
This is a custom font style for this cell.
'hiiiiiiiiiii'
In [7]:
alt
text here
• Unordered list item 1
• Unordered list item 2
• Unordered list item 3
print("Hello, world!")
Writing my_script.py
In [2]: In [3]: In [4]:
%%markdown
# This is a Markdown Heading
* This is a bullet point
<IPython.core.display.Markdown object>
In [5]: In [7]:
%%bash
ls -l
Couldn't find program: 'bash'
%%timeit
sum(range(100))
%! dir
4.77 µs ± 2.03 µs per loop (mean ± std. dev. of 7 runs,
100000 loops each) UsageError: Line magic function `%!` not found (But cell
magic `%%!` exists, did you mean that instea d?).
%%writefile my_script.py
7 of 14 27-08-2024, 17:17
Unit-2 - Jupyter Notebook http://localhost:8888/notebooks/Unit-2.ipynb
In [6]: In [8]:
In [11]: In [12]:
In [9]:
In [13]:
%%bash
ls -l
Couldn't find program: 'bash'
In [10]:
!ls -l %%html
8 of 14 27-08-2024, 17:17
Unit-2 - Jupyter Notebook http://localhost:8888/notebooks/Unit-2.ipynb
import matplotlib.pyplot as plt
# Create a plot
plt.plot(data)
%%javascript plt.title("Simple Line Plot")
alert("This is a JavaScript plt.xlabel("X-axis")
alert!") plt.ylabel("Y-axis")
plt.show()
<IPython.core.display.Javascrip
t object>
%matplotlib inline
9 of 14 27-08-2024, 17:17
Unit-2 - Jupyter Notebook http://localhost:8888/notebooks/Unit-2.ipynb
%load_ext sql
%sql sqlite:///mydatabase.db
In [16]: In [20]: %%sql
SELECT * FROM Employees WHERE department =
'Sales';
File
"C:\Users\ACER\AppData\Local\Temp/ipykernel_2
236/623830073.py", line 5 SELECT * FROM
Employees WHERE department = 'Sales';
^
SyntaxError: invalid syntax
a, b = b, a + b # Update a and b
return fib_series
10 of 14 27-08-2024, 17:17
Unit-2 - Jupyter Notebook http://localhost:8888/notebooks/Unit-2.ipynb
In [ ]: # %load fibo.ipynb
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "fc9cf5ec",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]\n"
]
}
],
"source": [
"def fibonacci_iterative(n):\n",
" fib_series = []\n",
" a, b = 0, 1\n",
" for _ in range(n):\n",
" fib_series.append(a)\n",
" a, b = b, a + b # Update a and b\n",
" return fib_series\n",
"\n",
"# Example: Generate the first 10 Fibonacci numbers\n",
"n = 10\n",
"print(fibonacci_iterative(n))\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5221035d",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
11 of 14 27-08-2024, 17:17
Unit-2 - Jupyter Notebook http://localhost:8888/notebooks/Unit-2.ipynb
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Out[24]: 55
%timeit fibonacci(10)
In [25]: 71.1 µs ± 8.56 µs per loop (mean ± std.
def fibonacci(n): dev. of 7 runs, 10000 loops each)
if n == 0 or n == 1: return n
return fibonacci(n-1)+fibonacci(n-2)
12 of 14 27-08-2024, 17:17
Unit-2 - Jupyter Notebook http://localhost:8888/notebooks/Unit-2.ipynb
specified: 'Form_data_visualization'
C:\Users\ACER
In [26]: In [27]: In [28]:
In [29]:
Out[29]: 'C:\\Users\\ACER'
]:
In [32]:
len?
In [
13 of 14 27-08-2024, 17:17
Unit-2 - Jupyter Notebook http://localhost:8888/notebooks/Unit-2.ipynb 14 of 14 27-08-2024, 17:17