Get Skilled in Python Fundamentals | Moustafa Saad Ibrahim | Skillshare

Playback Speed


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

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

111 Lessons (7h 24m)
    • 1. Welcome Part 1

      3:02
    • 2. Installations Overview

      4:13
    • 3. Installing Python on Linux

      1:16
    • 4. Installing Python on Windows and Mac

      2:46
    • 5. Installing PyCharm Windows and Mac

      1:27
    • 6. Installing PyCharm on Linux

      2:25
    • 7. Creating Projects using PyCharm

      8:14
    • 8. Printing

      7:38
    • 9. Syntax Errors

      4:54
    • 10. Indentation Error

      1:03
    • 11. Printing Homework

      1:50
    • 12. Data types and variables

      4:22
    • 13. Variables Assignments

      5:12
    • 14. Identifier

      4:10
    • 15. Dynamic Typing

      5:11
    • 16. String Manipulation

      4:41
    • 17. Function

      6:42
    • 18. Reading

      6:47
    • 19. Variables Homework 1 - 4 Easy Challenges

      2:19
    • 20. Variables Homework 1 Solution p1 p2

      2:26
    • 21. Variables Homework 1 Solution p3 p4

      1:34
    • 22. Variables Homework 2 - 2 Medium Challenges

      1:21
    • 23. Variables Homework 2 - Solution p2

      1:51
    • 24. Variables Homework 3 - 3 Hard Challenges

      2:55
    • 25. Variables Homework 3 - Solution p1

      1:27
    • 26. Variables Homework 3 - Solution p2

      3:36
    • 27. Variables Homework 3 - Solution p3

      1:46
    • 28. Arithmetic Operators

      8:05
    • 29. Assignment Operator

      4:17
    • 30. perators Precedence

      5:26
    • 31. Operators Associativity

      4:40
    • 32. Relational Operators

      7:34
    • 33. Truth Table

      7:04
    • 34. Logical Operators

      9:02
    • 35. Logical Operators with values

      3:39
    • 36. Logical Operators Homework 2 Challenges

      1:04
    • 37. Logical Operators Homework Solution p1

      2:40
    • 38. Logical Operators Homework Solution p2

      3:29
    • 39. Membership Operators

      4:31
    • 40. Modulus Operator

      5:43
    • 41. Division and Modulus Homework 1 3 Easy Challenges

      1:54
    • 42. Division and Modulus Homework 1 Solutions

      2:56
    • 43. Division and Modulus Homework 2 3 Medium Challenges

      1:43
    • 44. Division and Modulus Homework 2 Solution p1

      1:53
    • 45. Division and Modulus Homework 2 Solution p2

      1:28
    • 46. Division and Modulus Homework 2 Solution p3

      0:33
    • 47. Division and Modulus Homework 3 2 Hard Challenges

      1:50
    • 48. Division and Modulus Homework 3 Solution p1

      1:26
    • 49. Division and Modulus Homework 3 Solution p2

      2:04
    • 50. Selection 1

      6:22
    • 51. Demo and Indentation

      7:41
    • 52. Selection 2

      6:56
    • 53. Selection Practice 1

      6:24
    • 54. Selection Practice 2

      5:28
    • 55. Selection Homework 1 p1 p2

      3:30
    • 56. Selection Homework 1 p3 p4

      2:10
    • 57. Selection Homework 1 4 Easy Challenges

      2:21
    • 58. Selection Homework 2 2 Medium Challenges

      1:01
    • 59. Selection Homework 2 Solution p1 p2

      1:58
    • 60. Selection Homework 3 2 Hard Challenges

      2:24
    • 61. Selection Homework 3 Solution p1 p2

      3:57
    • 62. While Loops 1

      5:40
    • 63. While Loops 2

      6:16
    • 64. While Loops Practice 1

      4:43
    • 65. While Loops Practice 2

      7:15
    • 66. While Nested loops

      3:33
    • 67. While Loops Homework 1 4 Easy Challenges

      1:34
    • 68. While Loops Homework 1 Solution p1 p2 p3 p4

      3:43
    • 69. While Loops Homework 2 Application

      2:35
    • 70. While Loops Homework 2 Application Solution

      2:16
    • 71. While Loops Homework 3 4 Medium Challenges

      1:49
    • 72. While Loops Homework 3 Solution p1 p2 p3 p4

      5:47
    • 73. While Loops Homework 4 4 Hard Challenges

      2:52
    • 74. While Loops Homework 4 Solution p1 p2

      2:09
    • 75. While Loops Homework 4 Solution p2 (cont)

      0:53
    • 76. While Loops Homework 4 Solution p3 p4

      2:16
    • 77. For Loops 1

      5:12
    • 78. For Loops 2

      3:25
    • 79. For Loops Practice Medium to Hard

      8:01
    • 80. For Loops Homework 6 Medium to Hard Challenges

      3:56
    • 81. For Loops Homework Solution p1

      1:08
    • 82. For Loops Homework Solution p2

      1:36
    • 83. For Loops Homework Solution p3

      1:02
    • 84. For Loops Homework Solution p4 p5

      1:35
    • 85. For Loops Homework Solution p6

      1:45
    • 86. Debugger

      3:16
    • 87. Debugging with PyCharm IDE

      12:31
    • 88. Define Function

      8:21
    • 89. Return and Default

      7:34
    • 90. Function Calling Function

      6:03
    • 91. Enumerate and Override

      3:35
    • 92. Local and Global Scope

      7:20
    • 93. Name Binding

      7:55
    • 94. Positional or Keyword

      3:53
    • 95. Docstring

      3:52
    • 96. Function Homework 1 4 Medium Challenges

      2:40
    • 97. Function Homework 1 Solution p1 p2

      2:19
    • 98. Function Homework 1 Solution p3 p4

      2:56
    • 99. Function Homework 2 Application Solution

      2:33
    • 100. Class and Object

      6:31
    • 101. Methods

      5:28
    • 102. Constructor

      5:10
    • 103. str and repr for Class

      6:00
    • 104. Class Homework 1

      1:52
    • 105. Class Homework 1 Solution p1 p2

      3:10
    • 106. Class Homework 2 2 Medium to Hard Challenges

      2:47
    • 107. Class Homework 2 Solution p1 p2

      3:26
    • 108. Mutable Objects

      5:56
    • 109. Immutable Objects

      7:52
    • 110. Identity Operator

      6:24
    • 111. Garbage Collector

      4:44
  • --
  • 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.

5

Students

--

Projects

About This Class

d853508d.jpg

Many programming courses focus on teaching programming syntax but much less emphasis on skills!
My Python course is your way to master critical skills that differentiate software engineers.

In this part of my "Get Skilled in Python" series we will learn the fundamentals.
Through very extensive practice and homework sets, the course sharpens your problem-solving skills. Contrary to other students, you will have an easier learning experience in data structures and algorithms courses. Sharpening your skills after the course with more practice to get an offer to these companies should be an easier experience. The ability to tackle computational problems differentiate programmers. No wonder that interviews in Big companies such as Google and Microsoft are based on this skill.

Content wise, we cover in this part:
- Installing Python
- Running Python Code
- Printing and Indentation
- Data types and Variables
- Full Operators Coverage
- Conditional statements
- Loops
- Debugging
- Functions
- Basic Classes and Objects
- Memory and Mutability

Meet Your Teacher

Teacher Profile Image

Moustafa Saad Ibrahim

Educator, Software Engineer, Scientist,

Teacher

The most critical difference between my courses and others is ... going beyond knowledge: With me, you get really skilled. The extensive amount of quizzes, practices, homework, and [real] projects ranging from easy to hard will reshape your skills.

 

I have been teaching, training, and coaching for many students in Computer science and competitive programming.

 

I had been competing in ICPC programming competitions 2005-2011 (ranked 3rd/2nd/2nd in regional ACMC ICPC and World Finalist in 2011). After that, I played roles such as contestant, coach, problem setter, judge, and chief judge.

 

