#!/usr/bin/env python # coding: utf-8 # # Introduction: The basics of Notebook # # \begin{equation} # \int_0^\infty f(x) dx # \end{equation} # # You can write standard Python: # In[1]: from math import * print(cos(pi)) print(pi) 2*pi # In[2]: import math from scipy import * from numpy import * print(dir(math)) print( log2(10) ) print( math.log(10,2), math.log2(10) ) #info(log2) # ## Two modes # # **Command Mode** and **Edit Mode** # # "Return" and "Esc" to switch between **Command** and **Edit** modes # # **To Execute** : "Shift Return" # # **To return to Edit mode** : "Return/double click" # # **hide long cell output** double click # In[3]: import requests resp = requests.get("http://www.physics.rutgers.edu/grad/509/") resp.content # ## Two (main) cell types # # In a different type of cell, you can: # # * write Markdown # * embed LaTex equation in it # # So you can add comments to your code explaining that, to calculate your cycling speed, you must make use of the fact that # # $[x,p_x]=i \hbar$. # ## Some basic operations and keystrokes: # # Toggling toolbars. # # * Return and Esc # * A (new cell before) and B (new cell after) # * X (cut cell), C (copy cell), V (paste cell) # * DD (delete cell) # # The different types of Return: # * Shift-Return # * Ctrl-Return # * Alt-Return # # Choosing cell type: # * M (for Markdown) # * Y (for code) # Use ! to use shell comman right inside notebook # In[7]: get_ipython().system('ls -ltr') get_ipython().system('pwd') # ## Sharing your notebooks # # You can just send people the .ipynb files; they'll contain your input and (optionally) your output. # # Other ways to view and run: # # * **nbconvert** - e.g. convert to static HTML, LaTeX, PDF, Python script, etc # * **Github & Bitbucket** - rendered, but static, e.g. for [qhue](https://github.com/quentinsf/qhue) # * **nbviewer** - http://nbviewer.jupyter.org # * **binder** or **Azure notebooks** - take a github repo with notebooks, and run them in a Docker session \[mybinder.org\] # * **jupyterhub** - run locally to make jupyter environments available to users # # --- # ## Understanding the kernel setting # # The running Python environment is determined by the *kernel setting* of your notebook and not, for example, by the virtualenv you happen to be in. # # Here's where your shell environment will find python, pip etc: # In[8]: get_ipython().system('which python') # That's often the Python that's running the notebook server. # And here's the Python running *this notebook*, defined by the choice of kernel: # In[9]: import sys sys.executable # ## And lastly... # # Close and Halt #