Learning Python Programming A-Z with Real World Simulations | Alexander Hagmann | Skillshare

Playback Speed


  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x

Learning Python Programming A-Z with Real World Simulations

teacher avatar Alexander Hagmann, Data Scientist & Finance Professional

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

68 Lessons (10h 11m)
    • 1. Course Intro

      2:14
    • 2. Installation of Anaconda

      8:01
    • 3. Opening a Jupyter Notebook

      9:29
    • 4. How to use Jupyter Notebooks

      14:00
    • 5. Python Intro

      2:06
    • 6. First Steps

      8:57
    • 7. Variables

      8:22
    • 8. Data Types: Integers & Floats

      8:05
    • 9. Data Types: Strings

      9:59
    • 10. Data Types: Lists (Part 1)

      8:04
    • 11. Data Types: Lists (Part 2)

      18:24
    • 12. Data Types: Tuples

      6:29
    • 13. Data Types: Sets

      3:35
    • 14. Operators & Booleans

      9:39
    • 15. Conditional Statements (if, elif, else, while)

      12:01
    • 16. For Loops

      9:12
    • 17. Key words break, pass, continue

      5:31
    • 18. Generating Random Numbers

      6:19
    • 19. User Defined Functions (Part 1)

      9:21
    • 20. User Defined Functions (Part 2)

      7:16
    • 21. User Defined Functions (Part 3)

      8:17
    • 22. Visualization with Matplotlib

      15:20
    • 23. Class Project 1a (Sticker Album) Intro

      9:32
    • 24. Solution 1

      10:16
    • 25. Solution 2

      11:52
    • 26. Solution 3

      10:23
    • 27. Solution 4

      13:09
    • 28. Solution 5

      8:32
    • 29. Solution 6

      6:37
    • 30. Solution 7

      15:58
    • 31. Class Project 2a (Princess) Intro

      2:40
    • 32. Instruction & Hints

      1:58
    • 33. Solution 1

      9:43
    • 34. Solution 2

      7:08
    • 35. Solution 3

      4:13
    • 36. Solution 4

      4:42
    • 37. Solution 5

      6:47
    • 38. Solution 6

      10:30
    • 39. Solution 7

      13:29
    • 40. Solution 8

      13:12
    • 41. Introduction to Numpy Arrays

      7:03
    • 42. Numpy Arrays: Vectorization

      8:49
    • 43. Numpy Arrays: Indexing and Slicing

      6:49
    • 44. Numpy Arrays: Shape and Dimensions

      5:33
    • 45. Numpy Arrays: Indexing and Slicing of multi-dimensional Arrays

      10:36
    • 46. Numpy Arrays: Boolean Indexingx

      5:36
    • 47. Generating Random Numbers

      8:06
    • 48. Performance Issues

      6:17
    • 49. Case Study: Numpy vs. Python Standard Library

      6:49
    • 50. Summary Statistics

      6:38
    • 51. Visualization and (Linear) Regression

      12:00
    • 52. Class Project 1b (Sticker Album with Numpy): Intro

      3:45
    • 53. Solution 1

      10:43
    • 54. Solution 2

      12:14
    • 55. Solution 3

      9:18
    • 56. Solution 4

      18:52
    • 57. Solution 5

      14:01
    • 58. Solution 6

      18:22
    • 59. Class Project 2b (Princess with Numpy): Intro

      1:44
    • 60. Instruction & Hints

      2:03
    • 61. Solution 1

      13:15
    • 62. Solution 2

      13:13
    • 63. Solution 3

      7:44
    • 64. Solution 4

      9:48
    • 65. Solution 5

      10:05
    • 66. Solution 6

      7:27
    • 67. Solution 7

      21:27
    • 68. Summary and Outlook

      1:08
  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels
  • Beg/Int level
  • Int/Adv level

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.

171

Students

--

Projects

About This Class

Become a Python Programmer and acquire one of today┬┤s most requested skills!

This course is designed to make the first steps in Python for complete Beginners very easy. Everything is explained. From installation to the first lines of Code until more complex concepts.

After we have successfully completed the first steps, we will leave easy toy examples and move to more complex real world projects. There is no better way to learn and master coding than with real and comprehensive projects!

Learning by doing is always the best way to learn coding. Therefore, I have prepared instructed and interactive Class Projects. You will have the opportunity to start coding on your own with some hints and instructions from my side.

Meet Your Teacher

Teacher Profile Image

Alexander Hagmann

Data Scientist & Finance Professional

Teacher

Hi, I am Alex. As a Data Scientist and Finance Professional I am predominantly working on Data/AI -driven Finance Projects. Currently, I am passionate about developing Machine Learning-, Artificial Intelligence- and Automation- Solutions for Investments / Financial Trading.

See full profile

Class Ratings

Expectations Met?
  • Exceeded!
    0%
  • Yes
    0%
  • Somewhat
    0%
  • Not really
    0%
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.

Transcripts