In addition, I have a mix of experience in Software Engineering, AI/Computer Vision Research, and A... 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. Welcome Part 1: Welcome to my gets killed in Python, seers and birth one, we focus on the fundamentals of the language. Mini programming courses focus on teaching programming syntax, but much less emphasize on a skills. In my seers, the core focus is on skills, not just knowledge. During this part, we will cover fundamentals such as branding, data types, variables, operators, loops, selection, functions, some basic knowledge about classes, objects, and memory. During this part, we will focus on the basics of the problem-solving skill, the ability to tackle computational problems, differentiate. Programmers know under that interviews and big companies such as Google and Microsoft are based on this scale. Through a very extensive practice on homework sets, the course of sharpens your problem-solving skills. Contrary to other students, you will have easier learning experience in data structure and algorithms courses. The course isn't only for guys who seek to learn how to program. Actually, most of the students who learn a programming lack basic skills. As, as our course is focused mainly on programming syntax. Little about me. I am Mustafa. Over the last decade, I have been training, coaching, teaching many students in both computer science and competitive programming competitions such as IoT and AI CBC. The keys to success in both of these activities is being knowledgeable and skilled in programming data structures and algorithms. I was among the best in my region. And I sub B C programming competition and was an I sub c would have finalist in 2010. I also hold that VHD in the computer vision field from Simon Fraser University in Canada. My career includes an extremely diverse mixture of teaching, coaching, software engineering, and research experience. I have enjoyed working on a range of a challenging projects and several exceptional places and have learned from many intelligent people. During my career, I learned how to be an effective educator, explaining concepts in an easy and practical way. I built a very strong understanding for the skills needed by the software market and have the option to transfer that to my students. Other relevant boys, regarding my background, I was active in teaching programming algorithms and data structures for students in the Arab region. My efforts are highly recognized by many students for having their background and skills are highly enhance it and programming competitions. I was known for my juniors and seniors training from 2016 to 2019. I supervise around 225 senior three needs of several different nationalities. For more about me, visit my website. That's all the myths. Such a unique learner experience. 2. Installations Overview: Section, we will learn how to install the Python. And by churn, I would like for us to provide an overview about some terminology finished about Python. Python is our programming language when we write something like print, double-quotes, hello world, it is a commanded that language to print Hello World it for us. It is what we call a Python interpreter. This is a program that will read your code line by line and then execute it. For example, when it's fine print HelloWorld lid is going to display on the screen hello world. So Python it that language. Python interpreter is a program. That's why in this section we will learn how to download and install this Python program. Right now. The most popular Python version is Python three, like 3.9 for example. Before Python 3, there were, there was the Python tool like to 2.7 for example. Python 2 is still active in many older projects. So a lot of projects are already migrated to Python 3. Your focus should be learning Python three, which is very close to buy some tool that is not that big differences between them. In Python to where I write like Brenda hello this way without the parenthesis. But in Python three where I Hello This way. From a system to another, there are different naming for the python programs. Sometimes the default word that Python is referring to by 72. And sometimes it's explicit bias onto and some systems you have to write it by three to refer to by sensory. And sometimes it's just Python. So sometimes you need to be careful about that. One way as we will learn is you can check with this dish version if you open the command line and you wrote something like Python, version is going to tell you what is it to version two, version three, if it is vision, then you have to write python3 dash, dash version. There is a package manager in them. In the early two of the course, you don't need to install the web, but I, it's good time to know about it. Bib is a package manager, so it's going to help you to install a lot of things that you might need to add to the Python. So there is the default to Python with default packages. And then the Bid manager is helping you to add more and more similar to the Python before Python 2, and that is pip3 for Python 3 in future, that is a stronger way to support the real life projects and what we call virtual environments. And coda is one of the very bubbler direction to that with Anaconda and mini kinda to-do for that. You don't need to care about that for the moment, but feel free to Google and learn about it. When we say the command line, we refer to typically a black screen like that. Guys from Ubuntu, Linux and Mac are very familiar with it. Guys from Windows, the bins like but if you try to go to the start point and search for command line or shell, it's just something like that. So here on my open to machine I can write Python dash dash version and give me 2.7 by three dash dash version and give 3.5 by three. If I did bit version, then I know that this big vision for bison to, if I say pip3, there's vision and say, Oh, you don't have big three vision or your machine and so on. We can use a command line to combine and run our brokers. However, the way that we're going to create is a more professional way and more suitable for beginners is a pie chart. By chart is a very popular and very good IDE for developing the python projects. It has a lot of features and a lot of credibility. One of the interesting features about PyCharm, it is mainly duplicated for Python, so it doesn't need to take care of many other things. You will find others, other courses or so using what we call leisure, we can look back. It is kind of an open source ID that help you to create some documents that can be used in a lot of live coding. So it's also something that's good to know about it, but she didn't need to do that right now. But so 3. Installing Python on Linux: In installing Python on Linux is much easier than other machines. It's typically bunch of commands. So for example, for Ubuntu, you need to do sudo apt-get install Python 3, then install Python 3 desperate. But it could have in the event that you have Python 3 on your machine. So maybe go to the command line and first test. Python 3. There's, there's virgin exist or not. For the, for the Fedora, you can try the DNF install python3 command or installed Python BIP for example, or a BIP three, it depends. For yum, you can also, if you have young tool, you can also use the same commands for centers also you can commands for the for the installation. After you install, I would like you to verify if Python is for vision 20 or 30. If it happened to be vision to, then try Python 3. If you happen to face any installation problem, just Google it. You will find a lot of people covering the different destinations. If you couldn't install BIP for any user for now it isn't big problem. We care for now that you have Python 3 installed on your machine. That's all. 4. Installing Python on Windows and Mac: Let's learn how to install Python on Windows and Mac. The first step you need to do is to go to this URL by python.org slash downloads. When you enter the beach, you will have something like that. A button here to DO Loop Python. It will be customized for your operating system. In case you would like to do something else, you need to go to the download button here. And typically you are going to lose some Python 3 x something, maybe 3.93.8. It depends. For Mac, It's just straightforward though, load and double-click and executed. You have to be an administrator to do that. For guys from Windows, it is a same experience, but there are some checkboxes that a beer from a vision to another. So I would like you if you found any of these checkboxes, consider them some checkboxes about installing launcher for all of the guys. That's okay. Click it. Or if you have some something, say 64 launcher or 32 lunch or it depends on your machine. So if you are machine is 64-bit, select 64-bit. There is something about the bath or the environment variables. Please indicate this is the most important one. For some machines it might tell you about disabled Beth limit if it's haven't breast breast this books and click Yes. So this table, the bathymetry, it's okay to associate the wettest files with BI files. So init.py file would be attached to biotin and later to the ID. If it asks you to create some shortcuts security of them. Otherwise everything is very straightforward. Feel free to change the installation directory to something like that. One question is, am I 64 bit or 32 bit? If you try to Google for that, you can easily go to the start point to the sitting system and about, you will find the line about the system type. And it will tell you if you are 32-bit or 64-bit. Typically, many of the recent machines are just 64. Habit. If you are confused, please visit this link. Finally, for guys who are still using Windows seven or earlier, you cannot install Python 3.9. You have to install an earlier version. So for that, you have to go to the login slash Windows. You will find the first column about stabler release and find a vision that might fit with your machine. But be careful if you are 64-bit, select something that has X86 64 executable installer. It have to have the word executable. It will be an EXE file. If you are 32-bit, then you select something X86, again, executable, an EXE file, download. That source. 5. Installing PyCharm Windows and Mac: Let's learn how to install by charm for Windows and Mac. First, sip is Google, the road by chore and go to the JetBrains website here, and it would proceed to the download page. You would have three tabs, Windows, Mac and Linux, selected the right tab for you. And the community version, it is a free version. There is also another one for professional and spade one. So focus on that guy. You might be faced with the requirement list about your system like is your system two gigabyte RAM, double-check the requirements. And in all cases though Lu than installed in a solution is overall a very straight forward just double-click and execute. Format guy is the need to keep going with all of the details. Once it asked you about the theme, selected is a dark theme or light theme. Suppose 70% of developers are using dark theme. Feel free to go with that. Otherwise you don't need to play with the options. If it asks you to import the sittings, say no, if you are the first timer, then just know for Windows guys, some experience. Just a, you might have a link for 60 foot, 60, four-bit Launcher. Click it. Unless your system is 32-bit, then you should select the 32-bit launcher. It would help you to double-click on the lunch or later to like open the application. That's all. 6. Installing PyCharm on Linux: To industry by storm on Linux, you may need to go to Google and just try DO Loop by Chun. Then you go to JetBrains website and proceed to that. You will find here three tabs. Go to the Linux tab and then click the community visioning. And the community period is a free one, the fishnet, what is a big one? It might give you a less requirements like your machine have to be too eager. I'm just just double-check the requirements, but in all cases just double loaded. Once you they'll look at you will have some files compressed like the JS, for example. Right-click on it or is a command to extract it and go to the extracted directory, let's say by charm community 2023. And then open your terminal, for example, with Control Alt T, go to this directory. Let's say that the directory is a guy inside that you will have some bin directory go inside it. There is a pie chart. So just run in the terminal, this dashed by charged with CED to open it. If it asks Could you to import sitting just say no for the first time. So here is my, my concern. I go to the directory. If you can find the bend good to Ben and then by charm for me. So make sure to run them by Chairman from the bin directory, not from the original director. During running it, it might ask you about customizing the UI theme. Do you want the court to appear in a dark background or white background? 70 percent of verbal supposed to use the doctor but ground on a personal level, I use the light one. It's up to you. It might ask you to install it and the extra plugins, you just kind of skip that, you don't need it at the moment. That's sold. Some troubleshooting. If if if, if if running the bot Sharma file give you a permission denied error, then you probably just need to make it a read, an executable file. So I click on the Bashar fired and click here, allow executing file as a group home or from our equivalent if you'd like to do that and try again. If you are confused from any step here, visibly see this video. Otherwise, if you have some weird the herbs which might happen sometimes, but guys just googled them. Most probably will find a solution to the problem. That's all. 7. Creating Projects using PyCharm: Let's make a demo and creating project on by charm. You open by charm like me. If you have projects like me, you will have a lot of them here. If you don't, you'll have an empty screen with some button to create a new project. But in all cases you can come here and say File New Project and then give it a name, let's say. And the important thing here is about the environment. There are options here I would like you to do with the visual n, which is creating kind of an environment for you to use for your Python. And here is the interpreter, the interpreter of your system. This is very important to make sure that you are selecting or go here and browse for whatever interpreter version that you have in your system that previously configured interpreter or existing. Smart about other things that we will meet maybe in the future. For now, let's create it is going to give you three choices. If you have a choice to open in this window, in a new one, what I completely new window or attach it to this project would typically click Attach. But for now as a new project, let's say new window, it's going to open a new window like, like that one here. Some indexing as long as these guys working you have to hit him. Once it's done, then we are good to, good to go. This is our n, we don't come, don't touch it. But if you would like to create a file, let's say Come here phi a new Python file. And let's say this one will be y. Now we'll get our first file here. Let's say a print. Hello world. Let's work on another one here. Now, sometimes it tells you that there is no interpreter attach it for a reason or another and probably would not face that. But if it happens, you click Configure. You tried to select or go to interpreter sitting and go and try to select it from your menu or find it here. For now, as I am open to 16, I have some problem with 3.5 vision, but, but don't care about that. Let's try to run this program. You right-click here and say Run Test 1 is going to show you the output here. Another way to run the program is to come in this menu. If you have many programs, you will find all of them here. And then like this one here we click it and then this guy, this one. I'll see you can come in this menu, I click Run and this one. So this is how we created our program. Let's create another one. Again, Python, let's call it now. To do Python here. Let's do something very similar. Let's right-click and run test to. Now you need to hear the menu would have just 1 and test 2. This is how we write our own, our own code. We will learn soon that we can make comments like that. Hello, Mustafa, everything is okay. I'm, I'm showing you more features in bicarb. This is something like that. By short, module will highlight it like that for you telling you that there is some problem in the Toward you can then it is going to suggest for you replacements, this is like the upside that do some spelling checking for you and correction. So this is a nice feature in PyCharm. Another feature is you can come right here and right-click and say Split, split, right? You see what happened here. It gives you like to Windows. So now you can have like some window here and some window here maybe doing some comparisons or so. So this is what my speech. And by short and you can again split again, right? Come here and say split. So more and more windows. This is very, very nice when you would like to compare things together. Also, that is what we call the delimiter. If you come here and you will, you'll feel that the charm is giving you some, some warning here. If you come in, stop here. You are studying you something bad. Too many blank slides. Remember, there are occluding gliding guidelines. And the standard decoding line deadlines for Python is called BEP. And here is telling yes, there are too many black lines, blank lines are empty lines. So it means that there are a lot of lines here. We can come and do something like that. Now you see the error is gone because the standard is to have maximum 111 empty line between two things. The moral of that, what we were using something called winter, there is a built in length or hear that do some chicken for you if you are following the standard, they're not. As an advice, always a chick, if there is something in your code and they read the tab and then the tip will learn knew something about how to improve your code more and more in the future. Also, there is something that we call the local history. When you right-click here and come and say look at history show history is going to show you a lot of the history of this file. Sometimes you will lose the old division of your code and then 0. What is my code? The look of history is one very good place to show you. The old, the good and the new code. This is very, very nice feature. Now, there's also what we call the program structure here. If you click that the structure is going to show you some structure for your program in the future. You might have something like say functions. If f here, nothing. You see here, it started to add a function here for you in the future, we will have many, many, many, many functions. And then the structure will be very handy for you to move directly between function, especially if you have, let's say, 100 lines of code. So this is also another one. Nice feature in your code will learn soon about variables. So let's say I'm, I'm seeing some var equal a 100 and then printing, but I know that you're going to understand what, what is that variable at the moment, I'm just showing you some feature here. In the future you can come and noblest that guy for me. You say Refactor, Rename and then give it a new name. Notice here button bar. Once we refactor it is going to change it in both places. So this how we make good things in good. You can also, let's say you would like to replace something. You can click Control R. And then let's say we give it, let's say the word Mustafa here and ask it to make it more stuff almost of a Mustafa, then rubisco is going to make our investment. I'm trying to show you more features in your code. There is also a nice feature here is come in the Edit menu, and you will find a lot of very nice features here. I would encourage you to try to explore all of that. Maybe toggle case, for example, here you see all of them. Switch it from lowercase to uppercase. I think this is more than good enough for now. Yeah, it is a find, the feature that find also consist for you in the code with something. So edit stuff on the project and edit and tell him find, Find in Files is going to serve you for something that matches what you need. This is very handy feature when you have a lot of files and would like to search for something course all of the files, if I would like to search here only I can write colonial control F is going to search for you here, Control F over here. But if you'd like to search the whole project, still on the project, edit and then find, Find in Files. And it started to write something here. Let's say I would like to find print. So it's going to show you all of the things that are relevant to what you are doing that have the breadth of function, which is a lot here. I think that this is the most important for now. And I think the most fundamental is to learn how to create a project at the moment. This is always your screen. This is where you see some of the outputs that all 8. Printing: In this video, we'll learn more about printing. Let's read this program. The first thing that you see here is this hash. This hash is what we call a comment. When the interpreter remember that the Brewster is a program that go in your code line by line to execute it. When the interpreter find this, hash, it know that this align that should be ignored. So this has no effect on your program. You can write whatever here. If you have a line of code that you think is boggy, you can just comment it with this hash. And the second line we see print hello world, and this is going to bring the Hello World here. So I'm making another comment here on the side to show you what is the exact output of this layer. For now we have another Brenda year, but this time we're using this, this style. So with this, we call that double-quotes. We call it double-quotes. So now we see we can print with a single quote, two single quotes, or double quotes. Both of them are okay to bring something. The brunt, as we said before, is a command that, but specifically it is a function. We will come back later to that to even write our own functions. These two things we call them parenthesis. And this are single cause, this are double-quotes. Everything here is a little like English letter for example. What is between hello and world this year in the middle is what we call a species, as we see in the last video. About this program, has two instructions only and has to Albert lines of code only. Behind the scene. What is happening exactly? As we said, when we do something like print HelloWorld, the interpreter will bar. So this line of code, when the interpreter find the wood, the brain, it's going to know that this is a function. It will finish expected that you will have something like open parenthese with the double-quotes, for example here, this very informal discussion. And then it's going to social, for example, for the first double quote here. And then expecting after it, another parenthese. If it didn't go well with him, it would just come winnable the line of code. So it find the brand, then it will find this parentheses, and it's a closing parentheses. This double quote, double quote, brent, what is in between? This would informally what the bursa is doing behind the scene. Let's see more of the Brinton. I'm here printing Hello World. I am Mustafa. So the output here is hello world. And most of what I'm writing here, there are three double-quotes here, and another three double-quotes here. This is what we call a multi-line comment. A multi-line comment is just an area that is completely ignored by the interpreter. So from line seven to line to line 16, all of that would be ignored. So now we learned two ways to let the interpreter ignore what we're doing. We'll learn about the hash. And now we're learning about the multiline multi-line comment also. Otherwise you will have to write the hash for every line here, which might be not that best idea. Another interesting thing is what we call the backslash. Backslash n here, right, hallux, then a space. Then you see this later in your keyboard. Backslash. Backslash in is what we call an escape character. And it simply asks you the interpreter to Brent alive. So here is what the printer will be doing. It will read the word hello. So it's going to print it, then it fine backslash n, it means goo next slide. So it goes here to this line. They didn't find the word world is going to print it, then find another backslash n. So it's going to a new line. Then printing, I am Mustafa here on a new line. So this backslash n thinks that starts with the backslash r could escape characters and the backslash n is one of them to print a new line. It is another example, space hello, so it printing space hallux, two species worldwide sprinting two spaces warranted three spaces. I'm Mustafa, it's printing Mustafa. You can differently, right? Three lines to bring to that, but we can easily make it in a single command here. So notice here now this is a single command, is printing the three lines. So the moral of that is the backslash n asked for the interpreter to start the Brinton from new line. A very interesting also style of writing is as following Hello World. But beginners will assume that this is going to be printed in separate lines of code. This will not happen to have live in separate lines of code. You either need to write different printer commands or you use the backslash n. So what's happening here? We are just separating the message on several lines in terms of the code itself, not in terms of the album itself. So the way that the combined it, he had low speeds, space, I am Mustafa. So don't get confused and think that this is going to bring three different lines. This is a single command over a single message that all of them are granted on a single line. In addition to printing messages or what we call strings, we can also do some arithmetic. For example, if I say Brin, one plus two plus three, it will print this x. Three times four, 12, 6 divided by 2, 3, 1, 0. Interestingly here we can have many spaces between the brand and this parenthesis. This is totally okay. Seven over two is 3.5. But notice here, if you put a single quote, single quote, 7 over 2. Now the interpreter knew that this is a message to be printed as it is, not some math operation. So this would be printed as 7 over 2, it will not be printed as 325. So differentiate between doing the normal math without single or double quotes, and between using the single or double quotes. The last thing to learn here is about the coma. This character in the letter from your keyboard, we call it a coma. We can actually print using comas in the, in the brain to function. So I can say here as fallen, Brent, and I give it here, that is, this is a message here. It has its starting code and ending code. Then coma to print something else. I'm here printing a number, coma to printing something else. Again, double quote, double quote. Every item between this comas should be valid by itself. So this is another valid message. And then two times a three. Now observe here the Albert there is printed then space, one space. So what every coma is doing it also printing. So this coma would be ribose with a space. This coma will be replaced with this coma ribose with a space. So this is a single message. Again, notice it a single command. The are all written in a seam line of food. We're just separating them. In practice. We don't could this way normally, but it's Crystal Good to know about it. That's it for today. These go-ahead to id1 or your IDE and try every line of code that we did today. 9. Syntax Errors: In this video, we'll learn about the common errors that typically beginners might do. Let's look to this line of cool. I would like you to take a moment and think what is a problem here. And after that, I would like you to read the messages written here. Always do that before I speak. So the issue here is the message closing parentheses here, as we said, we have to respect and follow the instructions and the syntax format of a language. Looking here too, this is by short-term editor. So there are a few advantages here. The first is the syntax highlighting. The idea here is highlighting that something is wrong here. So this is a good way for you to figure out lines at that have problems. The second is a message, it seems here also, the compiler gives you, you see this like kind of an arrow is telling you there is some problem here. And there is a message that happened to be useful, missing branches in cold to Brent. Brent is a function, so we say calling a function, that's why we say here, cool Print. And also making correction here to tell you maybe you are missing this parenthesis. You find also the exit code. It's a exit code one. Exit code 0 means everything is successful. Exit good. One means there is some problem here. Another problem here is mixing between single quote and double quote in a wrong way. You see here we started the message with single quotes, but we ended it with double-quotes. You either have to make it single quote, single quote, or double quote, double quote, but do not mix them in our own way. So be careful about that. The message here is very hard for you to understand and the woman. Now, this is a bit tricky. You would like to write something like let's learn. And then you use the single quote here, single quote here. But it happened that the message you have another single quote here. Now, this is very problematic. Why the interpreter here find this single quote, and then finally another single quote. So it will think that his message is done. But after that this guy is wrong, is structured. It doesn't have a new single quote or anything that is valid. That's why it's problem. So now the question is, what if I will dry really to bring something like that? You have several ways to do it. The first way is using an escape character. If you use the backslash single, a single quote here is going to bring to the single quote for you as you see here, a more elegant solution is to make use of the double-quotes with the single quote. So you can define the biggest, biggest drink that who would like to bring to the big message with double quote, double quote, and then inside it you single quote. So you see, you can normally no use single quotes here because the interpreter, when it see this double-quotes, it will consider only a closing double-quotes right here. So the single quote here is doing well. The, let's say we would like to face it. The other issue would like to bring to actually a double quote. Then you have two ways. The first is if you are starting with double-quotes and double-quotes, then do backslash double quote. This will let you print a double quote in the middle. Otherwise, and more urgent is let your message is start with single quotes and single quotes. Then NN, double quote in the middle doesn't matter. Over all. You should go with the way of line four and line 7. If you'd like to print a single quote or double quote in the middle of your, of your message. Now, what's shown here, the wrong here is that P is capital and the interpreter is case sensitive. So it's expecting all letters here to be lowercase or uppercase. So that's why it will complain that it doesn't know what is this print? Let's all for today. I would like you to know that we all make errors. And the target of this video is to make it shorter for you by recognizing some of the errors. Tip number one is code line by line. When you could line by line after each line tried to run to make sure that your current output is good. One of the big mistakes is to write a lot of good and then try to run it to discover that you have like 67 errors and have hard time to solve them. So write a line of code problem. But another line of code run this way. You make sure your code is growing up in a proper way. The second is Google is your friend. If you start to Google on arrows, you will find that there are hundreds of other people who already met this problem. Stackoverflow is one of the very popular websites that we go to it a lot and we find a lot of Hillbillies. So always tried to do that. You couldn't solve your problem in this way. Just go to the cuneiform and just raise up a question that said. 10. Indentation Error: One of these special errors in Python is what we call II error. The identification mainly refers to the species at the beginning of the line of code. Look to this line of code here. We have a client is three normal line. But in line seven, there are a couple of species extra here. If you tried to run this program, the IDE or the interpreter will complain with an error. It say, it says unexpected identity. Then it means that there are extra spaces. The more we go through the bifan, you will learn that something could if statements and for loops. And you will notice that we have to do some species, sometimes spaces, sometimes steps. So there are more about the kind of error. But for now, for simplicity, I would like you to keep every statement in the very beginning of the line. When you see something like this, I indentation error, it means that there is something wrong with your spaces. That's all. 11. Printing Homework: Our first homework in the course about printing. The first task is, I would like you to guess the runtime of this task. The word Runtime means that we are running something. So if you have a problem before running, we say it like say interpreting problem or so. But when you run a program, then we call it runtime. So I would like you to go to these five lines of code and guess the output of every line of code of them. We call this task, by the way, tracing, trace mean to go line by line and to execute the light. So go here and guess what is the output and here what is the output? And he would sell, but, and so on. The second task is, I would like you to write a program that is going to print exactly this line of code. Here. You have to use only for commands of printing on D. And they should print for us this format exactly. So you have to match it exactly. Like B have to be capital for example, and so on. The third task is right there good That bring to this sheep. Then another could the brain to this shape, then another cool that bring to this shape. Finally, I would like you to go here line-by-line, check, is this correct line, then leave it. If it isn't incorrect, figure out what is incorrect and tried to fix it. And that's all. All of my solutions are provided in this course. If you didn't find any of them, please bring me to provide it and maybe I missed it. Otherwise, do your task. Give yourself some time to think about it, then compare your answer with my answer and is very important to understand my solutions because they are very educated and have a lot of you to learn. So if even sold with the cost, you have to understand My could at least do your best with it. That's all. 12. Data types and variables: Today we will learn about data types and variables, which are fundamental topics in programming topic. Every day we upload a lot of data to the internet. Thinking about the Facebook blew a lot about yourself, like your age, your name, current job, address, and so on. And we share a lot of data also in a lot of meaningful information like the connection interactions between people. And there are a lot of data like that. But one interesting question is, what is the datatype of such information? Thinking like, I am 52 years old. 52 here is a number, we call it an integrator. The integrator here is the datatype of this number, or like this baby is 20.7 kilogram. We again consider to any point as a, as a number, but we call it here floating wind. The difference here, it always involved with this and this fractional part. You can think also in a word like computer, we call it a word. We call it here in bison string. You can think of something like, what is your gender, male or female? Sustained of two things. We call that Boolean data type. So this is that we really, we have in our real data, real life. And we give them some our names. Also the programming language give them some name. And it is a datatype of them. So when I'm saying I'm uploading a variable or value 52, I'm referring to an interior to 12.7, I'm referring to a floating point and so on. So this is what is a datatype. There are a lot of these types in Python. The three major one that we will focus on them on the early days of the course is the integer, which is just a normal integer. The second one is the floating point numbers, which has the dots like 12.510.5 to 0. So 200 by itself is an interior. 0 is now floating way. Now first thing in the string, the string you can represent any sequence of letters like Hello, World it 2000 and 3000 or some other non English names. It can involve anything that you can write. You can involve a species, underscores, dashes, digits, whatever. The Boolean data type is one of the interesting data types in programming languages. It usually represents something that consists of two things. You can think of them as follows, true or false. If the male is true, then we know that female is full. If you have a coin, the coin can be head or tail. So again to status is only computers understand only zeros and ones on and off. So on is through an office. For Python has a lot of data pipes, but for now we're going to focus on the numeric data types, specifically the Internet and the fluid, and also are going to focus on boolean. For the beginner, we will learn more about the other datatypes. One interesting thing here that if we have information and we store data in computer like 54 and 55 for my years old, we need to refer to them in the memory. So while we need to put this information somewhere like let's say in the RAM, we need to refer to them. And this brings us to the idea of variables 23, just that, think about the memory. Like if I say like, I live in 37 June is three. We know that 37 is some position in S3 that is named June. So there are information about the people here like say, B will have types like male, female, there are child and so on. So the memory is something very close to that. The memory have books. It should have a location like 1, 2, 3, 4, 5. And each book has some name. For example, age, weight, gender, name, and it has a value 55, 90.592 million Mastaba and so on. So over all, ij equals 50 to the name is H, We call it also identifier. The value is 50 to 59 and so on. That's all for today. 13. Variables Assignments: Last time we learned about data types and variables. Today we'll learn more about how to create such a variables and how to assign them datatypes. This is a very simple program. I would like you to stop the video for a minute and just read it line by line. Familiarized yourself with it. We'll learn today how to create a sign and change the value of the variables. Initiating, we have a memory. And this memory where we want all of our variables. And initially, you can think of it as something that's completely empty. And then we have the interpreter. And as we said the intro bit there is an interpreter is a program that's going to read your code line by line and execute it. So initially we have an m-bit theorem. Let's put a four hour for a sake of visualization, let's say that we have here the memory before align and an instruction, and here the memory after it. The first line here have something called Brent 55. So this is going to just bring 255. But the Brenton command here doesn't have an effect over the RAM. So, so far, so good. Moving to the second line of goods. Here in line nine, we have something, say age 55. So like the last time we say that the name of the variable or the identifier of it is, and it's a value is 55. Clearly this is an integer. Now, the memory is empty, but after this line of code, somewhere in the memory, we will have a variable named the age was 55, and the type of it is the equal here means assign. It takes it the value on the right side and voted on the left side. So that if the side here represent something, some, some books in the memory here, the books old age itself. And as we said, there is, there is definitely some memory location for every variable here. But we don't necessarily know where is it exactly, but we know it must exist. There. Let's proceed more with our goods. We have used something good, Brent, age. The brain is a function that receives something to bring to it. It can receive almost anything that is breathable. So when the breadth function receives this age, which is a variable, it no, it's something that in the memory and it has a value. So it goes to the memory. And the good, the value here, 55 and the brand. And the second line, we have a brain to have an exhibition, age of five. Again, the edge is something in the memory. The first thing it go, it goes to the memory and get this value 55. So now it's like 55 plus 5. Adding both of them together, we have the value of 60. Again, the couple of commands or just the printing. So there will be no effect on their memory from such a branding statement. After that, we have a new assignment command which says Wait equal 75 way. After the destruction. A new variable created in the memory with the value 75.8 and the type would be float. Again, printing this value would just retrieve it from the memory and just a printed over all. This are, this is how we create and assign variables in the memory. That is, there is no maximum limit for a string. Like you can have a very, very, very big statement. This is three, maybe up to the limit of your physical machine. In Python 3, there is also no limit for the interior. You can have a very, very, very integral that we call it. When such a big, we call it a big integer is very, very, extremely. If you are coming from C Plus Plus background, you would know that the integral is very limited. However, the float variable has a limit. This is the limited value of the fluid value. Take a minute to two to read it. If you thought about it, we have number like 1.79, which is almost to two times ten to the power 300, 800 eight. This means that 300 zeros. And we have here like two. So over all, the float is a representation for 30909 digits and 11. Very interesting thing to know is the float is an approximation. It isn't accurate, especially when it comes to big numbers. It is more about representation that represent the fractional birth, but in an accurate way. So this is the catch here. It's a bigger presentation. 300 08 is typically way beyond most of your needs in practice. Both still it is inaccurate. In the future. You can write these two lines to bring for you the minimum and maximum values for the flute. But in the future we should understand more is meaning. That's all. 14. Identifier: So far we learned through our variables. And a variable has a name and has a memory location, and has a value, and has a datatype that the name of a variable we call it also identifier. So when I say sum equals, sum is a variable name or the identifier of this variable name. It typically just say it can be a word like status one, total underscore, underscore valid is underscore value and so on. But there is one interesting thing here is, what are the limitation on the names? Can we intimate anything? The answer is no. One of the rules is, you cannot start such a name of a variable identifier with a digit. We can say somebody would like seven, cool, You cannot do that. It shouldn't start with the sibling with a digit, but it can have in the middle digit. The second thing is it cannot continue speech or any of these critters. So if I say something like my dash bar, this is going to be wrong. But you can use the underscore. So you can say my underscore var. Also, names in Python are case sensitive. So variable name like some isn't the same as the variable name, some. So these are two different woods that are also in Bitcoin, what we call add keywords. There are a bunch of keywords that you probably know nothing about them in the moment. Take a moment to familiarize yourself with them. The more we go in the course, you will see them. You shouldn't use any of these names as a variable name or the program will fail. I very common guideline is to use lowercases in naming variables and to use underscores to separate them. So you write something like total underscore serve as a variable name. You don't write total sum where you're going to use a capital letters. This is just the common good life. Like maybe in your company they would have a different agreements. But this is something very common among engineers. Let's borrow some ideas from engineering. The first thing to know about is variability. When we write a good, it should be readable. It should be easy to read. So you should always think that someone else is reading your code and you would like to make his life easier. You don't, for example, Nim, something like S equals 0. This is a very bad name. It doesn't say anything. Maybe a good name is something like total sum equals 0, which means probably we will be summing something. Maybe summing salaries may be. So think about your code and about its heritability and its alignment and so on. In companies that are also something we call good review. Every time you finish coding some task, there should be one or more guys who review your, the review has several purposes. For example, it makes sure that you follow the coding guidelines in the company. It also is going to review the logic of your code. And as I said, there are some coding guidelines that are similar to one of several. One of them's. I'm referring here to the Google Python style guidelines, which is a list of do's and don'ts that you should do in your program. I would like you the more we go in the course may be after like 23 sections, start to give regular leading to such bifan getline and follow it. Note that for educational purposes and for simplicity sometimes I might, but it couldn't get lights. I might defend something x equals 0. But it's just for making variable names short to make it easier to learn. But you should stick to something like that in your life developed on your server. So far, I would like you to try to create different variables and the names in your program. Try to bring to them, tried to bring to the exhibitions with some plus-minus aesthetic multiplication, tried to catch errors intended to violate the syntax and read the error message and so on. You should find my good uploaded for every single lecture. If you haven't that something is missing, just let me know. Probably a mistake, a blade with them initially, then try to create your own variables and errors. That's all. 15. Dynamic Typing: In this video, we'll learn about dynamic typing, which is a great feature in Python. We can change the values of the variables, but also we can change it a type of the variable. I would like you to take a minute to read this whole program. We're going to trace it step-by-step to learn how Python help us not only to change the value, but also to change the type. Let's go. And line 3, here we have 55. It is a command, it means go to the memory. But the variable var, its initial value is 55, which is of type integer. So far, so good. And line 6, we started to reassign the value in the memory. So var now has the value 10 going to the memory. The new value is going to change it to 10, but the type is same. So what has it changes so far is the value change it from 55 to ten. But the integer datatype is still the same. And line 10, we say the bar, bar plus 5. Like the Brenton command, verbalise five, which is on the right side of the equal, is an exhibition. So what is the value of var right now? The value is 10. So now this is the noblest to stem. So var equal 10 plus 5. So ten plus five is 15. So the memory would be updated with the value 15. Again, notice that the value change. The data type is same. What do you say, Brent var, it goes to get the var from the memory which is now 15 and just print it. Now enlightened 60. And there is something very interesting. We started to say that var equals 6.5. So this means go to the memory. Ruby's the 515 here with 6.5 so far so good. But the very interesting thing is the datatype itself was six. This is now the datatype itself with integer. It is now a flute. Python allows us to change the value and allow us also to change the datatype, which is a great flexibility. Here in line 19, we're going to assign the var 2, 3 times a bar minus Y bar. So the var in the memory with 6.5. So this equation is like three times 6.5 minus 6.5, which was overall is 13. So the memory will be updated from 6.5 to 13, but the death of five will not be changed it now, going one more step. Now we say var equal a string, the value of Dr. Mustafa. So there are two changes here. The value 13, it would be changed to Mustafa, and the value of the fluid will be changed to the datatype of studying. As you see, the dynamic typing allow us to change the datatype of variables. So when we have variables like integer float, string of a variable, there are actually two questions in a integral grabbing language. Can we change the variables type from a line to another? And those languages chick that before or during the running of the cool. Python is a dynamically typed programming language. It means that the types of the variables are a chick that during the running of the program. This means that the N, and also it allows us to change the variables during this runtime. So this would make it dynamically typed in, in, in contrast to that, there are other language that we call them statically typed language. If you are coming from a C plus plus or Java background, if you declared the variable as an integer, it will remain as an interior and it will not be changed. So in a dynamically language, the type can change. In aesthetic language, the type cannot, cannot change. And this implies something. If the type can be changed, then we need during the runtime of the program to check one by one, what is the new type? If the new type moved from integer to a float? With two of these, the statically language like C plus plus will typically do the check before running. So there is an advantage here. If a tenant that you write some code that has a bug, they say the variable whose integer and assign it to say string. The combiner of the bus will complain early even before running your program and say, Hey, why this datatype is it changing from integer to string, from flow to integer? Why there is, sorry, from the flood to string for Gumbel. So the chick here had been before running because we can do that. But here there is no meaningful such as check before running. We actually allow the change of the variables during the running of the program itself. And this is making it very flexible to write the code. But the more you get experienced with Python, you will know that this feature can generate a lot of arrows at the runtime and in the ship that could encode a lot of problems. So every sing, everything has pros and cons. That's all. 16. String Manipulation: In this video, we'll do some playing with a string. We'll learn about some of usage. So we know that we can bring something like I am will suffer. But the interesting thing is I can use the plus operator. So I can say I am losses. Plus Mustafa is going to print I am Mustafa. The plus is an operator. There is a new section that is named the operators. You will learn more about that. And the interesting thing here is we can concatenate, we can concatenate strings. So the plus operator can do this as string concatenation for us. Let's see it more, more examples. We can say have a string, one, I am, and I've got a string to Mustafa with the space here, we can write is the R1 plus R2 and is going to give you I am stuff. So the moral of that is, we can write this, this plus operator to concatenate two things. Even Python has something more interesting. You can't multiply a string with some number. When you say, say is the R1 times a three, this means the R13 times. So step one is I am, so it's going to be I am, I am, I am. So we can add the plus between two strings, or we can multiply them. Now a cat or do something like that. Two times R1 plus R2, two times STR 1 is going to duplicate STR 1 two times, which is I am, I am. Then blas is to R2, which is Mustafa is going to add the word Mustafa. And so on. You can say have is the R1 with hello. And then start three resistors, R1 plus R2 plus 1 and so on. So the moral of that is we can do the blood or the plastic over strings to get meaningful results. The other thing that I would like to teach you is the backslash t. Remember when things to start with the backslash for some specific characters like the t, We call them escape character. We learned before about the backslash n, which allow us to go to a new line. The backslash d is allowing for a, for a tab. At the top is some character that move to the next stop in the console, in the, in the text. By default, every eight spaces. I don't want to confuse you about that, but if you write hello backslash t, This is going to be hello, three spaces, backslash t, y, y is three spaces because every species are considered. So the word hello is five liters. So what is the next multiple of eight? It would be hello, three spaces. This is now an eight. We said hello, backslash t, backslash t, Then hello. And then it would be followed by Allow around 11 species, because the IQ of five and 11 is 16, which is multiple of eight and so on. The moral of that is a backslash t is give you a bunch of species which are very useful. This is an optional reading about the tab if you would like to read it, if you didn't get it for now, this is totally okay. The second interesting thing to know about is using the three quotes, three double-quotes. We learned before that if you wrote three double-quotes like that, It's just a comment. But it happened in the middle of a function this way, for example, it's going to be a printing statement, normal parenting statement. So when you say bring a new bus here and input three single quotes or three double-quotes. It would be a combinatory, useful string here. Now, one great advantage here is you can use single quotes and double quotes inside the chemistry in a very normal way. You can define three double quotes here or double-quotes, and then use single quotes and double quotes as you would like. There is also an, another interesting thing. Let's say we would like to write a multi-line something. You can write it with them in an easy way. You can write here the three double-quotes is the print new line on several lines, line using. So the Albert would be, would look like that guy. So also has an advantage in easily writing several lines together. Back to the species. Yeah, I think this is the same message that I wanted to say. If you tried to see here, you'll notice that the Hello space here. So it's almost like it's pieces. And here it will be like almost 16 species. Yeah, the soap. That's all for today. 17. Function: Today we'll learn a little about function. Functions use image of topic, but we'll just would like to know little about it for the current Berbers of the current scope. Imagine that we wrote some code for a task and the good is like 50 lines of code and the task is a bit common. So there is another team in the company who needed the same task. Someone again, repeated my 50 lines of code to write the toss. In another company again, someone rude the same 50 lines of cool. So it's a very time whisked to keep repeating yourself, you are and your team members to do some common tasks. Here where the function come to that. In a function we write the code once and then everyone is just using it. We call it a variable or forget if the brain to function we use to the brain to use the print function to print something to the screen. There is a lot of logic behind the scene for how the function is doing that. But neither you nor other guys should be doing this logic by themselves. The functions that Python provides us with something like the brain, which has something like syntax to that accepts a string or an integer, or even accepting multiple arguments like that. So the bison are doing a great effort to provide you with all of this flexibility in preventing things. Now there is a new concept here, the return, the function can return to something. This means that when the function is done with the competitions or whatever builders is returning some message for you about it. The print function returning nothing for you, but sometimes it's returning something. For example, the Python define a function that is good men and it takes two integers. It returns something which is the result of that. The main function will compute which value is the minimum and the return it. The syntax that we use the function is like is as following, answer equal men of six and the three. So looking to the right exhibition here, it's meant three, which is going to be value 3. The value three would be computed and return it to be both here. So this line is as equally as unsere equal 3. Let's see some coding for that. I can say here, equal men of 36 main is a function accepting here two arguments and the returning, the answer, which would be three. I can even call it with more, more, more arguments as I would like. I can say mint or 3, 6 minus 2, which would be minus2 or 96 minus 215. Here is the max function which is the opposite, returning the maximum moves them, which would be 50. So when you see something like the men, these two parentheses, it means it's going to call some common could give it this two parameters. Compute something, return you the results for you and voted here in the US, even things can be more nested. For example, I can say print max of 47. So what's, what's happening here behind the scene? The max of 47 would be solved with tourists. So maximum 47, it's going to call it the max function to return a seven. Now it become parenthesis one. Here, it's going to be Brent 7 plus 2, which is 9. There's also an interesting function called the type. So let's define some variable, age, which has a value of 1 million value. And you see I put here underscores to make it easily readable. This is allowed in Python. Now if I tried to say type of 15, or type of the type is a function that takes some variable or a value to tell you the datatype of it. So the type of 15 is class in, the type of edge is int, type of 20.5 is a float. But the type of message at 325 is STR. You see here the word the class. This is relevant to object-oriented programming. We will come back to that later. Another interesting function is the Len function which can be applied on a string. Let's say we have a string, we'll stuff well, if you, if you, if you called the function Len of STR, is going to return to the lens of it, which is seven digits, seven liters here. So you can bring to the STR length, which is seven. Or you can make nested code. You can say Brent of Len, of STR. So then it's the R will be sold with first with value seven and return if you now a very common mistake that beginners a very hard time. Someone did the following Len equal length of STR. So far, so good. This is going to work on your Marie Lynn would be seven. The problem here is, you know, similar in the, in the dynamic typing. We cannot change the function name to be a variable name. Now this function name is going to be lost and Len is going to be a variable name here. Now the dynamic typing is going to give us hard time. If you try to call again Lynn of STR, and this will fail because Lynn is now a variable that has a value of seven. It isn't a function anymore. The advice is, don't use variable names, seem as some function. So we know now about the function lin, about the function max function. When the function type, if you use some variable equal to the function name, you cannot call the function again. Another interesting topic is convergence. There are functions like int and float, an STR that help us to convert something. For example, let's say we have a message JSTOR, which she has a string value of 10. But I would like the value tend to be incremented or so was like something. You can call the function into a string, which is going to return an integer value or flow to the string which is going to return a float value. So here if you try to bring messages to our and it's a type, it would be 10 and plus STR. But the excipient would be integer and the exit flow to be truth. In a very similar way. If you have a float variable and it would like to convert to integer, you can't say into the variable or is the art of the various. Observe. If I tried to bring to my float will be 20.7. But if I tried to bring into my end, it will be only 20. So we lost it the value here of 0.7. Why? Because the integer datatype doesn't keep the fractional bar is just to get rid of feet. One more time. Do not use a function named like int or STR, or lane, or Min or max is going to make your life harder. That's all. 18. Reading: So far we were printing today we'll learn about, let's say you'd like to read something from the user. The user will provide you with an input and your program will make use of it. So here were the input function come to the scene. There are two ways to use it. You might use a like an input of something empty, which is just going to read directly or input of message was going to bring to the message of tourists and imprinting it. I would like to them here so that you can see more what's happening behind the scene. So let's go to this code. Here is our first-line of goods. You see it? Say, they are equal input. And this means read something and voted here in stock. So let's run this program. So here I'm going to start to write something, maybe Hello, World it. If I printed it here. And you see here, Brent is TR, is going to bring to the statement that I read and it's going to bring to the time of eight to be of type STR. So as you see, the M boot is a function that we can just call and it's going to wait for us to input something and then we can do something about it. Another interesting thing here is what if I enter something like 1, 2, 3 with the type would be integer or a string. The type again will be string. So whatever you input here is going to be just a couple of, is just going to be a string. So be careful from that. Also observe like let's say I would like to enter two integers, for example, enter 10 and 20. So again, it going to be a string only of 10 and 20. What if I would like to read two integers, then you have to read twice and maybe to convert your code. So let's back here to our observations here. Yeah. Yeah, yeah, There is also another thing here to learn about. Yeah, let's check this code here. This code is doing the following. It says input off and then giving some message, enter your name. So let's see what does this mean? Let's run it. So you see initially it printed for you, enter your name, then it's waiting for something from you. So I'm going to say here Mustafa for example. So it says Hello stuff. Okay? In addition, you can make both of them in a single line of code like that. You can say hello plus n, Both of something. So like a function calling a function this end which would be resolved with Forrester to whatever I enter then hallux, let's say here I say it. It's great to say hello beloved. So these two lines of code are the same as this line of code. The input is going to firstly, breadth is our message. Taking a fruit from you, some inputs and then returning it to here. And then we can use the plus to concatenate the result together. As I said, if you strike two input two numbers in a single line of code is going to be just 11 is staring with a single line of code. If you would like to handle that, You better do reading for a m would be input into lines of code. For example. Let's go here and say something like that. And let's suppress the integral of a plus two times the integer of p. Now, we are going to read two numbers, but make sure to put every one of them on a single line. If I say the 10 and 20 is going to print 50, okay? But if you did a mistake like for example, you enter the thin and twin in a single line of code. You see what happened is the 10 and 20 are now in the variable a. The variable B is waiting for some input from you. If I tried to enter something here like seven, the program crashed. Why? Because it, the enter function here took us drink. It consists of 10 and 20 space. It couldn't convert that to an integer because it's our two now two integers, it cannot be converted. So over all, you have to be careful when you would like to read multiple integers. The last thing that I would like to know is I'm going to teach you an abrupt, but you will not be able to understand it at the moment. See this syntax here. A comma b comma c equals n. But the split, you can read something that consists of three items, spaces between them, and Python will split it for you this way. So let's try to print it here, print the a and B and C. Let's run that. And let's center here. I am. Mustafa is going to print I for a, B, and C will have Mustafa. So if you did something like that, it's going to divide the input for you. More interestingly, let's say you would like to read for integer variables, you do the following line of codes. Let's bring to the B and the D. For example. Let's run this enter 10, 20, 30, 40 is going to be into the B, which is here corresponding to the 20, and the d which is corresponding to the 40. The moral of that is this line of code. Can, is going to read some input and coding. Some function call is split. And it's going to map every string to an input. We will come back later to this syntax. For now, I would like just to follow it every time we would like to read something that is multiple items on the sunlight. You can differently can read each one of them with an input on an MBA client. But I would like to make your life easier in a very similar way that you would like to read five-foot numbers here. So let's run it is going to show you enter five numbers. Let's say 1.523546 is just going to, to present to them. Now, what if you give wrong gambits? Like for example, let's say you give here 55, 52. Now this are six numbers is going to fail. Too many values to I'm back. It's expected only five values. So I would like you to make use of this map or split function to make your life easier if you would like to enter multiple numbers on a single line. Later in the course, we will understand how this function is working from the source. 19. Variables Homework 1 - 4 Easy Challenges: Homework number one. The first one you will, you would like to read couple of numbers and just sprint to some math operations between them like addition, subtraction, multiplication, and division. So just follow the program here. Your three, the first number on the first line, then the second number or another separate line. In the second program, you would read the information here as you see, we read the student name, ID, the ingrain. This is the grade of their mass exam. And then you read another student name, id and degree. Then you are to bring to the gradient formation for them. So Brenton here, Mustafa information, then Bella information, then you are renting the average degrade of the math. So this guy has twins and this guy has Filter1. So the average is 25, 0.5. Just follow the picture here. And the third one, we will be given eight numbers on a single line like that. So some of these places are owed on some of this, please for the position. So the odd positions here are this position like 11 and seven and 12. And the three, you are to sum all of them. And Brenton here value like 33 for them. And doing the same for the even. So the overall is, you are dividing these eight numbers, 2, 4 even polices and for all places and summing every one of them. So 2 here is a sum over the places, and 33 is a sum over the odd places. The 43 program is, you read this 3s, three streams. Let's, for simplicity say now you read a and B. Then you are going to construct the ODE as follows. First, you need to print something like a single could be double-quotes. And you are three-beat that 10 times. So if the input was ABC, then this is Albert. Please read and make sure you understand that. It is another example. I am Mustafa. Now you are going to print a single quote, double quote Mustafa. And this string itself is going to be repeated here ten times. That's all. 20. Variables Homework 1 Solution p1 p2: In this homework, we would like to do very basic symbol program. We will read two numbers and Brenda there, plus minus multiplication and division operator. When you think about them, the flexibility of the program would bushes to think that these numbers shouldn't be an integrated, should be a float so that we allow our diversity of the different cases. We should also consider always when it comes to division, to not divide by 0. So let's think how can we write such a cool. We first, we're going to read the n-bit, which is first, and then using the float or converted using flow to a float number. And here in the second line we're reading the second number. The difference between this one and this one. I'm trying to make it one short line. So here we read the input and then we can state or converted directly to absolute number. This is, should be the way to go read your restatement and converted that showed this is assuming that the user is going to end with a valid, invalid. For example, if these are immature a string, this will cause a problem. Otherwise we are just some renting out of them in a normal way. This program, if we run it with the division by a second as 0, the program will crash. In the future, we'll learn how to handle that in a better way. In the second problem, we would like to read to student information numbers about math exam. For each student, it seems we will read his name, his ID, and some green. I would like to rebrand through them again and bring to the average of them. So we need to read this information and this information, but IBM variables for this guy, but a bit variables that guy and I start to read. Here in this code, we started to build the three variables of the fittest guy m with m both because both of them are string and then a float number for the second guy we're going through m with m with and second number. And then fairly we are going to bring to the information of every guy I'm here, but embedding it in a message. So adding all of them together, observe that you cannot just add the grid to the string. We are going first to convert it to a string and then we are adding it. After that, we would like to bring to the average of the numbers. So we will add grid one and grid tool and just divide them by two. I'm printing the average. That's all. 21. Variables Homework 1 Solution p3 p4: For this problem, it seems we have to read like eight numbers. So the best way is to directly read eight numbers in a single line, but consider the names to exactly match what we would like to bring. By that, I mean, create your program to have here eight variables. But the, in the exact order that we need like one, even one or two, even two or three event three or even four. And using such a very useful naming would help us to directly, but a beer they even some vertically beriberi or the autosome. And then just week we burn through them. In the loss of the program who would like to make a special kind of concatenation. We will read three strings. Let's call them a and B and C. And then we would like to bring it in this specific order. For example, if the input is I am Mustafa, then we would like to bring the eye, then it seems we have a single code. Then am the second quote there, Mustafa. And then it seems this is repeating for ten times, as we said here, the best way to do such a program is to be revered this input string, and then just multiply it with 10 to keep repeating itself. Let's see. Here we read this three, the three strings. And then we prepared the combust string, which is the concatenation as the fittest, the three items here which are repeating. And then once we multiply it was 10 will get repeated 10 times. In a similar way, the purpose of the assignment was to like exercise mentally the multiplication of that. So. 22. Variables Homework 2 - 2 Medium Challenges: Homework number two would be little medium level. The first one is you read this program which started with two variables, num one, num 23, sit and bring it eventually what is number 3? The second the program, you will do a very bubbler operation in computer science. We name it swab, swabbing. Two things means to change the content of one of them to have the other guy and the other guy to have value of me. For example, if number one value is seven and number 2 variable is 25. If we swap the values of these two guys in the memory, then the value of number one would be 25 and the number of value to the value of number two would be seven. So you see there is a kind of fix exchange operation that haven't been here. So this is what mainly have a year. In this program, you will use the following template. You are going to read two integers here on a line and eventually bring to the To line numbers here. You are expected to write three lines here. If you needed more, do it, but you don't need more than three lines. After this three lines, the values of number one, number two would be swapped. For example, if the user entered the 10 and 20, then the output will be 20 and 10. You should only change this three lines, nothing else. That's all. 23. Variables Homework 2 - Solution p2: In this program, we are supposed to do a very common abbreviation in computer science named as a swabbing. Swabbing me to change the content of two things together. What do you think about it? If you have two things to swap their content, we would like to put the content or the first thing is a second thing and the opposite. But if we tried to do that, we will lose one of the two values. For example, if I tried to put number one and number two, number two, number two, number two value would be lost. So how to solve this problem? The idea is to introduce a third variable that will act as a temporary value. If you would like, try to take this hand and tri-tone limited a problem by yourself. Now, let's say that we have num one, num two, and Tim, how to solve this problem? It is a nice visualization. Let's say that a and B are our two interesting variables. And we have here the Tim, just images for us. The idea is to take a copy of a and put it in the temp, and then take B and put it in the a. Now, although it seems we most of the value of a, actually we can get it back from the thymus so we can take back the tip and book it in B. Take a moment to check the elbows here. In terms of the code, we will introduce a num 3, which is a variable temporary. We take num one inside it. Then, now Sibley, we can both num two num one, num one, num two num, num, num 1 now seems lost, but we actually have it here, num three, then we covered it here. This is actually more like a C plus plus java thinking, but it is very useful to know about it. In the next sections, we'll learn about what we call multiple assignments. And we will know that this kind of swabbing can be done in a single line only in this way. The soul. 24. Variables Homework 3 - 3 Hard Challenges: Homework number 3. We are going to write a program that do this web of three numbers together. For example, let's say the user inputted something like a equal 115 b and c 301 after some operation. Here, we should have the value of a, B, and so, you know, Sweden and the value of c and b. So b now if 301 and the value of a itself in C, now C now is 150, write a program that will be the following. It will have here a reading for three lines and numbers and printing for the three numbers. And here you write your code. You can write it only in 34 lines of code, but feel free to go more than three guys. Would it change it this through lies. For example, if you enter them both 123, the output would be 2, 3, 1. If you enter the 2030 40, the output would be 30, 40. And so do not change line three, line 8 just stably in the middle here. Bring to me This program is a bit challenging. And later we'll learn a couple of things in programming that will make this program very trivial. But now you have very limited tools to do the task. You will read two integers, a and b. If b is either minus one or one. If the b value is minus one, you will bring to the exhibition 2 times a plus 1. If b is one, you will bring to the exhibition a times a. So let's see here. If I entered in books like seven, and the value of b is one. If v is 1, then we print the a times a and seven is 49. Here. If the input is minus1, you need to bring two times a plus 1 to 2 times 7 is 14, plus 1 is 15. You need to find a one line formula to do this task. Later, we will learn something could if conditions and we'll learn a relational operators, which will make our life much easier than that now. But for now I would like to make use of the current available today. The third program, you arthritis program that will read value in and bring to the sum from one to n. This is another program where later programming like for loops is going to make it very easier. But for now it will be a little bit challenging. Even it is right twice. So let's say I enter the value n equal 5, then the sum from one to five is one plus two plus three plus four plus five. So this is just 15, which is 15. There are more values. If I enter the four, then the output should be for ten, which is one plus two plus three plus four. I'm writing here some hints. Give a trial to find a very, very simple formula to solve this problem. If you couldn't try to read the hint and make use of it, that's all. 25. Variables Homework 3 - Solution p1: To solve the problem, when we expand it to be three numbers. Looking around the numbers, it looks like the circulating, write the value of a, go to the value of C, the value of b go to the value of a, the value of C go to the value of B. So it seems like the recirculating together. There are two ways to solve this problem. The first thing is to just do it like a two separate swap operation. So you swap a and b fittest and then you swap B and C fairness. And this is how you are done with the overall swabbing. For example, to do that, we take the three, oh, I didn't know this solution. Yeah, this is very similar to what we did before when we learned the swab in the last slide. Now, the smarter way is to try to use, make use of the circulation idea. For example, if we can just shift them, this one by one, we can do it. Again. We need, we need some temporary variable. So let's take num one here in them, then circulate them but two in one word 32. Now what to put in 3, that timber value that we would like to take by circulating the number. This way, we are extending the algorithm. We're going to be much smarter and to be just the four lines of code. Again, like I said before on we will learn about the assignment operator, the monkey assignment. We know that all of that can be done in a single line in a very Pythonic, a nice way. That's all. 26. Variables Homework 3 - Solution p2: Probably this problem gives you a harder time. It's very hard to bring something based on a condition and something else based on another condition. Later we'll learn about the fL. So condition which will make such a program very trivial. But without such a tool is a bit hard idea. For simplicity, if you'd like, like a similar problem, imagine that B is either 0 or one, not negative 11. How can we solve with this problem? The idea is as following. Let's, let's compute this term and this term. So now let's call this value 1 and value 2. If you multiply the input B and one minus B in the values, for example, multiply this would be and this one in one minus p and book them, both of them in a single equation. In this way bestow on the b value, one of the terms would be 0 and the other would be the actual value. The remaining threat is the NBA is minus 1101. So the idea is, how can we convert something that is minus 11 to something that's always 01? This is one extra trick in this program. Let's see what I mean by that. First of all, let's submit a beer, our two values, we have an equation if the value is one and we have another equation if Z value is minus one, now, we would like to convert the minus 11 to be 0 and 12 to facilitate creating an equation with it, it is the idea. You can convert the equation from one to the value of one to be like. Look here, if the value of b, if the value of B is, is, for example, 1, 1 plus 1 is 2 divided by 2 one. Now we created like an exhibition, its value is one. If actually the input value is one. And here is the other case. If the, if the, if the input is negative one, then we all what we need is just to switch to this value here from one to minus one. Let's simulate it. If, if the value of b is minus 1, if b is minus 1, minus 1 plus 1 would be 0. 0 divided by 2 is 0, is 1, now is 0, is negative, one is one. The moral of that is, we managed to have two variables. That would be either 10 if the input was one, or 01 if the input was minus one. I hope you got the target of this equation. Now, let's write all of them in a single equation here. What I'm writing here is one is negative one. If it is one, then this is one. And we will use this term, Wendy. And this would be 0. So all of this terminal will be canceled. On the other side, if is negative is 1, then this term would be computed and this one would be 0. So it will be canceled. Again one more time if you got confused. The moral of it is, there are two different equations and bear a bear two variables. They will be either 10 or 01. And based on the input, the MBA to be converted to only have one of the two guys here. This is definitely not very practical in the market in any way. As I said, we will learn later the if else conditions which will make our life much easier. But it is good to build the like mathematical mind that can make use of whatever available to build the good solutions that so. 27. Variables Homework 3 - Solution p3: If you like, math for public is problem was very easy and very directive for you. Later, we will learn something cool for loops. With, for loops, this problem can be trivially solved it, although it would be very slow approach