0% found this document useful (0 votes)
5 views17 pages

Unit-2 - Jupyter Notebook

The document is a Jupyter Notebook containing various code snippets and outputs related to Python programming, including installations, themes, and examples of basic Python functions such as Fibonacci series generation. It also showcases Markdown usage for formatting text and includes error messages related to missing fonts and commands. Additionally, it demonstrates plotting with Matplotlib and SQL queries, highlighting the interactive nature of Jupyter Notebooks.

Uploaded by

neeshu.chaudhary
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views17 pages

Unit-2 - Jupyter Notebook

The document is a Jupyter Notebook containing various code snippets and outputs related to Python programming, including installations, themes, and examples of basic Python functions such as Fibonacci series generation. It also showcases Markdown usage for formatting text and includes error messages related to missing fonts and commands. Additionally, it demonstrates plotting with Matplotlib and SQL queries, highlighting the interactive nature of Jupyter Notebooks.

Uploaded by

neeshu.chaudhary
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Unit-2 - Jupyter Notebook http://localhost:8888/notebooks/Unit-2.

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.

Requirement already satisfied: ipython>=5.4.1 in c:\users\acer\anaconda3\lib\site-packages (from jupyter themes) (7.29.0)


Requirement already satisfied: matplotlib>=1.4.3 in c:\users\acer\anaconda3\lib\site-packages (from jupy terthemes) (3.4.3)
Requirement already satisfied: lesscpy>=0.11.2 in c:\users\acer\anaconda3\lib\site-packages (from jupyte rthemes) (0.15.1)
Requirement already satisfied: notebook>=5.6.0 in c:\users\acer\anaconda3\lib\site-packages (from jupyte rthemes) (6.4.5)
Requirement already satisfied: jupyter-core in c:\users\acer\anaconda3\lib\site-packages (from jupyterth emes) (4.8.1)
Requirement already satisfied: traitlets>=4.2 in c:\users\acer\anaconda3\lib\site-packages (from ipython >=5.4.1->jupyterthemes) (5.1.0)
Requirement already satisfied: prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0 in c:\users\acer\anaconda3\l ib\site-packages (from
ipython>=5.4.1->jupyterthemes) (3.0.20)
Requirement already satisfied: backcall in c:\users\acer\anaconda3\lib\site-packages (from ipython>=
5.4.1->jupyterthemes) (0.2.0)
Requirement already satisfied: matplotlib-inline in c:\users\acer\anaconda3\lib\site-packages (from ipyt 1 of 14 27-08-2024, 17:17
Unit-2 - Jupyter Notebook http://localhost:8888/notebooks/Unit-2.ipynb

In [16]: 

Requirement already satisfied: jupyterthemes in c:\users\acer\anaconda3\lib\site-packages (0.20.0)


Requirement already satisfied: matplotlib>=1.4.3 in c:\users\acer\anaconda3\lib\site-packages (from jupy terthemes) (3.4.3)
Requirement already satisfied: notebook>=5.6.0 in c:\users\acer\anaconda3\lib\site-packages (from jupyte rthemes) (6.4.5)
Requirement already satisfied: lesscpy>=0.11.2 in c:\users\acer\anaconda3\lib\site-packages (from jupyte rthemes) (0.15.1)
Requirement already satisfied: jupyter-core in c:\users\acer\anaconda3\lib\site-packages (from jupyterth emes) (4.8.1)
Requirement already satisfied: ipython>=5.4.1 in c:\users\acer\anaconda3\lib\site-packages (from jupyter themes) (7.29.0)
Requirement already satisfied: jedi>=0.16 in c:\users\acer\anaconda3\lib\site-packages (from ipython>=
5.4.1->jupyterthemes) (0.18.0)
Requirement already satisfied: matplotlib-inline in c:\users\acer\anaconda3\lib\site-packages (from ipyt hon>=5.4.1->jupyterthemes)
(0.1.2)
Requirement already satisfied: pygments in c:\users\acer\anaconda3\lib\site-packages (from ipython>=
5.4.1->jupyterthemes) (2.10.0)
Requirement already satisfied: traitlets>=4.2 in c:\users\acer\anaconda3\lib\site-packages (from ipython >=5.4.1->jupyterthemes) (5.1.0)
Requirement already satisfied: colorama in c:\users\acer\anaconda3\lib\site-packages (from ipython>=
In [17]: 

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]: 

Reset css and font defaults in:


C:\Users\ACER\.jupyter\custom &
C:\Users\ACER\AppData\Roaming\jupyter\nbextensions

In [19]: 

Traceback (most recent call last):


File "C:\Users\ACER\anaconda3\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\ACER\anaconda3\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\ACER\anaconda3\Scripts\jt.exe\__main__.py", line 7, in <module>
File "C:\Users\ACER\anaconda3\lib\site-packages\jupyterthemes\__init__.py", line 290, in main
install_theme(
File "C:\Users\ACER\anaconda3\lib\site-packages\jupyterthemes\__init__.py", line 69, in install_theme
style_less = stylefx.set_font_properties(
File "C:\Users\ACER\anaconda3\lib\site-packages\jupyterthemes\stylefx.py", line 142, in set_font_prope rties
monofont, monofpath = stored_font_dicts(monofont)
ValueError: not enough values to unpack (expected 2, got 0)

One of the fonts you requested is not available


Setting all fonts to default

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 hii')

print('hello')

In [1]: In [3]:
 
2*3

Out[1]:
6

In [2]:

hii
( )

6
first python code

first python code

first python code

first python code

first python code

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

first python code


Strikethrough 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

Ordered list item 1 Ordered list item 2 Ordered list item

3 hiii tis is neeshu here

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.

'here is some thing'

'hiiiiiiiiiii'

In [7]: 

Out[7]: 'here is some thing'

'here is some thing'

Our program website can be found at this link (http://earthdatascience.org).


6 of
14 27-08-2024, 17:17
Unit-2 - Jupyter Notebook http://localhost:8888/notebooks/Unit-2.ipynb

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

'ls' is not recognized as an internal or


external command, operable program or batch
file.
Hello World
%%debug
x = 5
y = 0
'bash' is not recognized as an internal or
result = x / y
external command, operable program or batch
file. NOTE: Enter 'c' at the ipdb> prompt to
continue execution. > <string>(2)<module>()
%%sh
ipdb> c
bash --version
--------------------------------------------
Couldn't find program: 'sh' -------------------------------
ZeroDivisionError Traceback (most recent
!echo $SHELL call last) ZeroDivisionError: division by
zero
$SHELL

8 of 14 27-08-2024, 17:17
Unit-2 - Jupyter Notebook http://localhost:8888/notebooks/Unit-2.ipynb
import matplotlib.pyplot as plt

# Generate some data


In [14]:  In [15]:  data = [1, 2, 3, 4, 5]

# 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

# Example: Generate the first 10 Fibonacci


def fibonacci_iterative(n):
numbers
fib_series = []
n = 10
a, b = 0, 1
print(fibonacci_iterative(n))
for _ in range(n):
fib_series.append(a) [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]

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
}

In [23]:  In [24]:  def fibonacci(n):


if n == 0 or n == 1:
return n
return
%run fibo.ipynb fibonacci(n-1)+fibonacci(n
-2) %time fibonacci(10)
[0, 1, 1, 2, 3, 5, 8, 13,
21, 34] Wall time: 0 ns

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]: 

[WinError 3] The system cannot find the path


specified: 'notebooks/fibo.ipynb'
%cd Form_data_visualization C:\Users\ACER

[WinError 2] The system cannot find the file

Out[28]: Available line magics:


%alias %alias_magic %autoawait %autocall %automagic %autosave %bookmark %cd %clear %cls %color s %conda
%config %connect_info %copy %ddir %debug %dhist %dirs %doctest_mode %echo %ed %edit %env %gui %hist
%history %killbgscripts %ldir %less %load %load_ext %loadpy %logoff %logon %logstart %logstate %logstop
%ls %lsmagic %macro %magic %matplotlib %mkdir %more %notebook %p age %pastebin %pdb %pdef %pdoc %pfile
%pinfo %pinfo2 %pip %popd %pprint %precision %prun %p search %psource %pushd %pwd %pycat %pylab
%qtconsole %quickref %recall %rehashx %reload_ext %ren %rep %rerun %reset %reset_selective %rmdir %run
%save %sc %set_env %store %sx %system %tb %time %timeit %unalias %unload_ext %who %who_ls %whos %xdel
%xmode

Available cell magics:


%%! %%HTML %%SVG %%bash %%capture %%cmd %%debug %%file %%html %%javascript %%js %%latex %%ma rkdown
%%perl %%prun %%pypy %%python %%python2 %%python3 %%ruby %%script %%sh %%svg %%sx %%s ystem %%time
%%timeit %%writefile

Automagic is ON, % prefix IS NOT needed for line magics.

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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy