 The schedule next up here is Jupiter and then I will well, then I can tell us about this Should I share a screen now? Is that okay? Yes, please do Okay, so how does it look like? Okay, I switched to you Great, I am going to Zoom in a little bit so that you can see the content better So hopefully this is okay Yeah, so in the following 40 minutes or so we are going to go through Jupiter and I will tell you what how you can use Jupiter notebooks to build your own computational narrative how you can use them in order to do Code development and when Jupiter is not a good tool So one of the really the pitfalls of Jupiter and some of you that have been using Jupiter before will find this very very easy So you can just sit back and relax for a while, but we do this so that everyone is on the web on the same page as we most teachers will be using Jupiter actually to to go through the teaching material and You should also be able to do to use Jupiter in the directory to do your own work after after this lesson And as I said, you won't be an expert, but but hopefully you will find something useful and A fun thing to mention here is that this Jupiter lesson is actually written as a Jupiter notebook and you can find the source on Github if you're interested and if you have suggestions for the lesson I mean you're more than welcome to create some issues on that repo. So So what is Jupiter? So Jupiter is most known for for the Jupiter notebooks and the interfaces that Reasons of the Jupiter node and Jupiter lab and it's Jupiter lab, which we are actually going to use today And the nice thing about it is that in your Jupiter notebook you can have both the input and the output of your code and Along with that you can have documentation and that's very useful, especially if you are if you want to share your code To someone else because you can have a very descriptive Text and you can interleave both the text and documentation. Sorry Text and and code into one Notebook so that you can be in your own computational narrative and we'll go for some examples of that and the Jupiter is great when When you want to explore data When you really want to do interactive Work and it's also great when when you are teaching or you are presenting your results to others So while we use Jupiter First of all, it's a good way of of presenting Python code and also it because it minimizes the differences between different operating systems So we want to make this as smooth as possible for everyone following this course So, how do we work with the Jupiter notebooks? so I'm going to use the Jupiter lab interface and The way I will do that is go to a terminal. I'm going to activate Conda as I do not activated by default in my on my computer. Maybe some of you do that so Then you can skip this step simply. Yeah, and So When I yes, yeah, this is the standard anaconda activation Which you could also do through anaconda navigator. I believe So our basic idea is that I believe it's that Jupiter sort of the standard interface Not for everyone that uses Python but for this course. So we hope that everyone's able to get it working Mm-hmm. And this is like simple enough that we don't have to worry about installation issues So, okay. Yeah, sorry. And you have the mini conda I mean, you can of course use that and I will not be using the base Environment, I will actually switch to the one that I have created for this course Then we'll just type conda and list to list of my environments. I Only have two on this laptop and then I will just conda activate and the name of the environment and Then I am good to Open my Jupiter lab. I'm sorry and So this is going to open a browser I Can also choose Which browser or I want to open this in by copy pasting these HDD Link I Will as I have already opened it. I will just use this one. So I'll move my windows a little bit Okay, so what what what do we have in the browser window? We have a menu bar on the left contains the what some browser for the file browser I see all the Notebooks I have when I Well in the directory where from I started Jupiter lab. There are some There is a tab for the kernels That I have open right now is none because I have not opened any I any Jupiter notebook and And there is also a table of content. What this is is actually so if you write the markdown Text with different levels of indentation, then you can actually scroll through different parts of the Jupiter notebook in a very Easy way by just picking on that. I will show you later on when we actually have a notebook open And then we also have extensions. I will move this to the side now So that we have more space in the main window. So the launcher I see Some icons basically there are icons for for different What notebooks based on different? Kernels that I have installed on the system in this case I have a Python 3 What does that mean? So when I when I open a Not based on this kernel all the code lines that I have in my Jupyter notebook are going to be interpreted by a Python 3 kernel so let's open that and Always it's a good practice to actually what? Save the the notebook that I am in so I will save it as let's say first Jupiter Okay, same and then I may see that what we are we have a very first so-called cell in this and I can Have this cell either as plain code or I can use for example markdown just as we use in the hack and lead To write some descriptive text and let's say I'm going to give it Be title so And I'm going to press shift enter in order to execute the cell So I will have a markdown output and I'm going to also create a new cell Okay, so and this markdown is the same markdown. We're using in hack and D exactly Yeah, and let's see We can also have There are more examples actually here in the lesson material how to format the text in a nicer way by using either italics or bold and And We can for let's let's do some examples for example for for coaxer. So let's do a simple for look Then another nice thing about the notebooks is that Syntax highlighting is amazing Of course, you can do that using other tools as well, but I find it very useful and Then it's also metric indentation. This is another great thing And then let's just bring all the numbers from zero to one and then again shift enter to To have the kernel Interpret this this cell and then I just have to output I can also do a print again. Let's say I want to print several Well, a sum of several numbers from From zero to four Yeah, again, she entered and then I get the sample all the numbers from zero to four including as As the boundaries non non-inclusive in python So, uh, if we have for example an object So I do not choose to print but I if I were just to type sum of range from Zero to four and I choose to for example do the same for Um, uh, let's say Zero to nine then what happens so shift enter again is I'm only going to print The value of the very last object if I want to print the value of both objects Then I would actually have to have a print Well taken for both of these or at least the way for the first one so Another nice thing about the Jupyter notebooks is that you can include magic in your notebook. What what does that mean? so for example if if It's very useful if you have a workflow that includes doing some bash scripting together with running Python codes, so I can use bash commands for by including a percent and and then I can have for example a bash command like I know, let's say Pw would be or Just throw the the current directory or if I want to use the bash script, which well, obviously will not fit into one line then I can have a A double percent and then I can type bash for a sum it may actually Be better if you have a stage instead of bash And let's write for example A small bash script. Yes, Richard. I think this might not work on Well, if this doesn't work for you don't worry because It's probably won't work on a windows computer, but it's not needed. Yeah I know it works on some windows computers, but we have We've had persons in the past which were complaining about this, but try a stage if bash doesn't work I cannot guarantee it will but But please try it out And then let's see just a Short for look let's print the sequence of numbers from one to three And let's just print the value of these numbers and then And then again shift enter to to execute this and now we see that we actually Execute we get the output for this bash script and this I mean magic is very useful when you When you want to Well, uh, when uh, when you want to work when you want to for example go into different directories in in On your laptop and and any different files or or Perform different operations on your files outside of your python script Okay, so if you want to see for example all the the magics which are available you can type this magic Okay, I didn't know of that, but that's uh, that's quite cool. I also don't know. I learned it fairly recently but what are your Magic comments favorite magic comments Richard Well, I guess there's Mainly it's time it I'd say which I think we'll Learn in the next lesson. Actually, I see it in exercise So we actually have it in the second exercise It's actually it's very good Good timing for that. So we'll we'll take like 15 minutes for exercises And uh And it would be great if you do exercise one two and three the exercise number three is optional if you know If you've been using Jupiter before then you will find these first exercise very very easy So you may just skip it, but we link the we link Sorry, we let the link to the exercises in the hack and the So please do one two and optionally free especially if you have been Using the Python Jupiter a lot before and I I would just like to Say what you should do in the second exercise. So The idea is to print out the Fibonacci numbers And what the Fibonacci number is well, it's The Fibonacci is a series and the number In in the series is the sum of the previous two numbers There are many Ways you can solve this exercise and it's fun if you actually share Your solutions with with your colleagues or maybe In the hack and D Doesn't have to be one solution But but it's nice if you actually time Your different solutions and see which one is fastest Okay, so um Okay, good So half an hour I will switch to hack and D here minutes for the exercise 15 minutes. Sorry So now during these breaks as you can see there are the Um We put an exercise note And it has the link and the instructions and another poll where you can Ask or you can say your status um As usual the questions continue At the bottom of the page And this is until 45 I believe Yeah, okay, so we will hide ourselves now and see you in 15 minutes Good luck. Keep asking questions and bye Screen there you go Hey, then spend my life now Yes Okay, great. So um Before we report in this session, I just want to Provide a really quick solution to the Fibonacci exercise And especially a very nice Assignment that that one one can do in Python. So, um Um What we start with is a uh Initialization of the amb variables. So the very first two numbers of the siponacci sequence and then Let's say we want to print the very first the Well nine numbers in this sequence that I can choose is to print well a and then initialize Um The value for uh for the next number as the sum of the two so so the new a is going to be the previous b And the new b is going to be the sum of the All amb so Basically, we are going to have this sequence zero one the sum of zero and one and then the sum of of the ones and so on And um, if I want to time this For example, I want to have the All the numbers in The first one million of the pannachi numbers. I can use the time It magic, but please comment out the print statement. Otherwise, we are going to get an error And what the time it will do is compute this sequence of code Several times in this case Seven times and it's going to uh print the The fastest run monty's seven and you can also specify options. For example, there's our 10 if you wanted to do for example 10 rounds instead And um And uh with this let's uh, let's um go through some advantages and disadvantages of jupiter. So when Do you want to use jupiter? So it's great if you want to edit Check and then re-edit your code in an interactive Way instead of like Running it from the command line and opening it maybe in a terminal. You can just do everything in one in one window and As we said, it's nice that you can interlay both the code and the descriptive text I should also mention that you can use many different kernels instead of python I think there are something like more than 100 kernels available. So you can use Use it. For example, if you you if you run C code or photon code or Julia Really there are lots of and lots of kernels And um There are some nice examples. For example, the gravitational waves Notebook which is publicly available It's nice that you can use it as a as a teaching tool You can actually also create the slides from jupiter notebooks You can do some googling for that. But when is jupiter not a good idea? So it's not so useful if you have a modular code. You can still do some modularity with jupiter lab, but it's not ideal Um, it's not so easy to test And they can be version control, but it's not It's not I mean, there are some limitations still And Also, you can change the code after you run it and Well, this makes debugging a bit hard and they can Result to reproduce reproducibility if if you are not being careful But always make sure I mean you have a clean notebook and then and then you You reset the kernel and run all cells before you show results And what this reset of the kernel does is actually going to reset all the variables Of Of the code and then run all the cells one by one Okay, so this is what I wanted to say about jupiter richard. Would you like to add something? uh Not really my hands have been a little bit full right now, but um Yeah, then I think we go into a break. Yes, and uh We come back at 10 past 10 or 10 past 11 if you are in finland And we continue with numpy It's looks like it's 10 minutes So a little bit shorter Mm-hmm Three minutes past the hour four minutes past the hour. Mm-hmm. Let's do that. Okay Okay, thanks everyone. See you soon Bye