9:59:59.000,9:59:59.000 1[br]00:00:04,490 --> 00:00:09,040[br]In this video, I'm going to show you how to start up the Jupyter environment that we're going 9:59:59.000,9:59:59.000 2[br]00:00:09,040 --> 00:00:13,550[br]to be using for our Python program and write some of our first Python code. 9:59:59.000,9:59:59.000 3[br]00:00:13,550 --> 00:00:18,110[br]Also walk through the steps needed to turn a notebook into a PDF 9:59:59.000,9:59:59.000 4[br]00:00:18,110 --> 00:00:23,930[br]you can submit on blackboard for one of the assignments. So I've already installed Anaconda. 9:59:59.000,9:59:59.000 5[br]00:00:23,930 --> 00:00:32,500[br]You can find the instructions for that on the course Web site. On Windows, when we've installed in ancondo, we get 9:59:59.000,9:59:59.000 6[br]00:00:32,500 --> 00:00:40,630[br]a new kind of prompt available in the START menu. So I can go in to start the anaconda power shall prompt. 9:59:59.000,9:59:59.000 7[br]00:00:40,630 --> 00:00:44,010[br]And this starts up a power shell command line 9:59:59.000,9:59:59.000 8[br]00:00:44,010 --> 00:00:51,790[br]that has Anaconda activated. The process for doing this on Linux or on Windows is slightly different, although excuse me, 9:59:59.000,9:59:59.000 9[br]00:00:51,790 --> 00:01:00,160[br]on Linux or on Mac is slightly different, although you can also start the prompt from the Anaconda navigator. 9:59:59.000,9:59:59.000 10[br]00:01:00,160 --> 00:01:09,490[br]I will show you in another video how to activate Anaconda when we have it installed on Onyx, which will also apply to other Linux systems. 9:59:59.000,9:59:59.000 11[br]00:01:09,490 --> 00:01:18,610[br]So I'm in my anaconda prompt, it's in my home directory. I'm going to go to the directory I've created for working on C.S. 533. 9:59:59.000,9:59:59.000 12[br]00:01:18,610 --> 00:01:27,610[br]So I'm going to cd into documents\CS 533 assignments, and here I'm going to start the Jupyter environment with Jupyter notebook. 9:59:59.000,9:59:59.000 13[br]00:01:27,610 --> 00:01:33,880[br]So we're gonna be doing our work in what we call notebooks. They're a part of Jupyter. We can start this at the command line with Jupyter notebook. 9:59:59.000,9:59:59.000 14[br]00:01:33,880 --> 00:01:39,070[br]And it's going to start up the Jupyter system and open it up in our Web browser. 9:59:59.000,9:59:59.000 15[br]00:01:39,070 --> 00:01:45,100[br]The Web browser is the interface that we use to interface with Jupyter and interact with notebooks. 9:59:59.000,9:59:59.000 16[br]00:01:45,100 --> 00:01:50,650[br]So if I had some notebook files in here, they would be listed in the notebook list and we could open them. 9:59:59.000,9:59:59.000 17[br]00:01:50,650 --> 00:01:55,900[br]So in the assignment, you'll download the starter notebook. Save it in the directory you're working in. 9:59:59.000,9:59:59.000 18[br]00:01:55,900 --> 00:02:00,860[br]When you run Jupiter notebook, it will appear. But right now, I'm one to create a new notebook. 9:59:59.000,9:59:59.000 19[br]00:02:00,860 --> 00:02:08,560[br]I'm going to create a new Python 3 notebook because Python 3 is what we're using in this class. 9:59:59.000,9:59:59.000 20[br]00:02:08,560 --> 00:02:20,640[br]And it's a new notebook and it's untitled. So I'm going to given a name here. 9:59:59.000,9:59:59.000 21[br]00:02:20,640 --> 00:02:24,640[br]I'm just going to call it demo notebook because it's the notebook that I'm using to demonstrate. 9:59:59.000,9:59:59.000 22[br]00:02:24,640 --> 00:02:32,650[br]If I go back to our notebook list, we now see it and its "Demo Notebook.ipynb" the ipynb file as the source filed for the notebook. 9:59:59.000,9:59:59.000 23[br]00:02:32,650 --> 00:02:39,130[br]You're going to be submitting those as one of the things you submit in your assignment. So now a notebook is made up of cells. 9:59:59.000,9:59:59.000 24[br]00:02:39,130 --> 00:02:46,110[br]And right now we have one cell here. So I want to put some code in it. 9:59:59.000,9:59:59.000 25[br]00:02:46,110 --> 00:02:52,530[br]I'm just going to write the string "Hello, world". The string isn't close in case, and it's enclosed in double quotes. 9:59:59.000,9:59:59.000 26[br]00:02:52,530 --> 00:03:01,480[br]And I am going to hit shift enter. And that run - shift enter - runs the cell that we're currently in. 9:59:59.000,9:59:59.000 27[br]00:03:01,480 --> 00:03:09,970[br]And now it's labeled In [1] . It's the first cell that we ran. And it has an output Out [1] that says, "Hello, world" 9:59:59.000,9:59:59.000 28[br]00:03:09,970 --> 00:03:19,960[br]When you run a cell and the last line of the cell is an expression that has some value, what Jupyter will do is it will show you that value. 9:59:59.000,9:59:59.000 29[br]00:03:19,960 --> 00:03:24,700[br]So because the last and only line of the cell is the string value 9:59:59.000,9:59:59.000 30[br]00:03:24,700 --> 00:03:28,540[br]"Hello, world" It shows me the value. "Hello, world" 9:59:59.000,9:59:59.000 31[br]00:03:28,540 --> 00:03:37,500[br]If I put in a value - a number - five, it will show me the number five. 9:59:59.000,9:59:59.000 32[br]00:03:37,500 --> 00:03:41,820[br]It only prints the value of the last line, but it lets us very quickly just see an object. 9:59:59.000,9:59:59.000 33[br]00:03:41,820 --> 00:03:48,990[br]We don't even need to worry about print statements. If we do want to create output, we can 9:59:59.000,9:59:59.000 34[br]00:03:48,990 --> 00:03:53,310[br]call print, and it will print the output for the way Python would usually print it. 9:59:59.000,9:59:59.000 35[br]00:03:53,310 --> 00:03:59,370[br]It shows up as a as as text. Jupyter is going to show the output of our program here. 9:59:59.000,9:59:59.000 36[br]00:03:59,370 --> 00:04:05,640[br]It's formatted a little differently because its output. It's not just showing the results of an expression. 9:59:59.000,9:59:59.000 37[br]00:04:05,640 --> 00:04:10,170[br]These code cells are not the only cells that we can have in a notebook. 9:59:59.000,9:59:59.000 38[br]00:04:10,170 --> 00:04:16,530[br]So I'm going to insert a new cell above the above this one. 9:59:59.000,9:59:59.000 39[br]00:04:16,530 --> 00:04:21,030[br]And I am going to change its type to markdown. 9:59:59.000,9:59:59.000 40[br]00:04:21,030 --> 00:04:34,090[br]And in a markdown cell, we don't write python code, but we write text. 9:59:59.000,9:59:59.000 41[br]00:04:34,090 --> 00:04:39,790[br]So I wrote the text, this is the demonstration node to show notebook to show you how to run Python code. 9:59:59.000,9:59:59.000 42[br]00:04:39,790 --> 00:04:44,170[br]And if I run this notebook, it just renders it as text. 9:59:59.000,9:59:59.000 43[br]00:04:44,170 --> 00:04:48,430[br]Now I can edit it. I'm going to double click to edit it again. 9:59:59.000,9:59:59.000 44[br]00:04:48,430 --> 00:04:54,930[br]This supports all markdown features so we can give this notebook a heading. 9:59:59.000,9:59:59.000 45[br]00:04:54,930 --> 00:05:01,560[br]We always want to begin our notebook with a level one heading, which is done with a single hash that gives the title of the notebooks, 9:59:59.000,9:59:59.000 46[br]00:05:01,560 --> 00:05:07,030[br]that then when we convert it to another format, we're gonna have the title right there. 9:59:59.000,9:59:59.000 47[br]00:05:07,030 --> 00:05:17,540[br]Markdown cells support a variety of formatting features. 9:59:59.000,9:59:59.000 48[br]00:05:17,540 --> 00:05:25,040[br]Such as bold and italics. 9:59:59.000,9:59:59.000 49[br]00:05:25,040 --> 00:05:37,060[br]Also, bulleted lists. Lists and numbered 9:59:59.000,9:59:59.000 50[br]00:05:37,060 --> 00:05:47,080[br]lists. I'm going to stick another cell in here. I use the menu - 9:59:59.000,9:59:59.000 51[br]00:05:47,080 --> 00:05:52,930[br]I can also hit the A key and it will add a new cell above and M changes it to mark down. 9:59:59.000,9:59:59.000 52[br]00:05:52,930 --> 00:05:57,130[br]There's keys that will that will let us navigate the notebook quickly. 9:59:59.000,9:59:59.000 53[br]00:05:57,130 --> 00:06:00,070[br]Also, the notebook is what we call modal. 9:59:59.000,9:59:59.000 54[br]00:06:00,070 --> 00:06:08,860[br]If the if - the interface has two modes, if the cell is surrounded in green, I'm editing the contents of this cell. 9:59:59.000,9:59:59.000 55[br]00:06:08,860 --> 00:06:22,300[br]We can also show mathematical expressions like y = mx+b, you put them in dollar signs and they're going to be rendered. 9:59:59.000,9:59:59.000 56[br]00:06:22,300 --> 00:06:30,960[br]I'm going to shift enter again. And now the math is showing up like math. 9:59:59.000,9:59:59.000 57[br]00:06:30,960 --> 00:06:37,410[br]When it's blue, when the cell is highlighted in blue, we're not editing the contents of the cell, but rather we are moving around cells. 9:59:59.000,9:59:59.000 58[br]00:06:37,410 --> 00:06:43,560[br]So the up and down arrows, keys like a will add a cell instead of typing a in the cell. 9:59:59.000,9:59:59.000 59[br]00:06:43,560 --> 00:06:51,690[br]Once we're on a cell, we can hit enter to edit the cell and escape to change back to the mode where we navigate cells. 9:59:59.000,9:59:59.000 60[br]00:06:51,690 --> 00:06:59,940[br]So now we have this notebook control as saves the notebook. Jupiter has its own set of menus so we can do a variety of things like again, save 9:59:59.000,9:59:59.000 61[br]00:06:59,940 --> 00:07:04,920[br]save the notebook with a new name. We can make a copy of The Notebook. 9:59:59.000,9:59:59.000 62[br]00:07:04,920 --> 00:07:09,510[br]We can also we're going to go submit the notebook - in order to give you feedback - 9:59:59.000,9:59:59.000 63[br]00:07:09,510 --> 00:07:18,000[br]I want a PDF of your notebook so that I can use blackboards, PDF markup tools to give you feedback on your assignments. 9:59:59.000,9:59:59.000 64[br]00:07:18,000 --> 00:07:27,810[br]So, Jupyter has the direct ability to create a PDF, but unfortunately requires an entire LaTeX installation. 9:59:59.000,9:59:59.000 65[br]00:07:27,810 --> 00:07:32,160[br]An additional software on top of that in order to go from a notebook to a PDF. 9:59:59.000,9:59:59.000 66[br]00:07:32,160 --> 00:07:36,450[br]So what instead we're going to do is we're going to go into the notebooks print preview. 9:59:59.000,9:59:59.000 67[br]00:07:36,450 --> 00:07:40,560[br]So I clicked file on the notebook interface. I go to print preview. 9:59:59.000,9:59:59.000 68[br]00:07:40,560 --> 00:07:44,340[br]This shows a trimmed down version of The Notebook that's not interactive. 9:59:59.000,9:59:59.000 69[br]00:07:44,340 --> 00:07:51,200[br]It doesn't have any in the interface. And now we can print this version of the notebook. 9:59:59.000,9:59:59.000 70[br]00:07:51,200 --> 00:07:56,820[br]And we can print your browser is going to let you save as a PDF when you go to print. 9:59:59.000,9:59:59.000 71[br]00:07:56,820 --> 00:08:06,320[br]So we're just going to use that save as PDF. I'm going to go put it in my assignment's directory. 9:59:59.000,9:59:59.000 72[br]00:08:06,320 --> 00:08:10,660[br]Demo Notebook.pdf . I'm gonna dlose this window. 9:59:59.000,9:59:59.000 73[br]00:08:10,660 --> 00:08:14,050[br]Now, if I go to that directory, I'm going to see both my ipynm file. 9:59:59.000,9:59:59.000 74[br]00:08:14,050 --> 00:08:18,850[br]That's the actual notebook file itself and the PDF file I just exported. 9:59:59.000,9:59:59.000 75[br]00:08:18,850 --> 00:08:23,650[br]I can look at the contents of that PDF file and it looks like we expected. 9:59:59.000,9:59:59.000 76[br]00:08:23,650 --> 00:08:29,200[br]We see the notebook title at the top where he wrote that level one heading. 9:59:59.000,9:59:59.000 77[br]00:08:29,200 --> 00:08:33,370[br]We see all of our output. When you're submitting an assignment 9:59:59.000,9:59:59.000 78[br]00:08:33,370 --> 00:08:39,610[br]what I want you to submit is both the ipynb file and the notebook file. 9:59:59.000,9:59:59.000 79[br]00:08:39,610 --> 00:08:47,830[br]So now. So when we're done with a notebook, then we go what it this file menu and we close and halt. 9:59:59.000,9:59:59.000 80[br]00:08:47,830 --> 00:08:56,500[br]And this closes the notebook tab. But it also shuts down the python instance that's running in the background to let us run the code in the notebook. 9:59:59.000,9:59:59.000 81[br]00:08:56,500 --> 00:09:03,430[br]If you don't close a halt, you're going to wind up with a bunch of python instances kicking around that you may not want. 9:59:59.000,9:59:59.000 82[br]00:09:03,430 --> 00:09:10,120[br]We're gonna see more features of Jupyter as we go through the class, including things to manage the python processes that are running. 9:59:59.000,9:59:59.000 83[br]00:09:10,120 --> 00:09:14,410[br]But now you've seen the first steps to how you can open Jupyter. 9:59:59.000,9:59:59.000 84[br]00:09:14,410 --> 00:09:22,090[br]You can create a notebook. You've seen notebook cells and you've seen how we can take this notebook and create output 9:59:59.000,9:59:59.000 85[br]00:09:22,090 --> 00:09:30,600[br]you're going to submit when you submit the results of an assignment. 9:59:59.000,9:59:59.000