1. Course Intro: 2. Installation of Anaconda: hello and welcome back to our costs. So now we are installing our pricing environment, and there's actually no single solution for setting up Dyson, and they're required. Add on packages. So there are many ways to do this, and we are using the free and a condom distribution. So the Anaconda distribution is, so to say, and all around Caffrey package for everybody who is new to Price and as it almost contains , everything that we will ever need, actually, and Anaconda is a strong focus on data science and has more or less all data signs packages already included. So we do not have to install add on package separately, which is very convenient for us and in the sense we can minimize on the installation steps . And they are insulation itself. Is that pretty into a different, straightforward within a Connor and also updating our environment. It's also very comfortable with on a condom, and in addition, the inductive stupid and up book is also already included in the Anaconda distribution, and the Jupiter notebook is actually our coding environment where we will spend most of all the time when we coat. However, the advantages off on a conduct comes at a cost, so the download size is quite large and are we will download a lot off Eddins. That's probably really will never need. So more advanced years aside, wise to customize them that type of environment. So but for our purposes, it's no best to use in the all inclusive and a condom distribution, and therefore we are now opening our Internet browser, and we are searching for the Anaconda Web side. Then here we are going to products, and now here we can go to the Anaconda distribution, the most popular price in data science distribution. So now and here you can see here we have to be on a conduct 5.3 installer, and they download options for Windows for Mac and for the nooks. So I'm going to Windows as I have a Windows machine, and you can also see that there are two options. So we have pricing sweep on seven version and price in 2.7 version and 3.7. It's obviously the newer version and latest version which we will use. So the versions 3.7 and 2.7, are in some cases incompatible So if you have a legacy code in 2.7, and if you want to use them this it might make sense to download Russian 2.7. But as we are producing brand new code we are using here off course and the latest version 3.7 and tomorrow we have from the option for the 64 bit version and the 32 bit person. And if you do not know which version to install on your machine, we can go to the assistant control panel. So let's search it here and there can checking the system types. So here we have 64 bit operating system, and the general rule is, um, that actually on your machines and Windows 10 round on 64 bit. So I think you could also use here the 64 bit. But please check before and before we go under through the insulation. Let's go for a quick tour year on the Anaconda page so we can check which packages are included in our download. So that's select your 64 bit windows, and you can see all packages or libraries, which will be downloaded within the Anaconda installer and actually so here can see a one live reissue Tyson 3.7. But this is only one off many packages which are downloaded. So, for example, we also have the pan US library here for handing tabla data and high level data structures like time serious. And for example, we also have a very powerful man pie pickets. So here this so number is very useful for large in America, Data on operations and they are also we have, for example, is the CYP I package for scientific computing and met plotless package for Megan plots and visualizations. And they are many more actually. So we will use many off these packages. But off course, many Revilla typically you never use, but this is OK. All right, so let's go back. And we can also have a look at the anaconda documentation. So here you get very useful information on the installation, for example, so he can go. If you have some Lennox there, you can see detailed information on the installation process here, and that's also hear information updating and uninstalling Anaconda and the user guide. So you're getting started with Anaconda, your first pricing program so we are going through the major steps together, but for more information, feel free here to browse them through the economy. Pidge. And let's go back to the download. So I haven't been those machine. I have 64 bit. So let's click here and let's save it, for example, on my desktop. So then let's download here the anaconda installer so you can see a tests 600 megabytes, so it will take a bit three minutes. So now we are finished with the download. And yeah, we can go now here to our desktop. And here we can see the downloaded file and yeah, we can run it here and now we can hear set up and install the Macondo environment. So let's click next. Okay, we have fear the license we agree and installing just for us. So this is recommended here and here we can choose, um, the fold of every year want to install Anaconda and by before it's in the user's folder. So I would recommend you to just install it in your users Fuller. But actually you can tourists or whatever for that you like. So let's click next. So now we're installing and uninstalling to take a little bit time. All right, so I come back. So our download was completed. And let's click here next and here. I asked you if you want to download. Also visuals did your coat. So we skip it here and for the time being. Now we don't want to learn more about the anaconda cloud and learn how to get started with Anaconda. So we finished. Now here the process and we have also finished your our sessions. So in the next session, we will open our very first to bid a notebook so hope to see you there by 3. Opening a Jupyter Notebook: hi and welcome back to our cost. So no. As we haven't start the anaconda distribution, we can open our very first to build a notebook where we can write and run our python code. And there are actually two ways to open a stupid A notebook. So first off by a be on a condom navigator. So let's search for the anaconda navigator and you can see it. Here s an EP. Yeah. Opening a stupid and open quietly and a condom Navigators actually a bit more convenient and more user friendly than the second option, which we will see later. All right, thanks for installing. Okay, Don't show again. And here we see different eps And what we are interested in this in the tribunal notebook. And as we can read here, the tube in a notebook is a Web based, interactive computing notebook environment where we can edit and run human readable doc Slide describing the data analysis. Yeah, so easy votes, we can actually use Trippett a notebook to write and run our code, but also you can use it as a text editor and just write text and integrate images and visualizations and also html code and much more and in particular and data science to build a notebook is very popular because you can do your data analysis and write your coat and also use it as a text editor and describe and say whatever you are doing, actually, and also in research to bid a notebook is quite populist. So there are some researchers which actually submit their research papers as a two bit a notebook. All right, so let's launch our first trip, it a notebook and what Anaconda that's. Actually it opens the local serve, and I will stand up Internet browsers or here we on our Internet browser. Actually, however, we are not connected to the Internet, so we can also use them to build a notebook offline. However, that's the option to use it on a Web server. But, yeah, this is not a topic off our costs, actually. So now here we are on the Jupiter dashboard and the surface like a home page for our Jupiter notebooks, and the main purpose is to display our notebooks and fights in our current directory. And depending on which photo you installed Anaconda before we can see here the folder structure off. Yeah, the photo value and start Anaconda. And in my case, it waas here the use of photo. And actually, you can see here. So this is actually the same photo structure. So to build a notebook actually makes your reference to our users for that year. All right, so let's open our first to build a notebook and therefore we're going here to New and we are opening a Paice and three notebook. So here we are on the notebook and festive. While we can change the name off our notebook if we go here toe untitled and say, Okay, let's call this notebook test and here we can rename it. So now our notebook, His name is test. We can also change the name by going here to file and rename. So this is the same. It can also name it. That's a test one. And now we can go into our first cell. So this is a coding cell actually read become right. Our code also, you just text and you can see here which mode we f and this is now set to code. So we can all code a bison coat here. So Let's say we tried to use Python s a calculator. So one pass one. And now we want to run. Now execute our code and they're actually four options to run our coat. So option number one is by just clicking here. Run and there can see the output are the result of our code is too, so we can see here our cell. This is actually the input toe our pace and Colonel. And here you can see the output off our coat too. And now we can go to the next cell and for example, Calculator three plus three. And the second option to run the cell is by just clicking here and no surprise in the output of six. And we can run a ceremony double time. So that's run again. Our first cell and lets you It's then the third alternative. We can press shift, enter here. So again we get to and the shift end of Iran the cell, and then we're selecting automatically in the next cell. So now we are here in our cell too, and let's go back to our first cell here. There is another option to run the cell and three, the keyboard shortcut I'd enter. You can run the cell and then insert a new cell below, so lets them run the cell with I'd enter and there you can see we're from the sell our POTUS again to and now be inserted in your cell here and here. We can calculate, let's say, two plus two and actually fifth and the last option to run the cell. It's by control. And so let's tap control enter and there you can see we get the output for But we are, Yeah, stay in our current style year. So we are not creating in yourself. So we have five options to run the cell. And depending on what we want to do as a next step, we can either go to the next cell with shift enter or we can create another cell with Ender . So there's a lot of flexibility. All right, so once we have finished with our code, we can also a safe our two bit a notebook by clicking here on the safe bottom, and we can also save our troop eternal bakir safe and checkpoint. And then we can close our Jupiter notebook. And here you can see this is now our Jupiter notebook fire. And this is your knowledge dashboard. And also, if he opened here, our user fire. We can also find here the Jupiter notebook file here in our users folder and the green I can assess and that the stupid a notebook. It's still running. Even if you have closed it sotto really close it. We have to go here on running, and here we can see that still one notebook. It's running, so we have to shut down it. So it's not enough to just closer at the Jupiter notebook. So we have to shut down it here under running, and now you can see it's black. All right, let's close here. The trip it a notebook dashboard. Okay, quit. Yes. And before I said that they are two alternatives to open a job in a notebook. So the first alternative is via the anaconda navigate, and the second is fire in a can prompt. So let's search for it. And here you can see the conduct from, and it is a kind of a command style. So the commanders, actually the primary interface for managing installations off various packages so you can actually query in search. I conduct packages like a lump I o r pandas, and we can check the current a condom insulation. And we can also create a new environments and install an update add on packages to our existing environment. However, before I said that the Anaconda Navigator with them, the graphical user interface is a bit more user friendly and convenient because you don't have to enter manual commands. So what do I mean with manual command? So if you want to open a shop in the notebook here with the anaconda from we have to step in, you're Piter no book. And then if you press end up actually also our to get a notebook, dashboard opens here. So here we can see our test Jupiter notebook, we can reopen it. And here we can see our tube in a notebook test one. So there to race to open our Jupiter dashboard. So either via the Anaconda Navigator or by the Anaconda prompt. And yeah, it's actually a matter of taste what you prefer here, and you can do whatever you like. All right, so now we have finished with this session, and the next session we will have a deeper look into the YouTube it a notebook c thereby 4. How to use Jupyter Notebooks: hello and welcome back to our costs on this session, we are going a bit deeper into the most important modes and functionalities off Jupiter notebooks. Also, we will have a look at the most frequently used keyboard shortcuts that makes actually our life easier and more efficient. However, with on your things them, the best and fastest way to get the familiar and comfortable with stupid notebooks is off course by practice and coating on your own, you will see after a few hours off, working with stupider that it's getting more and more intuitive. All right, so nevertheless, I want to give you some good Hinds and help for the start. So let's open a Jupiter notebook with the Navigator, and we want to create a brand new tube it a notebook, and we could call it test to. And let's start with Nehisi Coates. So let's calculate one plus one, and we run the sell by pressing shift and earth. So now we are on the next line, and here we could calculate four plus four and also execute the South by pressing shift enter. And in the last session I said that when we are here in this cell. We can see here that the setting is code. So if we start writing, we are actually riding Paice in code and we can change this toe marked down. It's another setting, it's marked down. And this is simply a text editor. So if you know, start writing here and run the cell were getting Yeah, text, actually. And now we under new cell and you can see by before them the setting is to coat. But we can off course changed again to mark down and what we can also do. We can make article headings. So by starting aligned with the hash key and the space And then we're by writing a text we can create ahead of with them. Yeah, a lot of fun size. So let's run here. And that's maybe that's name here. Our head, uh, can a cool laser. And then now in the next century, want to create a sub Hedda and it's called the subheading. That's a edition festive fly. We have to make the setting to mark down, and then we press heskey and make a space. So now we have the same hierarchy. So the fund sizes identically nifty at here. Another hash Kia. The fund sizes getting smaller, so Edition could be a lower, hierarchical heading. And by adding more and more hash keys, it's getting smaller. So let's take to hash keys and run the server. And now we can also move our heading to the top off to better notebook by pressing here, move. Select itself up so we can move it here. Up also, the addition Jupiter Notebook has to Moz um so vast edit mode and the command mode and the edit mode is indicated by a green cell border. So if we go into the cell here we click into the cell. Then we see here a green cell border. And when a Cetus in the edit mode, yeah, we can type into the cell and a type of python coto our text. So here we can change from one plus 1 to 1 plus 12 Let's say, and then we can run this out and we get 13. So we changed the content off the sun in the edit mode, and the second motor command mode is indicated by a great cell border and the blue margin here. And when we on a command mode, we are able to edit the notebook as a whole, but we cannot type into the individual cells. So, for example, in command mode we can add and delete cells, and they make more changes to the whole notebook and that two ways from switching from the command motor, the edit mode. So either you go with our mosque Arza into the cell so we can see it changes from blue to green. And then we can go back to command boat by clicking here outside the cell so you can see here we are blue again in the command mode, and they also keep what's hard cuts for it. So we are now in the command mode, and if you click enter, we're getting to the edit mode and then via the edit mode and press and the escape key. Then we're coming back to the command mode. So what can we do in the command mode, for example, we can add a cell above ourselves so we can now press the key A for inserting a cell, a buff, and now here you have inserted a Saleh buff and let's go back to ourselves here. So now we are in edit mode, the press escape to go to the command mode and then we press on the BQE to insert a cell below. You can see we have no inserted a cell below and let's go down to our Johnson's cell here and the African Delete aside by pressing DDS. Ow! Now we have to lead in the cell, and they're also keyboard shortcuts to change and the setting. So now here. But before we have from the code setting and now we can change them the setting to mark down by pressing in the command mochi em there can see you now changed to mark down, and we can change it back toe coat by pressing the Y key so you can see it our way back to coat. And there are many more shortcuts and we can never look and also modify the shortcuts by going here to help and edit keyboard shortcuts, and there can see many shortcuts. So run cell and select the next sales shift and run the cell and staying in the selfless control. Enter and run cell and insert a cell below us. And so we already learned that. Then here enter to the edit mode by pressing enter. So again, all this rot cuts only work if we are in the command mode, not in the edit mode and what we also have. Furious inside Saleh, buff eh? And inset Sele, Bolo bhi and Change South to kowtow simply Waikiki and takes said to mark down This is the empty and how them anymore shortcuts. And it's a little bit of Meddoff tastes if in which shortcuts you're you want to use, actually, so it's completely up to you. So sometimes it's said for and in my opinion, sometimes not all right and what I also want to show you. We can actually store a value, Let's say five into a variable. Let's say a so equals five where we can actually execute a cell with a So this is called printing and now we get five because Christ knows them. A is five and what we can do now we can change our calculations a buff and say Okay, I want to calculate a one plus a So when this gets out six. And also, for example, here, I want to calculate for plus a. It's nine. Maybe I want to change here to two. Plus a gives us seven. Yeah, this is actually the good thing about Thibodeau notebooks and what makes the stupid and notebooks of comfortable and easy to use that, actually each Silas running independently from other sides. And here we can switch here from Seattle, sail around this, let's and then go back to our previous self, and we can see here on the left and yeah, the sequence, how we have from run ourselves. So I actually owe the cell this year line for then we executed Line five, then line seven and then line eight. And for example, let's make here something which price and cannot verify our price and do not know what to do with it. So let's say to class times three. So this is not defined in prison. And whenever we do something which is not defined in Tyson, then price in the drops us an aero message and you can see the comfortable thing about two bitter notebooks that we get an error message for only the cell, which s code that it's not defined. So this does, however, not impact the other side. So all the other sets Elsom gas still work and still show on output here, and this is in particular for beginners. Very convenient. Massive encouraged you to coat by trial and error. And you don't have to take care about making arrows, actually, because you only get an error message for the particular cell, and you can quickly edit your cell and change your error. So now here we know that two plus times says readers, not work, so we can quantify here, you know, we've changed it, and now let's assume we want to change eso A. It's not five, but let's say seven. Then we see us off the latest cell that waas executed a saline 11 and give you can see in line eight. So the output has not changed even if he changed line 11. Where we to find a seven someone lion eight. Where we calculate to plus a, this is still seven because before a waas five and 9 11 So the reassignment off a waas later than our line eight year and now if you want to update you output to our new way, we have to run the cell again. So now it's nine and we can see that the cell waas executed after the new assignment off a slow now line 12 should already contain them. The new A. So this is the very good thing about Jupiter notebook. So you can switch here from line to line and you can make errors and you can modify your aero. So no problem at all. However, in the end, we are definitely makes sense, toe, actually rearrange your code in a sequence. And that makes sense, actually. So now we should put here the assignment off A to the very top off our code. So a seven and let's say be rerun it again. And also here, the printing off A we can move up, then you re run it. Now we can also rerun all the other sets on our two plus A is nine. We can delete the cell here. Four plus a short than the 11 and two plus three is still five. So now you can see here we have a secrets from top to bottom at the end. That always makes sense to to rearrange the sequence and that manner, actually, and what we can also do here by clicking to Colonel, Then we can either restart Yeah, to say bison or the price and Colonel and Kia all output. So if you do that, you can see here. So there's no operetta. We have still the code in our lines, but the code is not executed. And now we can execute around the cells here in a sequence with shift enter. So now we have again the sequence from 1 to 5. And what we can also do we can do this and one step so we can clear output and run the sets again, beginning from line one by pressing a restart and run, Or so restarting the Colonel and running it again makes definitely sense, Um, from time to time. So if you have a very complex project with many lines in your stupid a lot book, so at some point in time, it makes sense to we rearrange the sequence and then restart your code again. So sometimes, yeah, there s a mystic or something, which which doesn't work. And you actually do you know why it's not working? And then it definitely makes sense to restart here. All right, So let's say few our notebook and let's close them the no procure. And we also shut our notebook down. And now that's one last thing I want to show you. So let's go back to our test to notebook. So before we shut down here the notebook and now we opened it again and we can still see here the output. However, our notebook behaves like the sets have never been run. So our variable A s Yeah, actually not starting pricing, and there we can try it by typing three plus a. So we would expect 10 and began error. Message Name is not defined. So will never be open or close notebook. So all off the variables and other things and they are not start. So whenever we open a notebook again, we have to go to Colonel and we start and run all the cells here. Well, we can see where the sequence from 1 to 6. And here three plus a works. And alternatively, if we open the notebook, we can run all cells here with just, um, going to sell here and say Ramo so here we don't have a sequence from 1 to 6, but still we have run or sets them from the top to the bottom. So now we are finished with our installation and triple A notebook basics and help You enjoyed it. And, yeah, CEO you in the next session by 5. Python Intro: hello and welcome to our price and basic sections. So first of all, let's open a brand new price entry to build a notebook. And in the next lesson, single built the fundamentals that you can learn everything that it's the required to work with and self our real world problems later on. So almost all of the concepts and that we will learn here in the price and basic section we will need and apply later in our comprehensive case studies. So this is the good thing in on our real about simulation case studies that more or less any important concept off basic Spuyten can be applied there. And we all know that the learning effect is best when we are working on renewable projects . So in the past and basic section, we are working exclusively with them the Tyson Standard Library. So that means them that with all functions that are by default included in the price in basic installation, and later in our course, it will import and work with them. The loan package numb pie, which is a very powerful and useful tool when it comes to scientific and large know Mary computations and also We will work this in the public library for making visualizations and plots, and that there are actually hundreds or thousands off Iran packages out there. And this is why price missiles popular because for every task in particular and the data science tech, there are many open source evidence, which makes life and price and quite easier. So by working with these Eddins, we don't have to reinvent the wheel every time by developing our code from scratch with basic patent towards. However, if you want to work serious and successful and pricing some, knowing the basics and being able to work with the place and send a library to its is nevertheless essential. So they're actually no shortcuts. And, yeah, however, it's a fun and interesting to work and with basic and essential coding structures, and you learn a lot. So I hope to see you on the next sessions by 6. First Steps: hi and welcome back. So first we want toe rename our Jupiter notebook from Untitled to let's say Tyson very thinks so. We are here on the pipes and basic section and before we start coding, you want to structure our notebook a little bit. So this is the good thing off stupid and notebooks and that we can combine code and text and festival, or we want to create a heading and therefore we have to change the setting off. Always said so. Here we can see. Um, it's in the coat setting and we want to create a heading, which is text, actually and therefore we need in the marked on setting and here we are already in the command mode and if you press in the MQ, we can switch toe markdown on. Alternatively, we can also switch to mark down by just here, going to the drop down menu and select markdown. All right, so now we can go into the cell and we want to create a heading. So we need to press and the heskey and then make a space and they're conceded the font size already increases and then we can write our heading. So let's call our heading Tyson basics. And then we can run the sell by pressing shift. Enter. So now here we have our heading and we are automatically in the next cell and you want to make a subheading and festival. Here. We have to select the markdown mode, and now we want to create a subheading. So we take to hash keys and an empty space. And let's say we want to numerator our sessions. So this is the first session about first steps so we can see with to hash keys. Our fun size is a little bit smaller than our header here with one hash key. So let's run here. So now, before we want to create our fast Kout, we want toe. Explain what we will do in the session here. That's against the deck markdown. And then let's explain in this session you better learn the basics. Oh, Price from All right, So now we are finished with our headings in our description, and now we want to start coding and before we are again, going to the command Multiyear and pressing the Beeb key a few times. So we at some lines here. And then we're going here into our first line and what we can do really can say, OK, we have a five year and we can just print out the five. So the in for this five and the output of our code is five. So five or simply five s, you can see here. Yeah, actually, we can use spices as a calculator to perform basic mathematical operations. So, for example, we can make in additions off five plus one, get six. And because of strict So, for example, five minus one gets us for and off course. We can also multiply five times two gets 10 and we can also make an exponentially ation so we can say five to the power off to gives 25. And we can also divide so we can say five slash is divided by two. And this guest 2.5 and Tyson death and the function tight and the briquettes you can pass an object like here, our number four or 2.5 and the function type checks. Then what data type? The object that was passed in the brackets. Yeah, it's actually. So let's try to find out what? Five. Which data type of this. And it's an indicator. So windage is just a number without any decimals, and we can also check the data type off 2.5 in 2.5 is a float object. So afloat Object has some decimals after the point here. So the type function Issiar the first example off a function in person so you can pass an object like five for 2.5 within the brackets off the function, and then the function does something with them. The object and, in this case, it determines and the data type off object. Now you could ask what is not checked on price, and everything is an object. Cost pricing is an object oriented programming language. How at this point, I do not want to go into details off object oriented programming. So what is important for years, actually that yeah, each elementary are working whistle, for example. Here, five for 2.5 is an object, and bison and objects can be off different data types of FIFA's an indigent 2.5 if they float object and different data types of different functionalities. But we will learn more about it in the next session's about India just floats string sense on. So what we can do now We can type something here in quotation marks. Let's say dark and it returns a stark. So now again, let's add some line services. Beaky. And if you check the type off dark, it gives us the strings of Dark is a string object, and string object is actually a sequence of characters from which was created within quotation marks. So my name is Alex, and I can just right here my name in quotation Mark. And this is a string also. Well, what does not work? We cannot just right Doc here. So this drops us in every message and tests and the name dark. It's not defined. So when the right doc here, without quotation marks, pricing, assumes that darkest live arrival, which Waas defined earlier. But yeah, it does not find any information on the meribel dark. So then it drops, um, an error message. And of course, you will learn later, boss about a rival lists and detailed. But now let's go on with the one more thing we want to learn. So let's assume here in a cell. We want to make two calculations. So let's say five plus two and then four minus one. And then if you run the cell, we only get the result off the last statement ourselves. So four minus one gives us three. But this does not mean that Tyson do not calculate. Also five plus tour and actually Price Industria Calculate five plus two. But we do not see it here in the output. And if you want to print, are many statements we have to use and the function print so print. It's also a function. And then the briquettes we can pass and statement, which we want toe see in the output. So, for example, five plus two and again we can take four minus one. And if you run the seven hour we get yeah, the output off both statements or five plus 27 and for minus one gives us three, and we can also pass both calculations over than the brain function so they can say print five plus toe comma and four minus one gets seven and three. But this is also an advantage of Jupiter notebook. If we only want to print. Let's say five. You can just type five and around the cell, and this gives us five. So we do not have to explicitly say here, please print me. Five So encoding environments other than Jupiter notebook, we always have to use the print function. But Jupiter notebook males here in this example. Okay, I should print five. So we do not have to explicitly, right print here in stupid a notebook, but it gives you actually the same result. All right, so this number the basics off python And then the next session, we will have a look at variable, so hope to see you there by 7. Variables: hello. When we come back to the costs On the last session, we learned about basic data types like indigenas floats and strings. And also we learned about basic operations like addition, multiplication and so on. And now in this session, we are introducing arrivals. So what does have arrived? Let's assume we have been in detail Object, Fife, We can print it off. And instead of having the Fife s the number itself, we can assign a of arrival. Let's call it a so a equals five and pies nomics internally reference that whenever we call a, um it's calculating fly for its it's returning five. So if you know, just print A we're getting five. So a stands for five. And as we learned in the last session, we can also print out a by calling the print function. So that's actually are the same. And we can also change the referenced. So if we say okay for a waas five, but now a seven you contest, change it so a seven. And let's check if a small seven and a seven hours so we can simply change our reference. So, before our reference Waas 252 the intraday object five and now a references to seven so we can change for the reference. All right, so let's introduce another Meribel. Let's call it B B equals two, and we can also print out B B is, too. And in the last session we have learned that if you want to print out both A and B and one cell, so by the four, to put a notebook only prints out the last statement or the last line that speed here. So if you want to print out bows, we have to call the print function friend a and be So now we can print out those seven and two. All right, so basically, we can do with arrivals the same mess within the just off loads. We can do the basic operations like Edition so we can take a plus B s nine a minus bi this five B minus a minus five. We can also multiply so eight times beer and become off course. You can also divide a divided by B and all. For example, we can assign the reside off a divided by B here, so it's 3.5 kind can assign a new of arrival. See to it. So C equals a divided by B that's print out CSL CS 3.5 and we can also check the data type off, see? So I would expect that it's afloat. Yes, exactly. And of course, we cannot only a sign of arrival to an Inter Traore and float. We can also assign arrival to a string object. So, for example, we have dark en ba can assign the Reiber d d close stock and off course print out D in Saudi. So internally a person makes a reference from the rival D to our string object dark. So do you stalk And we can also check the data Type off dear. And it's a string. So dark dog It's a string off course and the ideas referencing too dark and devious. Also string then and for either name we can actually make any name We we we want to have so we can say my favourite dork is Let's see it, for example and this works now. If I want to print out my arriba, my favorite doc, I can start typing my and by pressing the tab key supplies and automatically completes my Mariah. So my wife less is all that's called the tab completion. Surprising knows that Meribel caught my favorite doctors start internally, and whenever I start typing my then I can press tab and pricing automatically completes my arrival. So that's that's quite helpful, actually, when the rival list this is quite long, like here. In that case and what I would also like to highlight this and that I need the under slash year. So if it's just a space, my favorite dark, so that's that cannot surface arrival. So here it gives me an error message. So space space is not to find the assesses part off a varietal. Actually, I thought only wrecks in this way and also a string itself like, let's say, dark. A string like dark cannot be in our reliable. So dark equals Spike gives me a swell on an error message. Northen, interred or float cannot be in varietal, so let's say five equals spike. Let's say it also doesn't work. Button in detail can be part off in varietal, so let's say dark five. It's spike so that birds and they have one last thing. I want to highlight here. So let's assume I assigned to the arrival. E equals 10. So he's 10 and then I signed f equals e Sorry f equals E. So in this case, if it's 10 because East M and F equals S O f also must be 10. And now if I change years off before you referent was a reference to the object. 10. If I change u two, let's say 15 and I again check the reference off F efforts there tend, even if I before I referenced f equals s So what happened internally? So internally here and the object 10 watts created and then reference. And it was referenced to the arrival e And here when we say f equals here than internally a reference to the same object 10 watts created toe f. So with one object, enter to 10 and we have two references from 10 to be and to f. And if you change here, the reference to 15 internally a new object 15 is created and the reference for you was changed from 10 to 15. But there was no impact on F. So the reference from F Esther to the indigent object tend not to 15. So that's that's quite important to understand. You hope Ison works internally. All right, so that's it. So thank you very much. And yeah, I hope you tried toe. See you in the next lesson. 8. Data Types: Integers & Floats: hello and welcome back to the course some the last two sessions we learned already about the data types, indigenous and floats. And in this session we want to repeat and deepen our understanding off those two daily times. So first of all, we assign varietals to, let's say, five. So we assigned the arrival a to five and we assign be to the indicator to and we check the data types off A and B So I would expect to them that A and B are inter just yeah, that's true. Here you can see in didja indigent and what we already learned. I mean, Internet floats. That's both ordinary numbers where we can apply mathematical operations like Edition so we can add a plus B. We can at D plus a. So no surprise we get seven and both, uh, in both operations that becomes abstract. So a minus bi three. We can also create negative numbers. B minus A gives us minus three, and also we can multiply two in digest and get 10. And what We also already learned this, that by dividing into just be we get on and float objects. So if he de white a divided by B S 05 divided by two. We get 2.5 and we assign 2.5 to the varietal. See, so C is 2.5. And the data type off, see is a float object. And that's actually a difference between indigent and then float images, a number that can be written without fractional components. So five for two both don't have any any decimal, and in contrast, float object has decimal. So if you can see here, See has at one decimal 10.5 at this point, I want to highlight the different data types of different functionality and all that data types, if so called bid in methods are attributes. So actually, at this point, I don't want to go into detail off object oriented programming. But I want to show you the practical years off the so called methods and attributes. So let's have a look at the float, the float object C, and we can call the method as in disarray, show by pressing C dot And then, as in degeneration, if he execute the sale here, you can see that see as an inductive. A ratio is five divided by two. So this is called a method, because Python internally calculates something based on our object. Me at 2.5. So it returns the interational five divided by two, and we can also browse or search for build and methods or attributes by just Let's take the float si dot and then press tab. And there we can see what price in office us. So we have the Methodist Internet ratio and with quite a few methods and an attribute CIA. So, for instance, we can call the method as indigent and executed. Okay, so now prices checking if see as a float is an inter turned. Obviously, it's not an intern. Solid returns false. So difficult to our varietal B S B stands for for two. So it's season in Deter, And they are. We can call the attribute denominator and numerator. Yes, So actually it's quite, I mean, that's not not too much too much more information here. So, too, is made off the numerator two divided by one. So that's have not not too much helpful, actually, and we can also check here what other methods are attributes left by pressing the tab key bit lengths coming. Eight. It's not too interesting for us now, so I think we should go on and yeah, let's that's calculate 11 divided by three and assign it to the varietal dear gives us 3.666 And if you call now, the method is in disarray. So have to get quite quite, Um, yeah, it doesn't give us what we expected. 11 and three, because the flotus here by the fire around it after, I don't know the tense did it. So no, I mean, doesn't have too much here the two numbers, but nice to know, actually. And yeah, but we can also do. We can call a function on an object like DS or function like round so we can round our float object. Let's press shift Tab two c k. We can round a number, so it's Dia's stands for afloat, and we can also determine the number off digits. So if you take here one so we get come round our float object here to one did it and we get 3.7. So if you change it here to two, we get 3.67 obviously with injured in the just rounding doesn't make really sense because India doesn't have any digits so that we can also do. We can transform our flowed into an indeterminate calling the function and so int and then brackets D gives us the corresponding indigenous to the floaty and what Tyson actually does . It just cuts here. Mortgages. So it's the grounding if it's round, so we would get four. But it's just cutting here after the three, and we get Thean Deter three. And we can also transform an individual a stance for five into afloat and gives us 5.0 and there to raise to transform an indigent to afloat. So either we call the function float are, um, so let's check first off the type off five European indigent. And if you just press 5.0 placing recognises £5 eras afloat and even we don't have to press there. Also, only five point nothing gives us a floats up ice in the treats is other float and also here there to race to transform into jaw into a string so either by setting or putting five into quotation marks or by calling the S. T. R. function. So they're calling SCR Our Fife will be transformed into a string. All right, so that's the Samos here. Yeah, that's it. For now at this point. So that's not much more to say about indigenous and floats. And yeah, In the next session, we will have a people look into a string objects. So hope you enjoyed it and hope to see you in the next session by 9. Data Types: Strings: hello and they come back to the course. So in the last sessions he already got in touch with string objects. And now we dig a bit deeper into the strings. However, also later in our real world projects and our focus is not on string, so we keep it here. Start it's possible. So at the end of the last session, we transformed an individual five into a string by putting it into quotation marks. That's repeat this again. So we're transforming the industry five to a string, and this completely changes the functionality of the object. So before five plus two gifts seven. And now, if execute this string five so represented by sea plus two, you get an error message. So it says it must be a string, not an intra chest, so it completely changes the functionality. But what are strings, Actually? Well, strings are a sequence off Unicode characters inside a quotation mark, and this was treated like any other secrets, like lists or troopers, which we see later. And yeah, actually, we can, when we can put into a string many different correct us like numbers. Letter special characters like question marks and exclamation marks and so on, which we will see later. But before now, let's start with just yeah, signing, creating and string object dark and assign the varietal de. And also we create String Up the cat and signed the rival year. And no surprise if you print the types off D and you both strengths. And if you tried to add both strings as before, we try to apply the plus operator and see what we get here some place. And does it just come? Captain eights both strength. So D plus year gives Dark Kat in the FEMA at e plus D. We get cat dark, so it's just concoct in a ting both strings. And if you try to obstruct began error message so minus the finest operator is not defined for strength. And if you try to multiply two strengths, we also get him error message. And if he tried to end, let's say an interpreter to a string that's also era message doesn't work. But if you transform our intention five into a string, then of course we can add this string to another string like a kid while dark. So we get dark five and it works also the other way around. So we get five dog. And if you try to multiply a string with an interpreter like five, we get in string with five times the copy off dark. So we get dark, dark, dark, dark, dark so D A stock and times five. It's just common coordinating five times stock, and you can also do it the other way around and get the same result So it doesn't matter 50 times five for five times. D. However, if you transform the indigent five to a string and try to multiply it with our string dear off course, you get in a row message, and also we can concoct innate many strings to one string. So, for example, we have to string. I may have censoring half blistering five in the string darks and thought we get the statement. I have five stocks. So as you can see here, we need the empty spaces here. If you forget these, I was sent in, so our statement looks a bit a little bit unreadable, so person can also handle spaces here, and spaces can be part of a string. So that's it's quite comfortable here What I would like to introduce here it's string formatting. So we are assigning the string dogs to the arrival animal and the institute six to amount. And then we print the statement. I have Carly brackets. Carly brackets thought, end off the quotes and then I apply it to the string, the method format. And inside the brackets of form it I'm I'm defining for which the curly brackets are placed . Hold us so. And if I execute the cell here, I get I have five talks. So what The method dot former actually does this that it fills the place, told us the secret since as to find within the brackets here. So So the first Carly bracket will be replaced by the amount, and the second curly bracket will be replaced by animal. And then, for example, so yesterday I had six stocks. Now, today I have not dogs but cats and not six. But let's say eight. I updated. I got I have eight cats, and this is quite helpful. Actually, if your arrivals are changing many times and you want to automate your statement, how many cats or dogs have currently? So that's that's quite helpful earlier. What you can also do. You can delete a whole string by calling the Dell function. So inside the brackets you put the objective so the stands for dark and if he deleted. So if you then try to print dear so pretty is not defined here. It says. So now we have to redefined year again. Not our day is again, Doc. Before I mentioned that a string is a sequence off Unicode characters and yeah, you. By calling the length function, you can count the numbers off items in the string. So with Devi will expect three items the OMT all right, and we can also count the number of items on a number of characters and statement. It's 14. So let's go back to our statement. So a statement. This I have five talks. So then becomes we have to count actually all characters. So also the space character. So 1234567 89 10 11 12 13 and also the 130.14 characters. So that's correct. Here and before we set different data types have different functionality, so we could call the length length function on strings. But we cannot call the links function on inter Joseph laws. If you try to do so, you get an error message. So object type in Georgia has no length. Faction or the length function is not defined. And earlier we saw that Inter Justin Flows. They have bid in methods, attributes, and this holds also true for string objects. So sing objects also have pre defined, orbited in methods and attributes, and one off. This is the upper method. And let's execute the upper method on our string objects. Statement on. And that's Prince Statement. Now you can see all items are our characters are converted to uppercase. So what? Actually the upper method us it just yeah, it converts or characters to the upper case, and we can also call the opposite method dot lower. If you do so we get I have talks. Um, here we can see our characters are your lower case, and there's another method called capitalize in the feet called this method On statement. We get I have docks, but the I here you see a skeptical allies, so the first character in our string is capitalized with them. The capitalized method and there are many more building methods for string objects. And if you like, you can look at the documentation or test press CIA dots tip to see what price in office here and you can just try out. But what happens if you call the the methods and attributes here? But for now, we are finished here with strings, and we had over two lists and Desam function called list, which transforms a string object into a list so we can try what happens here. So our statement is I have five docks and we transform it into a list. And what we can see here We have all singer characters separated by a comma inside scrap racket briquettes, and this is called a list. So if you check the type type l Is this a list? And then the next lesson we were have a deeper look to the list object. But so for the time being, this is it. And yeah, I hope you enjoyed it and see you in their expression 10. Data Types: Lists (Part 1): Hello and welcome back to the cause. So at the end of the last session, we created our first list. So what is a list? A list of another object or data type that stars multiple other objects. So, for example, a list can store objects off different data types like India just floats, strengths and so on. So let's start creating our first or second list. So we are opening in Spab brackets and yeah, we're storing for Inter Inter Just wanted three far separated by a comma. And then let's see what happens if you're on the cell so it returns back. Yeah, a list with four elements. 1234 And if you check the type off l when we get back that it's a list. And as I said before, we can store elements off different data types. So, for example, here we had into just now in our next list em, we store three float elements. So let's execute here. The cell and we can see here we have a list em with 1.52 point four and 3.7, and also we can create a list with string objects so for example, list en We have a dark, we have a cat and we have a mouse, and we can never list where we have different data types. So, for example, list oh contains until one. It contains the flow 2.4 and contains and string object dark and it's no problem it Rex, and you can think off list like a backpack. So, for example, if you go hiking, you put into your bag a bottle of water sandwich to T shirts and maybe a football. And, yeah, everything fits into your back. And that's the same mess with the list. So you can, yeah, actually put everything into a list and started there, And we saw in the last session that we can transform a string into a list. So, for example, we have the string. This is a string, and we can transform us by calling the function list, and we get back a list with all single elements off the strings. O. T H. I also empty space and also hear the exclamation mark. So let's check again what data type we have here for our list P. And of course, it's a list and We can also count the amount of elements in the list. So in this case, it's 17 and yeah, we can. You can count here. And yes, we have before. Also the empty spaces and the exclamation marks. I was a string and loss account for for the links. So next we can take the arithmetic some off all elements. So we take the some off L. That's Jack Ellis in the list with for Inter. Just so are some of for Inter. Just shoot work. So the some off 12344 is 10 and we can also take the some off list em. It's sick again. I am here. It's the list of its floating floats, so this would also work. So it's 7.6 and we try to take the some off list end. So list 10 and listen. Contains strings. So the sum of strings. I'm not sure if this works. No, it doesn't back, so it gets lesson that wrong. So let's get back to list l in list L there for in the just 1234 and what we can do with Assam. Method build and method for lists called append. There we can upend another element to the end off the list. So if he upend five, let's see what happens. So then we get Becker list with a Fife in the end. And if you repeat this process and call a pen one more time with, um, the element five, so we get another five. And there's also a method that accounts of the number of occurrences off one element. So if you want to count the number for currencies off element five, you can do so by calling the method count. And there we have two. So we have two times the element Fife. And now we can also remove an element from a list by calling the method remove and in brackets we have Theo Element. We want to remove event. So we have here. We want to remove from five. We have two times five on our list, and then the method remove removes the first occurrence often element. So let's check. Okay, so now we have only only if the five only ones and we hear can account again. The five and it's so we have one time. We have five on our list, and we can also reverse the sequence off our elements by calling the method reverse. So let's do this. And now you can see so before our the sequence off our list wants 12345 and no way. I have from the reverse sequence 54321 And there's also a method called Sort where we can start our list. So in the case where we have only Inter just on our list, pricing automatically sorts from from low to high. So let's see what happens. And that's also the possibility to reverse the order with the message thought So. There's a para media called rebirth and it's by default. That's set to follow us, but we can set it to true and now we have them in the reverse order and we consulted again to the ascending order. So beginning with one all right and what we can all so that we can add a list and a list. So we have from L. A list containing 12345 and we can get another list containing three Inter just 67 and eight. So now we have a combined are a concatenation list. 12345678 So we have eight elements now list and what is not working? Actually, so we cannot suspect to two lists, so that's gets us in a row message. All right, so let's go back to our initial list. So we have a list with five elements and let's try to multiple apply our list, Um, with two. And let's see what we get. So actually pissing here it can, captain eights, many copies. So in this case, two copies and yes, you can see this is not an element wise multiplication. So if you see at times, too, you could also expect that one is multiplied by two twos, multiplied by two so that in the end, to get 246 a 10. But this is not the case. So this is not how lists work. So we just get many copies off the same list here. And, uh, for the sake of completeness and division off list with Inter just not possible. All right, so that's that's it for for the time being. And I hope to see you again in lists parts two or so see in the next session by 11. Data Types: Lists (Part 2): welcome back to Part two off our introduction to lists. So in the last session we learned about the general structure, off lists and how to create lists. So now in this session, we learn how to select single and multiple element elements from a list and how to manipulate and change elements off a list. And we also learn how to slice lists and make sub selection off lists. So what now? Let's start with our list, which we already know in Our first task is we want to select the very first element off this list in the general rulers that elements of a list can be assessed. This spare records. So we take Alice back cricket and let's try to get them the very first element off the list . So type in one and let's see what we get. So we get to so to this, Um, yeah, actually, the second element. So how do we get now? Our first element And yeah, the unders, actually, that we have to type in zero as index, Let's see what we get. So if he type in zero, we get the first element here. It's one, and this is neither a mistake. Oh, our special or strange behaviour off bison. Yeah, it's common. Commonly seen pattern in programming or coding that you have the so called Cyril based indexing. So the very first element off a sequence has the index position zero and then the second test, the in expression position one. The third element is the an explosion Position two, and so on. Now this is a general rule in many programming languages. So once again, it's quite Cyril based indexing. All right, so what if now we want to get the fifth element off? Our list of the fifth element is five. So, consequently, we have toe input, the index position for and now it's Let's return us five and this is true eternity. Vly, We can also assess the very last element off a sequence by typing the index position minus one. So minus one gets us the very last element of a sequence. So in this case, that's life. And the second very last element off our list can be assessed by the index position minds to and consequently the first element off. Our list can also be indexed by minus five so that two ways to index our lists. So that's the Syria based and next thing starting from zero so hour. Element one, this has in exposition zero in next position one in next position to in next position four . Sorry. In next position three and index position for and the alt Fay would be to have index position minus one in exposition lines, too. In next position, minus three in next position minus four. And next. Is this one minus life. So and this holds true for you almost every kind of sequence or not only for lists, but also for two parts which we see later, or for umpire race and so on. So, yeah, this is a very important and basic basic rule here. How toe to assess elements off a sequence and what you can also do. You can do it the other way around so you can foreign given element. Let's say five. Tyson can give you the index position so and community the method index and let's type in five. So we would expect the five fists at index position for, so we would expect here, too, return four. And that's correct. This is generally mutable, so What does it mean? Beautiful? So you can change elements off a list and how do we do with this? So we first have to select our element here. We want to select our very, very first elemental index position zero. And then we assign with the equal sign and you value here it's 100. So let's see what we get. And here you can see now our list them the first element, this 100 or not one. So we simply changed the first element that next with position zero, and we can also change the very last element in our sequence. So l at an exposition minus one equals 101. Let's let's see if it works. And yes, it works. Now what if you want to select many elements off a list and we can do this with the so called slicing by using a colon inside the spare brackets. So, in this example, here we have a slice from the second l amended in Exposition one, and by definition, this element is including so from first position onto the fourth in exposition. But here, excluding, so let's see what happens. So we have 23 and four So we're slicing the list from in Exposition one, including until in Next position for excluding. So let's check again. Here, let's see it. The list. So here is an exposition one, including until the next position for but excluding. So we get to three and four and we can also slice from in Exposition one to index position five. So here in our list, there's no in Exposition five. So by default we get all elements from in exposition one until the very end. So let's check and they get to 34 end here 101 and the alternative way to slice enter the very last element, including the last element, is toe to have just one colon and then nothing. So this means we're slicing from one until the very last element, including the last element, and we can also slice from our very first element. So at an exposition zero to, let's say, in Exposition three. Excluding, let's see what we get. So 102 entries we have, including the very first element onto in exposition three So 0123 But excluding so 102 and three and the alternative fate to do this. So slicing from the very first element to, let's say, the L amended in the index position three is to have just here Nothing. Colon three. So this is the same, actually. So in what? One more example. So let's slice from in Exposition one, including two. Next position. Three excluding. And they get two and three. And we can also select all elements by just having a colon and on the left side of Sicko along on the right side, off the coal on. Nothing gives us them the whole list, all right, so let's enlarge our list with some more elements. So from 1 to 10 and what we can also do it. We can truth every second element off our list, and we can do this by having to Coghlan's. This gives us here every second element beginning from the first, including So we have fear, starting from the very first element every second elements or one, three, 57 and nine, and we can also select every third element beginning from the first element. They're having double colon and then every three, so we're starting from the first element and then selecting every third element. So we have one for seven and 10 and we can also start with, for example, the second element that next position one and then select every second element by defining here. Okay, let's start from the second lamented in Exposition One. But please only give me every second element. So we get 2468 and 10. So we're starting from the second element and then slicing every second element. So we have to for six, eight and 10. So let's start again with L. It's our list. So from 1 to 10 and we can also assign many new value values too many elements. So, for example, if I want to assign to the elementary exposition for 50 into the elementary exposition 5 51 2 the elemental in Exposition 6 52 I can do this by slicing l and assigning the new values which are here in a list. So unless you can see here we have at an exposition for so 01234 we have 50 51 that the next position five and 52 it in Exposition six. All right, but cannot do us in the so called broadcasting. So if you want to have at an exposition 45 and six, if you want to have 50 than our coat as we have it here, it's not working. So we get an error message and alternatively, we have to assign toe next position 4 55 50 and 6 50 So we have to do it manually. And there we have 50 at an exposition 45 and six attorneys. Typically, we could have created a list off three times 50. So that's that's not turn it off here and what we can also do. We can delete an l amended a certain index position. So let's say we want to delete them. The very first lamented in the next position zero. We can do this. And, as you can see here, the first element of oneness removed. And another thing I want to show you is a nested list or lists off lists. So the last session we learned that we can actually put any day that time into a list and the sorts also true for our list itself, so you can just put one or many lists into a lists and, for example, we have here a list off, let's say, football players. So each football player has a name and if, for example, as the height 1.86 meters and has a great so 82 kilograms and we have four players in our list and for each player we have one list with the name, length and the height so we can create the list. And there we have from the list with. So it's a nested list with four elements, and each element is a list itself, and we can also print the type and the lengths off the list. Let's do this. So we have off course. This is a list and it has four elements, and we can also slice a select elements off our list so we can select the very first element at an Exposition zero. So I would expect to get them. Yeah, Andy here. Exactly. So we get we have any. Here is 1.86 meters tall and, yes, 82 kilograms. You can also get the very last player at an exposition three or minus one issue. Like so we get Mike. So now. But we can also do we can select the height off from the very first player, So let's say nd and we can do that by festival. Select handy. So now we have a self selection. We have feel the sup list and then we want to select the second elemental in Exposition one . You can do this, and so we have selected the hide off Andy. So it's 1.86 meters and what we can also do. We can create a list containing only oil for names off our players, so we create a list called names. We opened this Pap rockets and then we say, OK, first element should be the very first player in the first element. So at an exposition zero, it's the name here it's Andy and then give us the name off the second player. Give us the name off the third player and the name of the fourth player. So now we have a list containing only the names off our players. So we have a list of four strings, and that's another thing I want to show you here on. Let's create a list X with four elements, and then we trade another varietal. Why and we assign X. So here. Why Bus referenced to the same list. And now if you changed the very first element off X, let's say X that in exposition zeros 100. So now the list off excess 102 34 And now, if you're checking again our Why so why has also changed? So why is this a case? Well, and what price and thus internally, here it creates a list object and references makes a reference to rival ex. And here we assigning y to X. So we're creating a reference from X to the same list Object. So we only have one list objecting. We have two references. So one reference toe X in one reference toe. Why? And now if you change our object by changing the first element off X, why references to be changed? Object. So maybe it was our intention that also why changed? But what if it's not our intention that white changes if exchanges and you know what we can do here is that we say so let's start again here with X equals 1234 and then we create a copy here off the list by saying OK, please create me a copy off X and decided to Why So now why It's referencing toe a copy off x so not to hear the object itself. So now we created two objects that we have one object, the original one that is referencing to X or excess referencing to the object. And we have a second object which has yeah, actually the same elements, but only why it's referencing to the new into the copy of new object. And if you change here external, so why does not change and that's another way to do this. So let's start again. So we were creating an object 1234 and the signing X. So we can also create a copy off x by saying Okay, please give me all elements off x. So by writing it here in this manner, we are also creating a copy. So why it's now referencing toe a copy. So we have two objects object one referencing to eggs and object to where only why it's referencing to it now. If you change X also, that's no change with y, so we have to eternity of solutions where we prevent that also why has changed a free every change. X All right, so I'm at the beginning off the session year, I said that elements off sequences can be assessed with back brackets, and this not only holds for this, but also for other sequences or other data types, which are sequences like strings. So if you create a string dog, Dogus the sequence off three characters D O G. And we can also select here the first element at an exposition zero. So it's, um de, and we can also select the very last element G and before we said that this beautiful so we can change elements in a list, and that's the difference to string, so strings are immutable. If you want to assign a new value to, let's say, in Exposition one, let's say a so deck instead of talk and then bison gives us an error message. So this is an example that drink objects are the sequence that is immutable. All right, so now we have finished our session here, and I hope you have a better understanding off lists and in our next session we are going to the next data type, which is lost the secrets to puts so hope to see you in the next session by 12. Data Types: Tuples: we'll come back to our costs. So this session provides you with a quick overview over the data type to pull. So in a triple, you can start many other objects and therefore to bliss. Also a sequence off many elements like, for example, a list. So to listen, some ways comparable to a list, however, a triple has much less functionality than a list, and therefore we we don't use it as often and as much as we use a list. But however there many situations and pricing programming where we we get in touch with stupid. So we should at least know the basic functionality and the basics off two balls. All right, so let's start creating our 1st 2 pill by are creating of arrival a a equals impediment e This on 23 So is the trooper containing three elements Want two and three, and we can also create a to build developed Parenti za. So if you just type B equals 123 separated by commas, this also works and same mess with lists. You can put many different data types and many different elements into a triple. So, for example, let's create a triple C ce cross one 2.5 and talks that we have feared in detail. We have afloat and we have a string object, so that's no problem. It works like in a list, and we can also index the Tupelo like in a list. Let's say if you want to get the second element off our to plant an exposition one I would expect to get to exactly and also slicing works the same way as with lists, if you want to slice to see from the second elements are beginning from in exposition one until the very last element. Then this also works, and also if we multiply a tupelo with an interpreter eight times two. So we have the same behaviors with lists that actually we create copies off A and can captain ate the copies so we don't have elemental wise multiplication. That's 11 might expect, actually, and also we can come get in a to tow boats that we have trouble A and we have been another to pull with the elements for 56 that we can just contaminated to a large taco and the most important difference between a double analyst this That list this mutable so you can change elements off a list, and this is not possible with, say, a couple. So if you want to change the first element of Triple A, let's say, change it to 100 then pious and drops us an error message so terrible object does not support item assignment. So what trouble is immutable in this? Heavily restrict the other functionality of to put. So they're not too much cases where many took us, however, on placing their many functions that returned my values. And so if a function returns multiple, values them, it's in most cases, it returns it. Why returning a triple off these multiple elements? Or let's seven example here. So let's create the list. This five elements this l and now we apply the function in Yuma rate on l. So what in numerator actually does it starts index and value pass off list else? Oh, actually, it stores. So we have fear Element one at in expenses from zero and enumerated stars 01 So in exposition zero there. So the element one then at an exposition one death element to and in Yuma raid creates and stars the index value pass off a list. So and if I run now the enumerated function price and does not return the index or value pass So it's only creating a so called iterated. So what isn't Iterating and Iterating? We will learn later more about it aerators. But to put it in easy words by running in humor rate were telling Taison. So please pricing make yourself ready to give me the index value pass at the time that I need it So But now, at this step, it does not create and star the past. It only creates the value pairs if I explicitly call it in another step and I can do it here in this case by applying the list function on our iterated object. So now let's supply the list function on our enumerates object and assigned the arrival em . And now we get a list with five elements and these elements are triplets and these are two bits off next value pass. So we have fed index position zero the element one we have fed index position one the element to and so on, the next position for the element five and this is one example of every year. Get in touch with Cooper. So even if you if you don't want to get in touch with two bullets, there many functions that return to both, actually, and let's slice them the first to pull here. Let's say we take the festival it in experience from zero and call it first to pull. So now we have one to pull off the elements zero and one, and then what we can do. We can unpick a triple by saying, Okay, the first element I called Index. In the second element, I will call value. So index comma value is equal to first trouble. And now, if you print index and value, we get the unpacked MIA elements off the tuber, so index is zero and values one in. But you can also do we can. That's call again our list l We can transform our list into a trooper, so that's that's also possible. So now we have trouble with five elements. All right, so this was a quick overview over tubers. Hope you enjoyed it and are we see us in the next session about sets 13. Data Types: Sets: but compacted the cost. So in this session we learn about the basics off the set data type, like listen to polls. A set is a container off many elements, and these elements can be off a different data types that we can store in the just float string sense on but them. Yeah, what makes the set different? To listen tubers. So I said, only stores unique elements, and that means that there cannot be two identical elements and a set. And so, I said, automatically removes duplicates. So let's create a list. No. Now you can see we have some duplicate, so we effectively cut off, too. We have three times five. We have four times nine and no, if we apply the function set on l. So we transform Ellen to us head object, then Paice and returns us a set with only unique value. So it has removed the duplicate, so there's only only 11 occurrence off to only one occurrence of five on the one occurrence off nine. And if you check the data type of s, of course, it's a set, and we can also create a set from scratch. So let's create a set Tiu, and we can see here we apply curly brackets and that's that. The elements 11 12 to tens. 13 14 2 times 50 And in our it returns us a set and only with unique value, so it automatically removes the duplicate. So there's only one occurrence of 13 and one occurrence of 15. And then we can also count the length of the number off unique values and our Set T and its five. So we have 12345 unique elements. So initially we had 1234567 elements, and in the end we get a set with five elements. So I said this this good instrument to count the number off unique values and yeah, let's say a list or a tupelo something. And we can also add another element toe set t by calling the method ed. So we had six, and we can also remove an element with the methods. Remove. So we try to move. Remove element 12. That's sick, and that works we have removed here Element 12 Mr Lists and two apples. We have seen that we can index or slice and those data types and and if you try to do so with sets So we tried to get the first elemental in exposition zero off the set t then you get an error message. So I said, object us not support indexing. So that actually restricts the functionality and us that not only works with the Joseph Floats, we can also have a set with string objects like Dark Catmull, star elephant. So we have a duplicate off doc here. And I would expect that by creating a set in that the duplicate off Doc will be removed and this is the case. So we have kept dark elephant and mouse. So that's it for the set finder. Yeah, we will see us in the next session about Operator and Julian's. 14. Operators & Booleans: hello when we come back to the costs. So in the last session we learned a lot about different data types, and now we are continuing to increase our to set and get familiar with operators. Operate us, allow us to have interactions between objects. And in this sense, we are getting closer to work on riel world problems, where we have many interactions and relationships between objects. In this session, we also get familiar with the special data type off billions. But for now, let's start with them arithmetic operators. And actually, we already know most off them. And this part here is this more or less a repetition. Press off. While we have three rivals, we have a equals five b equals two and see equal seven, and we know that we can get to indigenous. So a plus B gives us seven. You can substrate to inter just a minus. Biggest three. You can multiply a Times B gives us 10. We can divide a divided by B, give us 2.5 so this float object and there's another operation called Floor Divide. So it's so here we have 22 slash is actually and run the cell. So we have the division here and then, yeah, actually really rounded down to the next indigent in this case, too. And we can also happen exponentially. Ation. So a to the power off beer gives us 25 and that's an operator more galore. That's from the side here, Mortal August. That's three remainder off the division A divided by B. So let's check a divided by B via five. Divided by two is, too, and the remainder is one. All right, so let's head to comparison operators, and that's before we assign some arrivals. And then what we are doing, we are comparing. It's a equal to be and you have to be careful here. It's a double equal sign. So a single equal sign would actually assign a equals B. But a double equal sign checks. If a is equal be and it returns True. If a Sikh Obiya and the deterrence affords if is not equal, be so here we have a s five bees to So I would expect that we get on force now. The next operation a exclamation mark equal Be So what? This operation that's it actually checks if a is not equal to be so we know here A is not equal to be, so it should give us a true then we have less signs off, The less sign checks if a is smaller or less than be and we would expect the false here and we have the greater than sign and this checks. If a is greater than B, I would assume that we get a true and we can also do more complex operations so we can check if a plaice P is less or equal than see. So a plus b seven CIA seven so see is less or equal than seven. That's true. So now, before the operators, they give us true or false a za result off comparison and to reinforce they are both special data types called billions, and if you check the type off true, it gives us pool for bullion. And we can also check about true stands numerically, for transforming true into an indigent and true always stands for one, and we can also transform faults into an indigent and force always stands for zero, and we can do it the other way around. We can transform an individual into a pool object and let's try it with one. So this gives us a true and also, if you can, some life into this gives us also a true and they rule us. Each indigent off load that is not equal to zero gives us the true if he transformative herbal will. So the only number or indigent, which gives us a false if we transform it into bootless zero. Actually, and you can also check the mathematical behavior off True and Ford's by applying arithmetic operations so we can calculate five times true true stance for one. So we will expect five. And that's true. And we can also making additions or five plus true, get six and let's try the same with false or five times for us. Return zero. And we can also assign a brilliant object to have arrival. So that's no no problems off life equals tour that's faults and be assigned falls to the varietal de and three years now stands or falls, and we can also then make operation Sunday So five times D D stands for false gives us zero . So earlier when we learned about lists, we learned that in a list. We can actually start each data type of object we can think off. And the sounds also true. For a 1,000,000,000 we can put a Boolean into our list. So no, it's executed. This l So on the list l deaths a in the one to enter just their Susteren cat. That's a float object 1.5 into this Apulia an object. True. All right, so let's go ahead with a logical operators. So in the first bonus end and this is yeah, so called logical end and was in logical end us. It checks if all conditions are true and only if conditions are true. Then we get a true so true and true gets us true if both are true. So that's easy here. In that case, now it's getting a bit more difficult. So we have two conditions five greater than two and seven greater than two. So we know both conditions that true. Then we should get a true here and in most cases, the end sign works in the same base. So there some some minor cases that doesn't work, but I don't want to go into detail here. So true intro gets that's true and also five greater than two and seven greater than to give us true. So let's go ahead with True and Fought So we only got a true if both statements are true but obviously false is not true. Now we have five greater than two and seven less than two. So obviously seven less than two weeks Fars and not our conditions are true. So we should get a force and also force and force will give us the force and five less than two with force and seven less than two is also false. So we should get a false Okay, let's continue with the logical or so logical our checks the statements and gives us the true if at least one conditional statement is true. So if you have true are true. That gives us the true because at least one condition is true. So yeah, both conditions true. Alternatively, you can use the type Simba for sewn. Yeah, the very most cases. This also works So it depends on whether your keyboard this American English or European one you can find the pipe symbols and also with the types number true are true gives us true. And also five greater tour or seven greater to gets us true, true or false gives us also a true because at least one condition is true and this is also the same. This Fife greater than two are seven less tour. So five grader to is a true statement. So this gives us true and force and false gifts. That's a force because no, no statement is true here. And last but not least, we have the not logical operator. So the not logical operator simply reverse is true and four. So if we have actually force and say not for us, it's true. So that's quite easy and not true is fourth and last. But not least now we have a bit more complicated example. We start here with this bracket. Five. Greater too. It's true. Not true is false. Fourth or fourth gives false and then here outside the record is not so not force should give us true. So that's it for the operators. And I hope you enjoyed it. And yeah, we see us in the next session about conditional statements if LF ads and while so see him by 15. Conditional Statements (if, elif, else, while): Hello, everybody. And welcome back to the cost. So in the last session we learned how to check whether that condition is true or false. And bison returned as the true or false, which are so called brilliant objects. So typically checking weather conditions to our forces. Only 50% of our job. Because in real world situations, we first have to check with the condition is true. And if so, we have to take action one. And if for us we have to take action to. So yes, the point. Where are we introduce If Ellis and statements that are doing a very good choppier and bison so festival will be defined. Two variables A and B equals five and then we check whether a is less than 10. So we start with the Keeper if if a less than 10 and then we need a colon and then we press enter and you can see here Bison makes automatically and in dent. And now we have to refine what our action is here. If our statement yes, correct. So obviously our statement is correct. So our actions should be pleased. Print me. A s less than 10. So Let's sick. What happens if you run the settle? So we get a lesson 10 and that's correct. So now what happens if we change here? The comparison operator to a is greater than 10 so obviously the statement is false, so let's see what happens. So Tyson prints nothing, so the statement is not true, so we don't have have to take action one, which is print ace Lesson 10. So now we have to define an alternative action and they re introduce the key bread of you, make a colon press enter, and then you can see also hear pipes and makes automatically and in Dent. And then and then we define our alternative action saw. If the statement is greater than 10 it's not true. What should be the action and the action here is print is not brighter than 10. So let's see what happens if you run the cell we get. The message is not greater than tenant. That's correct. So now if you change again here, the operator so a is less than 10 and we execute again, then we get again a less than 10. So what person makes here internally is actually checks better the condition, condition, years true. And then as it is true, it takes the action print and then person stops there Some sauces for mistakes here in statements you need to make the colon here. If you forget the colon, then we get an error message. So the colon is important. And also here the intent. You have to make the indented here If you don't make make the invent here, you get him ever message and typically Paice and makes the end end automatically. If you press yearender after the colon and you can also buy it pressing the key Tep, you can make the intent here and also for the s statement. So the statement short if they have the same in dentists and the if statement. So if the A s statement has another in dende, it also doesn't work. So the s that mentioned empty saying intend Theis statement and the action here in this case, the print statements should have phone on Dent. So this issue correct. All right, so let's move to another example and we compare A and B so if a is greater than being which is here, not the case then please print A. It's not greater than be so. If this statement is not true, person then checks if our alternative condition LF so that's a key word for checking on alternative condition So else if a is less than B which is here also not the case. Please print me. A is less than being. This is also force soap, Ison continues And then this in the else statement. So if condition one in condition to their both falls then in all other cases please print me A is he could be and he in this case of course Spuyten prints a sequel to be and again what Python does internally. It checks them the first condition. If it's true, it takes action one and stops. And if a condition one is not true, it checks the condition too. And this condition do is true. It takes to the action off condition too, and then stops. And yeah, if our statements are conditions are not true, then Tyson. That's a reaction which is determined by the statements off all other cases. And we see now in the next example that we can have more than one ls statement. So now let's assume that we are ordering some goods in an online Web shop and we get some discounts depending on our price and there some discount interprets. So if the price is lower than $50 we get 0% discount. If it's between 50 and 100 so 50 including until 100 excluding, we get 10% discount. If our prices in the inter bit 100 including Teoh 200 excluding get 20% discount. And if our prices equal or greater than 200 Allah Oh, are we get a discount off 25%. You can transform this into a code and say so far, prices less than our discount and terrible at positions there. Also, if our prices that less than 50 years we get a discount off 0% and then LF so if this statement is not correct, but prices less than 100 we get a discount off 10%. And if also this condition is not true, then we check if our prices less than 200 and also this is not true. Then we know that our price must be a greater than 200 are great out. We could have been 200. And in all other cases here, greater than 200 our discount is 25%. So now let's check this hour price of $75 and we run here our if LF statements after this comprises 67.5. So we get 10% discount because or prices in the in terrible 50 to 100 where we get 10% discount. And also let the fume if we have a price of 40. So I would assume to get 0% discount, you know, after this comprises for two years. Also, let's assume our prices. 1000 we get in after this comprises off 750. So we get 25% discount and weaken further increase them the L S statements, or there's no restriction on the other statements. We cannot fear, let's say 50 Ella statements. So this is quite flexible here. All right, so let's move on to the viol you. So let's set 8 to 10 and let's check whether a is lesser than 20. Enough ace, less than 20. We increase a by one. So this is CIA. A plus equals oneness to the same mess. A equals a plus one. So that's on a previous ation here. We can do that. So if a s lesson 28 please increase a by one imprint A. And let's see what happens if we run the cell. So we get 11 and then we can rerun again because now it's 11 and we can check again. If it's less than 20. You. No, we get 12 and we can repeat this process many times until we sort reach 20 in the end for it's chicken. So now we have reached 20. And now if we rerun the cell again, we check whether is less than 20. So 20 is less in 20 and this is the fourth statement and hear our loop stops. Yeah, Mexican CEO. I mean, it's a bit inconvenient to do this process or to repeat this process manually and there divide loop constant to play. So we actually do the same task at Sierra Buff but introduced the device statement stand. We define a secrets 10 and then be making repeated if statement and check whether a is lesser than 20. And if it's the case, we increase a live one here and print a And so now let's see what happens. Surprising automatically dust the repetition off our if statement so you're the first check is them? A Is 10. So the first step is pricing checks, whether tennis less than 20. In this case, it increases a by one and Prince A and now price and repeats the process so it takes a equals 11 checks. Whether it's less than 20 that's correct. Increases a by one and again, Prince A. This is 12 points and repeat the process until we reach a equals 20. And this is all automated, so we don't have to make this manually. And that's the purpose off my loop. And then in the end, we can. We can also print again a to check. Okay, this is our final result. So the violent stopped when a is 20. So let's move on to a more more realistic case here, a more real world situation to say. So let's assume we are in touch off loading a container ship, and we have to check a freight exceeds the Mexican, afraid that is allowed, and we assume here that the maximum will outweigh just 1000 tons and our actual wages 1100 tons. And we have many containers on our ship and we can reduce our afraid by unloading a container, and we assume that a containers wait a 70 tons. So first step, we can reduce the rate by 17 tons. And so we are introducing here a by a loop. So we're checking if our waitress greater than our maximum allowed made. And this is the case. We print the cautioned statement, afraid with expanses too heavy. And in the next step, we reduce our weight with by our reduction steps. So we unload one container, and we repeat this process so many times until our actual waiters less are not greater than our maximum weight. And in the end, we reach it and are dilute dupe stops we print the final results are afraid with extends. It's okay and yeah, let's assume that our our actual weight it's 1100 tons. So it's it's area than our Max Wade, and that's check what price and us here. So at first checks is if our initial weight 1100 tons is OK. No, it's not okay. Then introduces our weight by 17 tons. And also 1083 thons is too heavy. And it repeats us that so many times until we reach afraid off 998 wants. And here the pilot stops and we get a printout that 998 tons is Okay, so this works. All right. So we learned a lot about if l f and l statements and Divi Loop. And in the next session, we are getting introduced to far loops the Charles A very important. So see you in the next session. Thank you. Bye. 16. For Loops: Hello and I come back in the session about for loops of follow ups are one of the most important and most heavily used concepts and programming. And before we learned about lists and lists are containers off many other objects, like a back pick that you put in things like a sandwich, bala fora or extra T shirt before you go hiking. And now let's assume that it's raining in your backpack and all elements get and what you are typically do you unpick each element and taken action on it. So in this case, you are drying each element in the sun and others quite an element wise operation. But earlier we learned that however, limit dries. Operation ISS understand, not behavior off lists. Let's create a list with four elements. 1234 And now our attention is to my reply, each element by tools. So on Element West operation. But you already know if you just put any other times too, we get a manageable off the list itself. So actually recreated two copies off there and then we can Katyn aided it. But we didn't get on element wise operation, But now what should we do if you want to have an element wise operation. And there the four key road comes into place. So we're saying for J in lists that we can also say for Ellen Men in list, we can name the each element off the list. Um, with the name we want, we can say element or I O. R J. That's important. So we can say for element for each elemental list. And then we have to make a colon. And if you print and if you press return, then we automatically price and make Syrian and Dent and let me say print the element so we can see here reiterated overall elements. And we printed all elements that we get 1234 And of course, you can do more than just sprinting. We can say OK, each Ellen one. We want to magic by by two and then print it. We can also do that, and also we can say that we name each element. I might apply each I by two and then rename the my deployed element as Jay and then print Chase that we get here the same result, of course, and before we learned the function lengths. With the function lengths, we can determine the amount of elements. Analyst. We can replicate this process by a few lines of code so we can say count equals zero. And for element off under slash in list, please increase my count. So encounters for So we just determined to the lengths off our list l for elements. But again, I want wanted. So I like to think so. You need the colon here, so it's the same with the if statement if you forget the colon getting error message and we need the intent here. So if you forget the intend, we also got our message, though this is here, the right structure. So before I said we can iterated overall, it'll rebels. So literary efforts objects that contain many elements. And also we learned that a string also has a container off many elements or, for example, the string Dark contains three characters. Dont and let's create the rival Dia equals stark. And then we can also reiterate over GM print or single element D O T. And we can also print each character as an upper character so we can say for each corrector . Andy, please print me in the upper character and we get D O T. And we can also determine the length of our string. And of course, it's three. At this point, I want to introduce the range object and the range objectives. Also, it'll rebel so we can iterated overall elements. And in this example, the range objects stores inter just from one, including until five excluding soon. If you run the cell, you only get here the range object from 1 to 5 and you can also check the type off the range, object its range object. And when I say the range objects, stars and the elements, it's the action of really starring it. It just makes itself ready to give me all elements if I explicitly want to have them so I can explicitly call the range object by creating a list. And then the list is containing all four elements off our range object. We can also reiterate over a range objects of same with the list so we can say for Ian range 1 to 5. Please print me all elements and we get 1234 So the last element excluding so from one, including 25 excluding, and this is actually the same behavior as to the list. So before we had our list 1234 and reiterated over it, and we got you all elements. So what's the difference to a list? While a list once created, it stars all elements off the list at the same time. And, of course, you can iterated overall elements. But the range object arrange object never starts all elements off it at the same time, so we can iterated element twice over all elements off the range object in python eternally stores only the extra element. So we iterated over one element. Do something that's this element after we are finished and want to go through the next element, then pies and drops out our actual element and takes it off out of memory and then takes next. Elements or bison never stores more than one element at the same time with the range object . And yeah, that's quite memory efficient. So if you assume we don't have an elemental range object with four elements but with one million elements, so it makes a difference if you restore one million elements are only 11 element. All right, so let's go on with the range objecting, Of course, we can create five iterations so we can say for Ian Range five and five stands for the last element. So excluding by default, our starting elemental zero. So here we get all elements from 1 to 4 Indican Dossett would explicitly we can say we want range object from zero, including 10 excluding, but only every certain elements. We can also define this one here and then we get 036 and nine. And of course we can do more than just printing. You can, for example, my reply. Each element now arrange object and printed out there. We get all my deployed elements from 1 to 10 including let's go to a very common backflow. So we want to store the Cranham bus from 1 to 10 in a list, and therefore we create an empty list. L reiterate over the range object from 1 to 10 including we calculated the square number for each element and call its career, and then we append it's scrap number to the list ever. So let's see what we get here. So we get a list with Oscar at numbers from 1 to 10. And that's also quite a concept called list comprehension, which does actually the same chopped. So we can say, Here we create here and spare brackets. We create a list you and we can say please for all elements in our range. Object one till 10. Please give us the element to the power off, too, and please store it in a list and execute the salad and they can see you. We get the same results before, so we reduced three lines or four lines off coat to only one line of code with Phyllis comprehension. All right, so let's go on with another case study and let's count or numbers between zero on 10,000 that are divisible by tour and five without remainder. So we can say for Ian Range 10,001. So we wanted include 10,000 and if one water low tour is zero. So if oneness divisible by two without remainder and one model of five equals zero, then increase our count by one. So first here at the beginning, we introduced arrive account equals zero and and for each element in our range object that forfeits here. Both conditions. We have fear. End statement. Please increase our count. And there we get 1000 and one elements and that fulfilled the conditions. So, obviously is their oath of office our condition and then 10 2030 until 10,000 from each elements that I actually a divisible by 10. All right, so that's father time being in the next session, we will have a look at the key. Arguments are key breads continue break and pass. So see you there, but 17. Key words break, pass, continue: hello and welcome back. So in the last session, we learned about four loops. And now in this session, we want to increase the functionality or the flexibility off our follow ups by introducing the key birds continue break and pass. So first of all, let's create a list l with the elements. 1357 10 11 13 14 and 15. What we want to do now we want to find the first even element. And so what does even mean even means that I model auteur equals zero We are introducing here a four Rudolf for every elemental ever on. Then we're having an s statement. If I'm model two is zero, then please print me the first even elemental X industry elemental art. Then please print me the elemental sought. So let's let's have a look what we get here and here we get. Okay, oneness up. Three Assad fighters at seven is up, then the first element is 11th even element. But now you can see that the federation goes on until the very last element 15. But what we actually wanted we wanted to determine the first element that this even and we don't care about any other elements that comes after the first even element and therefore we can hear include the key broad break. So let's execute again. They can see that the iteration stops once we have reached the first even element. So what Tyson is doing here, illiterates over the list. And once our condition Ismet, once eso tennis, our first even element reprinted and then break means that we completely stopped the alteration here. All right, Yes. We are only interested in the first even element. We don't care about what elements, so we don't want to print out there. Let's, for example, say oneness upped. And yeah, what we can do Because instead of having here the action print elemental sort, we can just say pass or do nothing if elemental art and they can see the only message are the only result we get us that the first human element is 10 and even be. We don't actually need here the complete s statement. So if you just delete it, then it also works. So maybe you're asking yourself why do we need the past statement? I mean, here we just deleted the whole L statement but let's assume we want to have the if statement the other way around. So first off, what we want to check if the elemental ought. And in this case we just want to do nothing. And if it's not Ott, we want to print the very first even element. And let's run the set here. And you see, it still works because he every saying if the elemental art then passed. But what if he But what if we completely cross out past and just have nothing here? So if element is that I don't care, I'm not interested in began error message. So one statement. We always have to define an action. And if you want to do nothing, the past key road, it's just a fill abroad, which we need Other vices. You get an error message. All right, so you have a better understanding how the past keyboard works. We're just here having the same coat. But after our passkey broad, we say OK, even if our elemental art priest print me and the element and then we get 12357 and then the first element even element is 10. So maybe you want to print out all what elements. But what if you don't want to bring out what elements? So we're checking If element IHSAA benefits out. We're just wanting to go to the next element, and they are the key. But continue comes into play. So instead of having past year, we have continue and still react print here. But let's look, if the behaviour is different and here you can see we are just having the statement. The first element is 10. So what? Python Dassier? It checks whether an element is odd, and if it's odd, continue means please go to the next element, do nothing and go to the next element, even don't print it. So that's actually the difference between pass and continue. So continue is the key right? Saying that please go to the next element and passes just a key road for Please do nothing and to make it a little bit more clear. So let's assume we still want to find the first even element. But forever reason. We want to exclude 10 as a result, that's here. So this is the code we already know. So if to iss even then, please print the first even elemental Exploit that and then please break. If you want to exclude that, we get 10. We have to introduce another if statement saying, If I equals 10 please continues for Please ignore if tennis and madness because I don't want to have 10 as a result. So disgusts me here. 14 as a final results of the first. Even element is 14 because I just ignored 10. All right, so this is it for the time being, and I hope to see you in the next session by 18. Generating Random Numbers: hello and welcome back to the session about random numbers. So creating random numbers is a very helpful tour to assimilate and analyze the real world processes like playing the lottery. So if you are good in Massasoit has six. You can simply calculator the likelihood of finding a lottery. But if you don't not have any clue about math and so six, yeah, you can also simulate this process by generating random numbers and analyzed and the results off the assimilation. It's a festival. Let's import them. They render model. So it's not important by Ford. So we need to import that with the key bread import and then with the the function random that random we can generate a random floats in the interval, a 0 to 1. So if you press shift tab, we can never look here. So it's in the inter ver 0 to 1 until we get a 0.5 to 3 something and to fear read around the cell, we get another random float also in the interval, a 0 to 1, so it's no 10.89 and every time we repeat this process, we get another random flowed in the in trouble or 21 And there's a very helpful tool called a random seat, where you can pass within the brackets. A number here it's 123 But it can be any number. And when we create random numbers like here, we need to set the random seat before. And as long as we have the same random seat, we get the same random numbers. So the random numbers are still random. But the so called pseudo random because then they depend on the random seat. And this enables reproduce ability. So as long as you have the same seat as I have so here in this case 123 we should get them . Yeah, the same random numbers. So let's run here. The Senate with the random seat 123 So we still use the random generator and them that random. So we would expect a random float between zero and one. So here we have a 0.5 to, and if you repeat this process, we should actually get the same a random float. And this is the case. So went. If we change here, the random see to say let's take 10 so it can be any number here. Then we get a different random number. He had a 0.57 And if you repeat this process that we get the same number because we have the same seat us before and depending on the characteristics of our real about problem. There are different the random generating functions. So here we learned about the random, a random function that creates floats in the intervals 0 to 1. And that's also the function random that rent in, which creates random India. Justin on in Terrible Vitria can determine actually, so let's press shift step and have a look. So he returned random indigent range A to B, including both end points. So if you want to generate a random indigent range 1 to 100 both ends, including then our function, here's random dot rent int from 1 to 100. So let's run the cell here you will get 55 on. You can also repeat it. So without random CTF, you get have different indigenous and let's assume we have the problem off rolling the diess. Yeah, we can simulate rolling the dice by creating random in the just in the range 1 to 6. So now fast row, we get five and now a second throw one in our sets TRO two and so on. And we can also create many a random numbers with a for loop professor. For we create an anti list. And we said that the random see to want to three So we want to have the same random numbers . If we repeat the process here and then we say we want to have 10 random indigenous and range 1 to 100. So the FDA for uber with 10 iterations So 10 times we create a random India turn range 1 to 100 and it's a random in digitally append to our list. L So let's see what we get. You can print out here. So here we have a list with 10 random in the Justin Range, 1 to 100 and that's check also the lengths off. It's off course, we have 10 random indulges the and we can also simply change this. So let's assume that we want to simulate rolling the dice 10 times. Then we can say, OK, I want to create random in the Justin Range 1 to 6 and here we have the result of simulating rolling the dice 10 times. So we have 1314311455 And as I said, depending on the characteristics off our real world problem, there are many more random and functions. So if you press your shift tab, So, for example, we can create look, normal random numbers or normal random numbers. So there a lot off options here. All right, so let's create some normal distributed numbers that several look at shift tab. So here we are, creating normal distributed numbers with mucus and the mean and sigma standard deviation. So let's assume we are We have a mean of 10. Understand that deviation off five. Then we can create a random number from the A normal distribution with mean 10 and standard deviation five. So in this example or 50.26 All right, so we are finished now with the Rendon what you'll in later we can see that also lump I their surrender module with uprights. Actually, even more functionality and more options than than the red Ahmadiyah here in the price in standard library. So I hope you enjoyed it and yeah, you see us in the next lesson 19. User Defined Functions (Part 1): hello and their come back to this session about user defined functions. So whenever we want to reuse or repeat the same or very similar code more than ones, it may be worth writing a reusable function. And by doing so, this can help us to make our code more readable. Functions are nothing new, and we used a lot off build in thanks and so far, But first of all, let's create a list l containing off for Inter just 3 to 56 And we already know the function, the building function, print so we can print our list and like something that's also the function sorted that we can sort our list in ascending manner. So here we have 2356 and solve It actually creates a sordid copy off. And so if we want to, they are really thought over this l we have to reassign l. So now let's print again. Oh, and here we have the sorted list. L and we already know methods which are functions that I attached to a specific objects. For instance, we know that the list object has some the method append where we can upend another element to the end off the list. So, for example, we can hear upend the element seven to the end off the list and let's print out our list again. And there we have seven at the end of the list, and as a general rule, functions work for different objects so you can print out a list or on individual on float with function print. And in contrast to that, methods are functions specifically designed for particular objects. So, for example, here append the upend method. It's a particular function for for the list object, all right, and we already know more functions. So we know the lengths function, which calculates the amount off elements in our list. So we have five elements, and we already know the mid function, which calculates the many moons element off our lists. So it's too, and we also know that makes function. And we have already seen also the some function which takes them the sum of all elements in our list. Yeah, we have seen that habit and functions like many more maximum some, and one could think that them there there should be also a mean function which calculates that the mean off our list. And if you try to apply the mean function to our list, l and then Price and assess them that the name mean it's not defined, So that's no mean function. Now we can create our own user defined mean function that calculates that the mean off your list and before we start creating the function mean be subversive. All think about how to calculate the mean off a sequence off numbers. And actually, we just have to take some off all elements divided by the amount off elements itself. So let's take what we get here. So we have here the sun. It's 23 the length is 5 23 Divided by five gives us 4.6, and now what we can do we can you define our new function mean and we have to start with the keyword death here, your seat and green. It's a Q Bert, and then we say, mean so our function should have the name mean, And then within the brackets, we define a pyramid X. So X quipped, stand for a list or another type of sequence, like a triple or so on and then we have to make a colon. And then if you press ender, we see that the python automatically create Syrian and Dent. So this is called the function head of it. We defined the function, and now here is the function body, where we define what the functions would actually calculate. And here we have to make a dent, so the function should calculate them. The sum over our perimeter X divided by the length off our paramedics. Then we can delete here the empty line. And then we have to define what our function Saudi actually return. So here in the function body, we defined what the functions would calculate. And then in the end, we should define what our function should return. So we used them. The keyword return and the facts are short. Return us. Um, they mean so now we can run the settle and here once again. So this is, um yeah, the same coat here. If you compare it and then what we can do, we can call the function bypassing the argument to the functions of Ellis, our list and the thanks and expects an argument for the paramedics. So our argument is on the list. L And let's see what we get here. So you give you get 4.6 and we can also do this more explicitly so we can call the function by saying, Okay, our pyramid a x should be, um, our list L So this is actually the same as a buff. Yeah, Our thanks. You should not only work for lists, but you have also for other sequences, like two birds. So we can define a two party with the elements for 567 And then we should also be able to calculate on the mean off our total. Because if you look at the function body here, so we calculate the sum off a sequence divided by the length of a sequence and the salmon lengths functions should also work for troubles. So our function, our user defined function means would also work for toppers. Let's see if it works. And here we are and what I also want to show you. So there's no need to define your arrival. Mean we can directly say Okay, please return me the some off our secrets X divided by the length of our sequence. Six so this would also work and let's run it again. There can see. So it also works. All right, So let's move to another example and we assign the inverter seven to our rival A and then we can calculate a squared. So it's 49. Yeah, and then if you want to change it, So let's say we want to change a to eight. Then we can rerun here the cells and get 64. And whenever we want to re use a code, we can also define a function so we can define the function square with them. The paramedics and the function should return us them the square off our paramedics. So let's try for and call the function, bypassing the argument for and the function gives us 16 and the same as a bath. You can also make it more explicitly by calling the function, saying that the pyramid of X shoot before so this is the same. But actually what we have to do we have to pass the young argument to our function. So if you just call our function with no argument, we get a narrow methods. So you can see is our functions crass, missing one required positional argument. ICS. However, what we can do, we can set a default value to our paramedics so we can define our functions. Create toe by saying that the default value off our pyramid, the extra p two and the functions of return X squared. So now if you call the function without any argument, the function automatically applies our default value to. So now we got expect here them for a return off the the function and correct. Of course, the function can also be called the new arguments off like Sample four gives us 16 and Samos above. If you can make this more explicitly by saying our perimeter excess for and this also works , all right, this the basics off you that defined functions in the next two sets sessions were going a bit more detail, so hope to see you there by 20. User Defined Functions (Part 2): hello and welcome back to part two of our user defined function session. So far, we only had one para amid an hour functions, but of course, functions can also have many perimeters. So let's define the function power very calculate X to the power off. Why? So he and the function definition within the brackets we have the pyramid us except by and we return X to the power off. Why? And then we can call the function bypassing the arguments to and seven and we would expect to through the power off seven and it's 128. And before we move on, I want to make clear the difference between para middle and arguments. So many people mix them, those two up. And also I do this sometimes. So here in this function x and y a para meters. So these are the names that appear in the function definition. So weeks and wife are perimeters and here, too, and seven arguments or values that are passed to the functions when the function is called . So this is a slight difference, and I just want to make it clear, and if you mix it up, it's actually not so serious. So everybody understands what you mean by saying argument. Oh, our perimeter. And in this example here, so two and seven are to positional arguments because Tyson automatically assumes them. That two stands for Extender 74 way because exists the first para media and y is the second para media and consequently to ism the human for the first para meter and 70 argument for the second para media. And you can also make this more explicit and by saying OK exist to and why is seven and in this case to win seven s so called Cuba arguments because he explicitly say, okay and my pyramid of excess to and my pyramid of y seven. So in this case, of course, the same recite and what you can do you can change the position off the keyboard arguments . So instead of saying, exist to and why seven You can also say why seven nexus to that's no problem, so there's no danger that person could mix it up. Now what if you use a keyboard argument for the Pyramid of X and the positional argument for Pyramid A Why so let's look what we get here and he would get in the air. A message position argument follows keyboard argument. So whenever you use them a mix off key bread and position of arguments, the position arguments have to come first, so you must not start with them. The Cuban arguments otherwise again, ever message. But what you can do you can pass in the position of argument to for the Pyramid of X and then apply the Cuba argument seven toe about perimeter wise off this works and what we can also do. We can define default values for our para meters so we can define the function power to with the default values too far Perimeter extend the 74 para middle. Why? And then we can call our function without any arguments over the four values. And of course, you can also call our function with the new values and to positional arguments. So 34 hour pyramid, except too far para meter by and instead of fusing to positional arguments three. And we can also use to Cuba arguments ex equusearch three. And why? Because too. So this is more explicit and yeah, actually, better to read for everyone now what the fear only wanted change. Pyramid extra. We have by default X equals two. And why equal seven? And if you say that, okay, extract the three year, then python automatically assumes that the full value for why so the specs, um, three to the power of seven. And if you only want to change X, you can also take a new position argument for paramedics. So if he only pass here, the argument three pricing automatically assumes that three stands for X and we have to default value seven for why? And discuss them The same result. Now what if we only want to change our perimeter wire? So if you use a position of argument for why and place it here at the beginning, Tyson has a problem. The cost Python things okay, three stands for X. And then if you define X equals two, then our function got might about values for the argument X and Samos before. So if we start within the Cuban argument for X X equals two and then assume that why is three? This also does not work because position arguments here 34 wife follows and the key about argument and disaster work. But what we can do, we can just say OK, our why is the three and four x you want to have our default value networks and we can make it more explicit by passing the two key but arguments so saying okay exist to it's in the same mess in the four value and why should be three. And in my opinion, this is definitely best practice because everybody sees and knows at a first glance, yeah, the arguments for for the pyramid us exist to win wise three. All right, so now, coming to a completely different topic, we can also assign a varietal to our return value. So here our function power to returns the value eight in this case and we can directly assign the reliable set So set should be aid and this correct. All right, So this loss part two off user defined functions. And in the next session, we've learned that a function can also return my liberal values and they are also have a look at two case studies, so hope to see you there by 21. User Defined Functions (Part 3): Hello, everybody. And welcome back to paths three off our user defined function session, and so far our function only returned one value. But of course, functions can return many values and therefore we've defined the function character within the pyramid, US, X and y. And our function should return X plus y x minus y and expired applied with why so let's define the faction. And then we can call our function with the documents five and two and our function returns us a trouble with them. Our three values So five plus 27 five minus two us the three and five times two is 10. So we get a double Elvis. I was three results and we can do this more explicit by defining of arrival so we can say explicit bias Um, Ed X minus wise sub A and X times y smiled and then we can also return the arrivals so it's up and mild. So this is our function to and we can also call our function to with theocracy mints five to and off course them the skiffs them the same top of and we already learned that we can assign a varietal toe a result off a function so we can assign seat with the chapel. So C s in the top of the 7th 3 10 and then we can unpick the triple by assigning the rivals at sub and miles. So now it should stand for seven substitute stand for three and mired for 10. And we can also do those two steps on only one step by calling the function and directly assigning the arrivals at sub and might to the results off our function. So this is the same as above, but we could safe on step here. So at us again seven subs three and modest 10. All right. And what we can also do. We can get a conditional if statement in our function bodies so we can define first off all a list with the seven elements wanted seven. And what you going to do, then? We want to define the median off our list. So that's no bid and function media. And the median off a sequence off values is actually the value where 50% off the other values is lower and 50% us higher. So the median off our list should before. Three values are lower and three values are higher. And our median function should cover yeah, cases. Whether we have one element, five elements or 10 elements in our list or even know elements arrests off all we define our function median with the pyramid. Exactly. Expect a sequence. And then we calculated the lengths off X so to say, the number off elements and our secrets. And if the length is smaller than one, so if there's no element than there's no media, so our function returns nothing. And if the amount of elements in our list is hot than our function, median should return us. Yeah, actually the middle pointy off our list. So in this case that the element that index position of three years or the fourth element in all as like other cases where the amount of elements and our list is even so, for example, we have for six elements, Then the function median should return us theory Ridge off the third and fourth element. All right, so let's run our function here, and then let's call our function with our list l. So we would expect for us the median and this is true. All right. So before we learned about generating random India, test them with function random that rent in and yeah, that we can create random into. Just for example, E and range 1 to 100 festival. We have to import the random audio and flex our over here We have 52. But what if you want to create many random individuals and we need your for loop And we can also create here a function called random generator where we have to permit a size. So we want to have 50 random into just and the lower end point. This one in the higher end point is, for example, 100 so 50 render vintages from 1 to 100 and we can also set up the pyramid a seat for the random seats. So we should also be able to change them the random seat. So this is the function header here and in the function body, we create an empty list. Set the seat with, um, the pyramid. A seat equals them seed us to find here in the function, and then we introduce a for loop so 50 times we create a random in Detroit from the lower and point to the higher end point in this case, one till 100 and we call the random into two random and and then we upend the random end to our list. L and we repeat this 50 times, and in the end we return our list. L within this case, 50 random into just and then get in this case we set before value. So our the fourth value for the size is 50 for the low and 500.1 for the higher 0.100 and for the seed 123 So let's run the Senate here, and we can also call the function with default pyramid us. So the soup Merrick here and here we have 50 random in the Justin Range, one till 100. And we can also call our function only with positional arguments so we can pass 10 for the size 100 for the lower end 1000.200 for the higher end point and 100 for the seat. So that's what Berg. And here we get 10 random in the Justin Wrench 100 to 200. However, the best practice, at least for me is, um yeah, calling the function with Cuba arguments. So with this much better to read and understand for for everybody, actually. So you know, we call our function with them for Cuba arguments. So we set size to 10 lower and 100.200. High end point to 200 see to 100. So, actually, our pyramid US arguments are the same as above. So we would expect them. You actually the same result off the function, and this is true. So here we have the same results. But as I said before, this is definitely here. Yeah, the best practice to explicitly have from the keyboard arguments. All right, so now we are finished with the user defined functions. Yeah, there's much more to learn about user defined functions, but I think this is a good foundation for our purposes. And yeah, I hope to see you in the next session about visualization with my plotless 22. Visualization with Matplotlib: Hello, everybody. And welcome back to our visualization session with Met plot lip. So in most cases, a graft has us more than a bunch off numbers. And for the human eye, a graph is typically more intuitive, understandable and therefore also, python has an extensive library for result ization called Met plot lip. So they're actually no limits and customizing grass with Met plot lip and you could actually a re engineer or read you any graph you might think often Paice and and yes, just a matter of time. Because the functionality off Met plot lives here more or less unlimited. So this session should itself as a shot intro that enables you to make the most common plots, like line plots, scattered plots and history grams. And it should also enable you to make the most common and important. Customization is two. Plus, it's a festival. We have to import the plotting framework off bad plot lip called pie plot. So we import met plotless dot pie plot spl t. So this is standard convention to if they're radiation Pierre to you And if you work in trip in and out, Booker really should also have here the magic function. Met block, flip in line. So let's execute here and then festival. Let's create a list with five elements 1357 and nine. And we want to create a line plot off these values. Therefore, we're using the function period t that plot for the line plot and we pass our list tour purity dot plot And before you want to execute and show our line plot. We also showed us peered here. That show Let's execute this out here. So now here we can see our line plot. So we're looking at the y axis. We have one here. Then we have three. We have five, We have seven and V s nine. We could also change them the last element here to, let's say six. So he in the end, then we have six. And by the four appeared year That plot starts with Sarah at the X axis. So this is actually an inter plating line for the points. 01 one's for you 25 37 and 46 And we can also define xxx value. So body four Tyson assumes inter just starting from zero and you're in this case, we have five elements, so from 0 to 5 excluding. So this system the fourth case. So we get to you the same graph, but we can redefine the X axis. So let's say we want to have X values from 5 to 10. We can do this. So now the X values are starting from 5 to 9. So and if you cross up purity, so then we can still see the plot here. But also if your description off plot object and therefore it's the best practice here to have the purity show before we plot here. And we can also make us get up a lot with the function purity dot scatter where we define x value. So from 0 to 4, including and the vie values is our list. So let's see what we get here. So we get your scatters and the 1st 1 has the next value of zero. And then why? Well, you off one. And the 2nd 1 has the next body off one and the y value off three and the 3rd 1 has the next value off to wonder why value of five and so on. Why we have to keep in mind that the amount of X values must match from the length off our values Here. Sophia, for example, X and range seven. So we have here seven elements off our X axis and only our list. Elvis. Five elements when you get an error message, so extend why must be the same size? All right, So let's move on to a history Graham. And let's assume that we're standing downtown New York at the street with the speed limit 50 MPH and we are measuring the speed of 10,000 cars. And for our purpose here we assume that the speed is the normal, distributed with mean 55 standard deviation. Five. So we're creating 10,000 normal distributed random numbers with me and 55 and standard deviation five. So we're using here a list comprehension and be assigning the rival speech in New York. So actually the length of our lists would be 10,000. Okay festival. We have to import a random audio. Then it's advert, and we can also check some elements here off our list. Speed. New York. So let's say let's check the first 10 elements so we're 54 55.4, and so on. 48. And then we want to create a history, Graham, with our 10,000 measurements and therefore we are using purity hissed, and we're passing our list Speed, New York toe purity hissed, and we're defining that. We want to have 100 minutes. So let's see what we get here. So here we have a history, Graham, with our measurements. So it's most of price s. We created our measurements with a normal distributed random numbers generator. We get your kind of a bell shaped curve from with the mean at 55 approximately. And we can also change the amount of pins here we have 100 bins on. Uh, let's see what happens if you change it to 10. So now we have only 10 been. So that's maybe not the perfect solution here. So maybe if you increase it to 1000. Yeah. This is maybe also not the best solution. So 100 bins for 10,000 measurements should be a good solution here. And what we can do, we can do many customization. So first off, all So let's plot again. Here re plot them. Our instagram. We're passing our list. Speak New York we are having on 100 bins. We're setting that able to New York data. We will see later what this will bring us and also be set Alpha 21 and the color off our surround to read. Let's draw the graph here, and it's essentially the same graph as a buffer. We only changed here. The color to red. Yeah, and then we can make your customization. So first off, all we can change the style we use to see Bon style. So you're there. Many starts and met plot lit, and it's more or less a Meddoff taste which style you want to use. So if you change it to see born, then it looks a bit today after friend. A bit more scientific, actually. And we can also change the size off the figure by using the function ph d dot figure and set the fix size to, let's say, 10 6 So now it's a bit larger. We can also change here, let's say 12 6 and we can also add a title to our graph with from the function, purity, job title and then we need to define the title as a string Zaheer measured cast speed, speed limit 50 MPH and what we can also do. We can set the font size so the fun size could be 15 year. So it's a bit larger than the excess here. And then we can also introduce labels for the excess so we can introduce label for the X axis with p o t dot exe label and pass of a string speed. So now here we have speed and the same we can do with my little and for example, we can set the label occurrences number off occurrences here. And you can also plot the vertical lines with the function purity every lines. So on the purpose years to draw vertical line at the mean value off our collected on measured data for your let's see shift tab what we need here. So we need the X value, and this is the mean value off our list. Speed New York. So we take the sun divided by the length, and then we also have to define the minimum wire. Well, you and the maximum y value or so here can set it between zero and 400 and then we can define that the colors will be read and the lines should be here best. And the labour sapir mean New York. So let's see what we get here. Right here. You can see we can see the dash line. But this our history Graham, is entrance baron. Yeah, we cannot see our dash line here, and therefore we have to change the Alfa off our history. Graham. So l five equals one means and there's no transparency off our instagram. So if you change it, Teoh, let's say 0.5 Oh, instagram here is getting transparent. And then we are seeing the vertical line here next to consider the range off the axis. So here, with P o. T, not excess. And let's see what we need here. So we have to set X Men expects Wyman and why, Max. So why should be between let's say zero and 400 extra p patryan. Yeah, 30 and maybe 90. So let's run here. And then we can also set the ticks off our access. So to say, here we have ticks at 2 30 40 50 and If you want to take that, let's say 30 35 45 we have to change it here. So from 30 to 91 we want to have ticks at every fifth value. So here we are, and the same we can do with them. The by label. So he had makes sense to have the attics that every fifties number, So we already have it here. And then we can define if you want to have the grit here or not on by default with, um, the Seaborne style. It's enabled, but we can also disable it with force. Let's make it for Oregon. And before we had to you in our history, Graham, we had the label New York data on in our vertical line the label me in New York. And to show the labels we have to call the function purity legend and in with beauty letter , we can define the location off our legend. So let's enable it here. And that's press shift tip. So here location strings so you can pass best or alternatively, is the row are upper right? This one here I have center right center right a seven and so on, and we also define the fund. Size equals 13. So let's see what we get here. So now we have here our legend, and we can also make many more plots within one graph. So let's assume we're going to Boston and also measure 10,000 times the speed in a street with the speed limit. 50. So let's assume the Boston people are driving faster and Everett 60 MPH and 50 MPH sown and the standard deviation. Eight. So let's create another random numbers and start in the list. Speed Boston. And then you can also block the history Graham here from Boston for purity his we passed speed Boston reset pins to 100. Set the label to Boston Data Alfa Equals Opened five and the color to blue and let's see what happens. Yeah, here we have both its program some New York and from Boston and one graph, and it makes it very easy to compare. And we can also enable here the vertical line at the mean off the bustin data. And here we can see. On average, we have The Boston people are driving faster than the new York people. And also with Mariah ability off the Boston Data's retire. So it's a bit more digress here because the standard deviation off our Boston data waas higher with eight. All right, we have finished. No, with them. Our shot introduction to met blood lift. And if you want to go deeper into details, I recommend you to go on the documentation side. So here you can find many examples and tutorials. And if you have a look at the examples so you can see here, yeah, the options are actually unlimited. So there are hundreds or thousands off examples here, so have fun if you like, and I hope you and tried this session and take care Bye. 23. Class Project 1a (Sticker Album) Intro: hi and welcome back to the cost. So this is the intra session to our single album Challenge, and I have provided a instructed and inject of coding exercise. You can coat the sticker album challenge on your own by using a job with a notebook that I prepared before for you. So we all know that practice and coding on your onus and the best way to learn and improve your skills off coding. And if you haven't done it yet, you can in the first section of our costs, download the materials. There are also the stupid A notebook is included, and before we start going quickly through the notebook, I want to show you how to integrate, find and open the downloaded notebook, your anaconda environment. And therefore we assume that we already have downloaded the materials fired toe our desktop here. So this is the file that you can download in the first section off our costs, and then we have to copy this fold into the fold of air you installed anacondas freeze a body for its in the users for so let's have a look here. So you just fold us typically on the C drive and then use us. And this is my users folder here. And they can see on a conduct Tereus installed here. And then what we do, we just copy here our materials folder into our users Father and the unsub here. Our materials folder with extract oil. So now here we can see it. Yes, Our materials holder concept with our five to better notebooks. And here, the stupid and up acquired sticker album Pricing basics coding challenge. So that's the notebook we want to open if you want to ramic the coating off the sick album challenged on our own. And therefore now we opened the Anaconda Navigator and relaunched to been a notebook. And here we are on our to better notebook despot, and we can see here you have the folder materials. So we opened the folder here and one more time. And then we can see here our 52 but allowed books them that we don't load it. And then we're opening the tube in a notebook, a sticker album, pricing basics calling challenge and every hour. All right, so I shot background to our challenge. So the assumption is and that you want to buy a sticker album, Let's say the football World Cup to 18 Ibom or enough air collector cuts, and there are certain amount off unique cigars you need in order to complete your collection. So let's say we have 600 unique Stick us in our World Cup album, and we all know that the status quite easy. So we buy some stickers and there are new and their unique, and I won't see by more and more Stickers Way are suddenly getting duplicates in the stoop like it's It's getting harder to complete our collection, and therefore our task here is to analyze, quantify and visualize and this effect and draw conclusions and then optimize our strategy that minimize costs to complete our album or our collection. And we also have some assumptions that we can also relax later on. So the basic assumption is, um, that our stick us are uniformly distributed so artistic us are produced and sold in equal quantities. Or, in other words, the probability of getting a sticker is equal for So let's assume we have 600 eunuchs, Sigel's and the probability of getting a certain stick us all. It's safe for example, sick of 246 it's one divided by 600 if you buy one sticker, and the second assumption which we will use is actually that way, we can order certain amounts of stick us directly from from the bend off the singles or albums. So let's say we have bought many stickers and paste it into our album, and in the end, twisted us are missing. So 220 for example, and stick a number 210 and then we can order those directly at the vendor off the sicker album. Typically, this option is limited toe 20 or 50 stickers, depending on the size off the album. And typically these orders stickers custom but more than than the on everyone. And our sad assumption is that typically we buy stick us in a pack off. Let's say fast stick us epic and this is the guarantee that within a pack there are no duplicates and this issue as a very small impact on our analysis. However, at this point, you want to neglect this issue, and we just assume that we are buying singer stick us and then that are not blundered into pecks of you Spy stickup has to go. All right, So let's go through the notebook and you can see here we have always a description off why and how we are doing this and that. And we have also some coding instructions that helps you to make your own coat. And if you want to check if they are called, is correct. Or maybe in the case that if you do not have the right idea about two code yeah, you can simply have a look at the solutions notebook or you watch from the solution video. So let's quickly go into the case, and we assume that we have a cigar. One with the 660 acres consecutively numbered from 1 to 600. And we want to buy 800 stickers. So our budget allows us by 800 stick us. And what we actually want to know is how many unique suggested we get when we are buying 800 Stick us. So this is the background here off our story, and then we get our first coding assignments or we should assign 600 to the varietal alone capacities. So here we should write. Album capacity equals 600 purchase tickets equals 800. And first of all, you want to simulate the purchase off 800 stickers one time. So getting started with one simulation and we use in the random what you're here and you also using for loops and if statements here and in the end, once we are finished with our coats, our code works with one simulation, then we're heading over to many simulations, so assimilated the purchase off it on its biggest one time we get a solution. Let's say 493 unique stick us. But actually what we want to know is that what can we expect on average if you repeat this process many times? So this is a more probabilistic approach, actually. And here we start with 10 simulations, and in the end we end up with sponsored in simulations and we have 1000 albums are 1000 results. So let's say we have for the first album 493 year unique stick us for the 2nd 441 and then we're calculating statistics. So me and Max mean and media and we will also go to plot our results in the history Graham . And once they're finished with this, we want to automate our code. So we want to vary ate the pyramid, us everyone capacity or artistic us and so on. And therefore we want to write a function called Sticker album where we can automate our coat there. And then in the end, we want to self more advanced problems and make some optimization. So here we assumed that the capacity of our album 600 but the vendor allows us toe by the last 50 stick us directly from the vendor. So actually, in our to say, Random Pro says he only need 550 unique stick us and t