Introduction to Python | Achraf Mad | Skillshare

Playback Speed


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

Introduction to Python

teacher avatar Achraf Mad, Creative Engineer

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

13 Lessons (1h 50m)
    • 1. 1 Introduction

      2:28
    • 2. 2 Why Python

      2:50
    • 3. 3 Download and Install Python

      11:59
    • 4. 4 Hello World and Help Function

      8:48
    • 5. 5 Variables and basic data types in Python

      12:26
    • 6. 6 Commenting your code

      6:56
    • 7. 7 Reading keyboard input

      10:55
    • 8. 8 Exercise Build a program to say Hello

      4:49
    • 9. 9 Exercise Build a simple calculator app

      7:31
    • 10. 10 Conditional Statement

      14:29
    • 11. 11 Loops For Loop

      14:23
    • 12. 12 Loops While Loop

      7:34
    • 13. 13 Exercise UserName and Password

      5:16
  • --
  • 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.

18

Students

--

Projects

About This Class

Introduction to Python: A Practical Approach

Learn Python easily and unleash the power of Python coding using Real life examples and Practice activities

What you'll learn

  • Explore the choices available to run Python apps
  • Use the Python interpreter to execute statements and scripts
  • Learn how to declare variables
  • How to take input and convert it
  • How to send output in more than one method
  • Build a simple Python app that takes input and produces output
  • Build a simple Calculator using Python

Requirements

  • Basic Knowledge of Digital Electronics

Description

>>>Learn Python easily and unleash the power of Python coding using Real-life examples and Practice activities. <<<

Welcome to this course.

Python is one of the most popular and fastest-growing programming languages in the world. It's used for all sorts of tasks including web programming and data analysis; and it's emerged as the language to learn for machine learning. That popularity means that python developers are in demand and python programming jobs can be lucrative.

These are all great reasons to learn how to program in Python. This module will provide an introduction to using Python to build an app that can be a starting point for becoming a Python programmer.

Why You Should Learn Python?

  • Easy to learn.

  • Supports quick development.

  • Cross-platform.

  • Open Source.

  • Extensible.

  • Embeddable.

  • Large standard library and active community.

  • Useful for a wide variety of applications.

You’ll learn how to:

  • Explore the choices available to run Python apps

  • Use the Python interpreter to execute statements and scripts

  • Learn how to declare variables

  • How to take input and convert it

  • How to send output in more than one method

  • Build a simple Python app that takes input and produces output

  • Build a simple Calculator using Python

At the end of this course, you can create Innovative Projects using Python. The only thing that you need to do is THINKING, WIRING & CODING.

Who this course is for:

  • Python Geeks
  • Anyone interested one of the most requested Programming languages in the World right now
  • Engineering Students - Electronics, Electrical & Computer Science
  • High School Science Students
  • Electronic Geeks, Hobbiest & Art Students
  • Embedded Systems Geeks
  • Arduino Geeks

Meet Your Teacher

Teacher Profile Image

Achraf Mad

Creative Engineer

Teacher

Hello, I'm Achraf.

A passionate engineer who loves to share his knowledge with the world

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. 1 Introduction: Hello and welcome to this new course in which you are going to learn Python. This is an introduction to Python course presented to you by usher of Python is one of the most popular and fastest growing programming languages in the world, is the third most used according to git hub in 2019. It's used for all sorts of tasks, including web programming and data analysis. And it's merged as the language to learn for machine learning. That popularity means that Python developer bars are in-demand and Python programming jobs can be lucrative. There are all great reasons to learn how to program it by phone. And this course will provide an introduction to using Python to build an Arab, which can't be a starting point to becoming a Python programmer. It will be the first course of a series of courses which will help you master Python programming in no time. What you will learn in this course, you will explore the choices available to run Python apps, different machines, Windows, Mac, and Linux. You will use the Python interpreter to execute statements and scripts. You will learn how to declare variables, different time of variables, and what each type of variables does and why and when. You need to use it. How to take in both and converted to fit your app goal. How to send output in more than one method, and how to build a simple Python script or app that takes input from user and produces output depending on ascertain algorithm. You will also learn how to convince code and why you need commenting. You will learn why Python is great language for programming scripts and how to build a simple calculator using Python language. I'm sure you will enjoy this course content. I can assure you that at the end of this course, you will create two or three Python scripts. One of them is a simple calculator app that you can show off to your friends. And it will be a starting point for your Python courage. Thanks for watching this introduction. See you in sight. 2. 2 Why Python: Hello and welcome to this new lesson. Now let's talk a little bit about biofilm. Button development started in the 19 eighties and unpopular in the last decade or so. Python 3 x is the future of Python. There's Python two 2p sites still use Python to, but you should learn Python three. There are changes between bifan to unbinds from 300 for libraries that are not supported. And you have to make sure that you are learning the most trending one. Python is an interpreted language. It's a very high level programming language. So it requires a lot of decoding and celebrating. And it takes a lot of processing power. It supports a multitude of programming. Borodin's. It supports object oriented programming, functional, procedural, logic structures, and a lot of other things. It's a general purpose programming language. This is why it's a very trending language and a lot of people use it all around the world. It's very comprehensive. Standard library includes nonnumeric modules, crypt to service, operating system interfaces, networking models, GUI support and development tools, among other general-purpose libraries and techniques. Now, when it comes to Python, it's a very easy language when it comes to learning how to program using this language. It supports quick development and it's a ball's cross-platform. So you carve out and Linux, Windows and Mac. It's an open source language. You will find a lot of projects and a lot of libraries available for free online so that you can use and download easily. It's embeddable language. You can embed Python coding and almost everything. It's extensible language and it has large standard library and active community. If you have a question, you will find almost free will to answer your question. It has a very active community that will help you gain knowledge and solve your problems in no time. It's very useful for a wide variety of applications, like Internet of Things and other applications. This is a sneak preview of why you should learn Python and why Python is a very great language to start with. Thanks for watching this quick intro. This is rational. 3. 3 Download and Install Python: Getting started. Before we begin, we need to actually install Python. The first thing you should do is download and install Python environment. Paul instructions and examples will target this environment and this will make your life away much easier. Now, when we come to uninstalling or downloading and installing Python, we have more than one option. You can choose and install and editor of your choice. For Linux users, I prefer sublime text. It's a very interesting and widely used editorial. I will show you this editorial nominate. For Windows users. Most Windows users use ie, the allele, or the integrated development environment provided by Python, which is the default one. Options or other options include Vim, Emacs, Notepad Plus, Plus PyCharm, Eclipse, or any other software that you feel comfortable when using. Throughout this course, I'll be using PyCharm in IE Windows environment for all of our demos. So you can use any other one. That coding is the same. But make sure that you and all the software that you are using. Now, let me show you the sublime text editor and a pie chart editor. And let's install Python. Now to install Python, go to any search engine and try to install Python. The first result is download Python from python.org. And now what you need to do is download Python 3.8.3. You can go with an older version. As you can see, we have 3.73.63.5, but I prefer working with the largest one. So click here once. And as you can see, you have adult EXE file, which is now downloading and installing. Now once it's done downloading Gould's sardonic installation process. And what you need to do. This point will go to the Start menu, right-click and open that Cmd or Windows PowerShell as an admin. Now, if you write Python here, you will get an answer. As you can see, I have python 3.8.2 and installed, already installed on my system, which is a windows machine. And now we can install Python 3.8.3, which is the latest version. So click Open File. Now, since I already have 3.8.2, I have Upgrade Now option, but you will get an install now. And what you need to do is simply click ones and the installation process will start. It will take some time for Python tool be installed in your system. And once it's done, you can make sure that Python is installed by checking this using a command window. Now, let's leave it. Now. Go and write sublime text editor. As you can see, this is the icon of this software, click ones. And this is the software itself. As you can see, it's a very nice software that you can use for writing codes. You can download for Windows. Click once here. And as you can see, the download process started. And I'll pass on is silane stalling. It has a little futures is a sophisticated text editor for core markup on pros. And you can use it for any programming language, not just Python. And we also have pie chart. And pie chart comes in a free and bed versions. So what we need to do here is download the free version. As you can see, this is the download option for PyCharm. Click download. And now you have two options. You have Windows, Mac or Linux. Choose your operating system. I have windows. If you went with professional, you will try it for like 30 days, then you will have to pay and the community edition is more than enough. So click now Lord, for the community option. And as you can see, the download started. Now let's install the Sublime Text editor. I'm showing you how to download and install each of these, but you have, you only have to choose one. So click next and install. And now the installation process for Sublime Text editorial starts to click Finish. Now if you want to see it, you can simply go look for text editor. Here it is, click ones. And here you have it. Here we have the Sublime Text editor. And from here, you can simply change the properties for this software. You can go to View syntax and choose the programming language. Again, review syntax and select Python from here. Now once you select Python, it will color your codes depending on the language but you are using, Since this is our PHP called tone peak collapse correctly, again, you have to go to View and syntax, then Python to make sure that you are selecting the Python environment. Now, the next thing is you have to go here, setup was successful. Now we have python 3.8.3 Install. Click close, and go to the Start menu. Right-click. Choose Windows partial or command. As an admin, click yes, now to norm the Python version. And if Python is installed, just write Python. And as you can see, Python 3.8.3 is installed on our system. That's it. This is how easy it is to install Python on your system. Now we have Python installed and we have Sublime Text uninstall. I already mentioned that I'll be using PyCharm Text Editor. I prefer this one. So let's close this one. Let's download pirate downloaded pie chart. Let's install it. Now we are installing PyCharm text editor or coding editor. Click Next. And now slither by charm committed version that you want to uninstall. Since I already have a version, I want to uninstall it and install the latest version. Click Next. Next. Now we have the 20-20 version. Click next again. Choose 64-bit lunch shot at Open Folder last project if you want it at lunch out the IR to the path and associated with Python files and installs a 64-bit lunch OFF. Since I have a 64-bit operating system, I marked all of these. Then click Next, Next. And as you can see now it's installing. It will take some time for the installation to finish. Now it's extracting the files. But this is by far the best Python editor that I have used that to find a lot of functionalities. You can create projects and create files inside these projects. And you can easily run your Python file, track your errors, and debug your code. And best of all, it's free of charge. It's a community versions so you can use it without any restrictions. Now, it will ask you to reboot your system. You should report it. But for the so-called listless on I want so I want to manually voted later. Click Finish. Now if you wanted the Start Menu, you will find PyCharm Community Edition install tool. Click once to style the software. As you can see, PyCharm, 20-20. Now, all what you need to do is simply create a new project by clicking here. Or you can open up on all project from here. Or you can open any old file from here. I will create a new project. And let's call it Hello World. Okay. Now we have everything up until ready. Just click Create. You can choose this new environment or an existing environment, which is our Python that EXE file and tell brittle. Or you can go home with annual environment option pushes this one. Now, lists create, leaving everything to its default. Just change the name of your project to Hello World and click Create. And now to create virtual environment so that you can use it to program or to start tracking your very first Python code. It usually takes some time. Huni are running it for the first time. Now it's downloading the necessary libraries. So you have to be connected to the Internet. Click FX and configured automatically. That sets up and ready. This is your project. And here you can create your own scripts. You can add new file, new Python file, and you can name it Hello. World. As you can see this butterfly. And the next lesson we are going to start with our very first Python program is printing the Hello World on the console. Thanks for watching this lesson. This is Ashraf. 4. 4 Hello World and Help Function: A great way to get started with Python is learning how to perform input and output. In Python, the print function, which is one of more than 60 functions built into the language, outputs text to the screen. Now, the following statement. Let's start. Go to view, go to appearance. And I will entail presentation mode to make my coordinate more clear to you. So view periods. Enter presentation. Whoops. Now as you can see, I can't start writing here. If you tried this function print. Inside it, you can write anything you want. You can write Hello World. Now this statement will displays Hello World on the screen. You can't go to run and run it. As you can see, now we have hello world planted on our screen. Close, we use the print function. And now the argument passed to print function is a string, which is one of the fundamental data types in Python use to store and manage text. By default. Print outputs are new line character, which is this one, the end of the line, so that subsequent output, for example, additional calls to Brent will start on the next line. We can test this out by simply writing print. And here we can write hello world. Ashraf. Now fluent again and run the code. As you can see, Hello World is in one line. Ashraf is our new line. That's it. Now you can try your first Python statement. Python supports an interactive console experience, which allows you to type in commands and see the results immediately. This is sometimes referred to as a read eval, print, loop, or reboot or REPL. It's written like this, r, e, p, l. Read Eval, Print Loop. Which means that you can type things and see relevance coming up as you type. Now, we can try this in our console window. If you went to the start menu and right-click Torben up down those partial admin. You can easily write Python here. And it will respond with Python 3.8.3, which is the iPhone version that we have installed. Again, when you type python to start the Python interpreter. Now you have initiated, all started the interactive mode. Now, the next tip that you can do is. Try the print command. This is an active window for our console and in Python interpreter. So you can print here, you can write Hello World. As you can see, it did respond with the very same thing which is printing hello world. Now the REPL has a built-in help function that you can use to look up keywords and functions. The generalized syntax for this function is writing help are two parentheses and inside them, caroline object for example. And you will get results to help you use objects in Python. Now, you can try it out for other things as well. Object here is a specific function or keyword you want help on. Let's try a few examples. Let's try to get some help regarding the print function. So you can, as you can see, we have more things to show when it comes to our help. Now, what you need to do is click Control C to get out of this, now we are back to the Python enthalpy with our window, the active interpreter. We can write help, friends. As you can see, we have that isn't now selling us that print tool. Take these as input and it explains everything. As you can see, it tells you what SIP is, what n is, and you can get help for any other thing. Again, this is a very nice feature that will help you get heaps of result. Now to exit the help screen and return to the interpreter, you can simply press Q and you can get out of the help screen. Now, the interactive help console is a very great feature if you don't pass an argument to the help function. And interactive help facility is started. If you did type help with two parentheses. You can see that here we have help and we can't write anything that we want, like a keyword or a symbol for the thing that we want hurled worth. Now, once you write helped to enter the interactive help console, this will list some basic instructions how to use the help system. From here, you can just type in the element you are interested in. If you type string. To get help on the string data type, it will display something like this. As you can see, whitespaces, ascii code, lowercase digits, hexa digits, classes, and a lot of other things. Now if you want to get out of this, you can simply rescue the enthalpy. When there is more than one page of output, you can press enter to align. As you can see here we have mod. So if I press Enter, we'll get more results. As you can see, line-by-line. Now, once you hit the end of the help screen, you can type q. And as you can see, I'm out of this window and I can search for any other thing. You can feel free to explore more things. For example, you can get a list of Python keywords by typing keywords, key words. And as you can see here, we have a lot of keywords that we cal use and Python coding. If you want to get out, you can't simply live Q. And now I'm out of the help section and back to the active interpreter. Now, this is it. This is how to use the console won't comes to Python programming. How to use the help few Charles, all the help features to know more about anything in Python, you will need the help function in a lot of things in the future. But for now, you just need to know how to use it. You can simply press print and between the parentheses you can't type the thing that you want tell worth like class, and you can look for a thing. Now, there are no results for class or classes. You can look for string, you can look for keywords, and you will get a heap for results. Again, this is only to get help on how to use certain keywords so their functions. And it's a very nice feature. Now let's go back to our coding section here. We did learn how to print hello world and Python, and how to print our name. You should try this out on your machine before moving on to the next lesson. If you have any questions, please ask. In the Hyundai ball, this is Asherah. 5. 5 Variables and basic data types in Python: Variables and basic data types in Python. Variables are one of the fundamental building blocks of programs written in Python. Variables hold that in memory. They have names and they can't be referenced by name. Variables also have types, which is, which specify what type of data they can't store, such as a string or an integer. And they can be used in exhibitions that use operators such as plus and minus to manipulate their values. In Python, a variable is declared and assign a value using the assignment operator equal, which is this sign. The variable being assigned to is on the left-hand side of the operator. So here we can write x, which is our variable, and the left-hand side of the operator. And the value being assigned, which can be an exhibition, just such as two plus two, and can even include other variables, is on the right side. So we can write x equals one. We can write y equals x plus five. And we can also write SSID equal y. So the equal operator can take two variables on the left and the right side, or it can take a variable on the left side and a value on the right side. Or it can take a variable on the left side and a variable and the lifestyle blasts are value. So you have a heap options. And these are only examples to assign numbers to variables, but numbers are just one of several data types and that Python supports. And notice that there is no type declared for the variable. And this is because Python is a dynamically typed language which is a very, very great feature. It means that the variable type is determined by the data assigned to it. In the example here, the x, y, and z variables will be integers or integers types capable of storing positive and negative whole numbers. Variable names are case sensitive and can use une, letter number and the underscore character. However, they can't start with a number, so you can't write five. Let's see, value. This. As you can see, we have an error. You need to rename it because you can't start with a number, but you can write the value five, which is the variable and make it equal five. You can even use the underscore, or you can simply write it, use that camel case. Like this, arrival value number. And this is a very nice strategy for naming the variables. You can start the first one with a lowercase, then every other World. With an uppercase. Now, all of these variables are integers. And we didn't write int x to make sure that Python understands that this x is an integer. Python, again, is a dynamically typed language, which means that when you write x equals one, it will understand that one is an integer variable. So it will assign a variable x to be treated as integer. As you can see, x integer equal one. Same thing for other variables. If you went to y, you can see that y is also an integer variable, zed equals y. And since y is an integer, then SSID is an integral value. Now, same thing applies for other type of variables. So if you did write my name and you use this, this means that you are using a string variable and we didn't have to lie to shrink. As you can see, my name string Ashraf. Now Python did understand that my name is a string variable because we stored Ashraf, which is a string inside it. And these marks are used to assign strings. Now, if you want to work with numbers, most programs manipulate numbers, computers, three, integer numbers, and decimal numbers differently. Let's see this example. If x equals one or x equals 1. Now, this is an integer, while this is a decimal floating point number. Because we have adults here. As you can see. Now, Python creates integers from our built-in data type called int. And this allows like this one, which is floating point numbers as instances of float. So this will be treated as a float variable, and this will be treated as integer variable. Python built in type function returns a variable data type. The following code that we are going to write will output types to the screen. So if you write x equals one and you use the function type, let's sprint. Now inside of the breath we need thrive type, which is a function in Python and thigh the variable name. Now, this will print the type of variable x. Let's use it here. Plinth type x. Now, the first x will be integer, while the second x will be float or decimal point. Now, let's write this out run along HelloWorld. As you can see, the first one is integral of the second one is float. This function will return the type of x and printed on screen, which is basically printing float and integer. And this is the result. As you can see, we didn't fly the float, we didn't write nth value. Python again. Is a dynamically programmed language. So to understand on its own that this variable is an integer because we did add one to the variable x. And to learn their stand on its own that this variable is flawed because we added 1, so variable x. And this function can't print out the type on the console window. Now, the addition of the Boyne zeros to the end of one. Here makes a big difference in how the programming language three, it's a value type impacts how the value is stored in memory, how the processor, CPU, and there's the data on evaluating expressions. How did that relates to other data and what kinds operations can be performed with it. Another common data type is the Boolean type, which holds the value true or false. Now, if we did clear this, when do we cut out x equals true? Now to print the type, you cut right type and right x here. When you run the cords. You can see that this is Boolean data type. Now, internally, bool is treated as a special type of integer. Technically, true has a value of one and false has a value of 0. Typically, Booleans are not used to perform mathematical operations. Rather, they are used to make decisions and build form blanching. Nevertheless, it's interesting to understand the relationship between types. Many types are nothing more than specialized version of more general types. Integrals are subset of floating point numbers, and Booleans are a subset of integers. So when you are working with variables, make sure that you understand what you are working with and you are choosing the right data type for your application. Now, let's try to print out and look to other data type, which is things along with numbers. Strings are among the most commonly used datatypes. As string is a collection of 0 or more characters. Strings are commonly declared using a single quotation marks, but double quotation marks may be used to. So to initialize a string, you can write X equals. This is my string. And you can print the string itself by writing print. You can also print the type to make sure that it's a string using the type function that we already mentioned. And you can also use the double quotation to print out a string so your current, this is also another way to write a string. Now if we did run this, okay, let's print the next string. The fluid around this. As you can see, this is my string, which is the first print line, and thus string which is the second line. The last line is this one. And this is also another way to write a string. Now, strings can be added to other strings. And operation known as concatenation with the same bus operator that adds two numbers to add strings together. We can simply do this. Let's remove these print lines. If I want to add these two texts together, I can't simply declare a new variable that says ID equals X plus Y. Now, I can't print it using the wrong. As you can see. Now, the two strings are printed on the same line and are treated as if they are once drink. We can add a space here to make sure that we have a space between these two lines. Now if you did that on, as you can see you now, we need a space here. Sorry. Okay, now this is my string. This is also another string and we have a space between these two lines. That's it. You will learn more about strains in another lesson, including how to parse them and how to manipulate them in various ways. You will also learn about other important data types such as lists, which store collections of data and are frequently used to hold coalitions of strength. But that's it for this lesson. If you have any questions regarding annual these data types, I'm here to help. Thanks for watching. This is Ashraf. 6. 6 Commenting your code: Coming to yield codes. Most programming languages support, including comments and source code. Comments do not change what the code when it runs. The are ignored by the compiler or interpreter. Instead, they are used to explain how the code works or why it was written. Comments are a great way to document complicated code and to include to-dos, reminding you to come back and do something later. For example, you can write a note for yourself. Make sure that this code works with empty strings. Paulson supports comments using the pound sign or hash, followed by the text of the comment. So you can simply add the hash. And by IRM opponent, don't mind me. I don't. Comments always extend to the end of the line and are always one line only. For multi-line comments, place a bound sign are the salt of each line. Comin may appear at the start of a line, or following whitespace code, but not within a string. In that case, it's just a literal bound sign in texts. And to show you an example of this, here we have, I am a comment. Don't mind me. Now, if you wrote x equals this, you can write a comment here. The rest of the line is equiluminant. So it won't. People said that bottle this string, which is this, this is my string. Now, you can also add another comment here. This is also now if you went down and growth here, let's write a fixed equals and you add a double quotation inside them. If you added the hash sign and wrote, this is not a component. You can see that the hash sign here is treated as part of a string that is stored inside the fixed variable. Adding a hash sign inside the two double quotation of the string will not make the compiler or the enthalpy with purpose without this other thing. And this case, this will be treated as an ordinal takes that has, that has us hash side either beginning. Now let's print the text to show you this in action. Now if we click plan, as you can see, this is the hash sign and it was printed. And this is not a comment. As you can see. While if you want, they'll hear you added a hash outside the double quotation and outside the variable declaration. You can, this is. Covalent. So make sure that when you write a comment, you don't buy nice thick added inside the double quotation or the single quotation marks of the string or any other variable declaration. You have to avoid space out your harsh outside anything, and then start writing your comment. Now you can't culminate each line to make sure that whoever is reading your code can understand that you can write here. This is used to print the text variable. And this will make sure that if I took your code, I understand what each lines, what each line means. Now, some programmers avoid comments in favor of flighting self-documenting quad, which is easy to understand as a result of descriptive variable and function names. So we'll find them fighting a sort of x. They will write, let's say, first, you wouldn't Nim. And when they arrive this acyl effects, they don't have to write a comment stating that this is the Affairs. Student name goes at sort of the reason and the variable name or listening, then it will assume Santosh. And this is called a self documenting code. Goes, we are naming everything and refinance to how we are going to use it inside our code. So we don't have to write comments to explain everything. Same thing goes for functions and for any other thing. There is nothing wrong with self-documenting called, but never hesitated to use comments in an effort to be as explicit as possible about your thoughts and intentions. The purpose of a block of code may be clear to you. If you're ot it ten minutes ago. But a year from now, I will place comment may be as helpful to you as it is the other programmers who are seeing girl called for the first time. Close one-year means all the scores has Burlington and you are most likely, let's say loss in the coating. And when you see a chord that you did write I a year ago, few ON THE recognize it and you have to understand it line by line. So I didn't want compliment can make a little difference and save you a lot of time. Some people use comments to document that date and time. So we'll find them writing this. Let's say that today is June 2020 and it's 9-13. Yeah. Last is now this will make sure that you have are clear date clothes. Sometimes when you could be a file from one location to another location, it takes that Thailand data than your location. So to make sure that your code has the last edit, DAG, make sure to update this when you edit your court. That's it for this lesson. Thanks for watching. This is Asherah. 7. 7 Reading keyboard input: Hello and welcome to this new lesson in which we are going to explain how to read keyboard inputs. For reading input from the keyboard, pass on, provide the input function. And put three is what they use are types on the keyboard and returns it as a string. And you have to concentrate on this line. Python will attend whatever you write in the keyboard or using the keyboard as a string. Now, here is an example that combines input and print functions to capture a person's name and then displayed on the screen. We start by defining a variable. We'll call it name and light input. Now inside the inbox, you wouldn't write whatever you want to be displayed to the user on the screen. We will ask the user to enter his name and tell you name. Now when he enters his name, then what function will take it and installed inside the name variable. After that, we need to print the name using the print function. Now, let's run the code. Let's measure that are running the right file. She's really on both. Okay. Now, it's asking me to enter my name. My name is shut off. Now, it did print Ashraf, as you can see here in this line. Now, the string passed on or as an argument to the input function is the probability that you are a user will see. In this example, you are asking the user to type his or her name into username. Here, between these two single quotation. You can't choose this with any other thing. Once their users types uname and presses pinto, variable function will return the name and store it inside the variable. The function will return the value, which is a text here. And the text will be assigned to the variable named name, which is here. That m variable is then used as an input or argument to the function print. And print will print the name that was written by values. Now, you can all scored the input function without a parameter. You can simply write it like this. Let us call these two. You can simply do this. You can write print. And between these two, you can write in thought, or what is your name? And here you can write name equals input. Then you can't print the name. Now for you to run, as you can see, what's assumed name, which is the slide. I would like to push off. And as you can see, it did print my name, which is partial. Now this program will behave almost the same as the first one. The difference is that print by default adds a new line to the output. So in the previous example, we have the name written beside that. What's your name line? While in this example, who we call import, it added a new line. So we wrote the name newline, then it print out then a new line. As you can see here, we have three lines. Now if we come with these three and remove the comment from these two. Once you right here, you would start laughing at the very same line as you can see. And when you plus enthalpy will print your name in the second line, it's not the case with this example. This will be printed on a new line and this will be added and a new line, you will add your name, you lie. Close input adds a new line, and then the name will be printed on our new line. As you can see here. It's not a very big difference, but this is, or this is how you can take an input from the user using two methods, not just one. You can either pass a variable or a value or inside the input value. Although both parentheses or you can leave with empty and ask the user and assimilated line to tell his name. Now, if you want to read numbers as input, the input function always return the type value as a string or text. And we already, we have seen this and this example. This makes sense because the user can enter whatever value there, like, even if the input is a valid number, it's still returned as a string type from the inbuilt function. Now for example, if we did ask the user to enter a number, and here, let's make it x. Now, this code, as you can see here, we'll print the value that those are told and we want to print the type. And we already mentioned the type function. Now the tide will return the type of variable x. Let's run the code. As you can see, if I wrote five, it did print five. And the type of a class type is think it's not a number because we already mentioned that the input returns only string value. Now, running this code, an integer value five would display string, which is this one. This makes sense because those are entitled and Ambar Bertha. Functional materials are text. Even though the value itself is numeric. To turn the value into R through integer variable, you can use the nth function and tools, the int function. We have to do this. As you can see here. We are. Using the input function as well, asking the user to enter a number. We can write here ends, which stands for integer, and we can add two parentheses. Now the int function, we'll call the input function and will fill the use up the entire arm. But now this will return a string. And this string will be converted to integer and will be stored inside the x variable. So this function will convert string to integer and store it as an integer and the X variable. Now, this code will output class guilt. Let's try it out. As you can see. Let's write five. As you can see here, we have the clasping to Russia, which means that this number is now an integer, x variable is an integer. You can use the float function in the same way. If you expect a fractional component, you can simply write flow to you. And when you run the code, you can simply write one k del symbol right here, 1.5. And as you can see, that data type is float. So flawed variable here. All the float function takes the string in both form they use are converted to float, then store it in the x variable as a float. So the type functionality and float, as you can see here. And now. And there is a very important thing that I need to mention here. If the input is in numeric and you pass it to the integer function, as you might expect, this would be an error and cause a runtime failures. That program will end at this statement, you can try it out yourself in the Python interactive console. And let's run this code. And let's enter a. A is basically a character. It's not a number. So if I click in thought, as you can see, we have a runtime error, could not convert string to offloads. Goes, this is not a number, this character. Okay? So this is called a runtime error. Now, let's talk about another thing which is converting numbers to string. You can go the other direction as well. The string operation will take an integer or float value and tear it in clustering. This is required if you are concatenating the number into a string. For example, you can write X equals five. Now, we want to print this line. The number is loss x. Now, if we print x, let's see this. As you can see, we have our problem. We are all trying to concatenate a string with an integer, which is wrong now to make sure that we are able to blend this integer beside this line, I'll concatenate them. We need to use the String or STR function. Now, STR function will take this integer and converts it to string, then concatenate this string, which is five, With the number is. And now when we print it out, as you can see, the number is five. So what this will do is basically why this number is five. Now five here is a string because we use the string function to convert the integer between these two parentheses to strings. And this is the only way that you can print or concatenate a string with a number. That's it for this lesson. If you have unquestioned regarding anything, I'm here to help you. Thanks for watching. This is Ashraf. 8. 8 Exercise Build a program to say Hello: Hello and welcome to this new lesson. Now, let's use what you learned about print in both and string concatenation to display a personalized greeting using a Python script. Now the first thing that you need to do is basically create a new file, pile, new Python file. And let's call it. Say hi. Now click enter. And now you have on your python file. Let's start by printing will come. Now, the next thing that we need to do is we need to ask the user for his name. Then we need to print his name. So we will present this hello comma, then leave a space. Then you can write the variable name. Now we printed welcome. We asked who's often tell his name. He will tell his name, and it will be stored as a string inside the name variable. And we can concatenate the hello string with an empty string and print it on our screen. Now, what you need to do is symbol. You need to run. And make sure that you are running the right file. Say hi, now will come into your name. My name is Ashley off. As you can see here, hello, partial. And now we can prove this program. We can ask the user for his age. And uv edge, sorry, j, until your age. Now, we can enter your pair three, Bhutan asked him to tell his birth year and do some math. And I'll feed it into his birth year. We can create a new question here. Let's convert this to an integer using the int function that we already mentioned. And here is change this to birth year. Now, edge will equal 20-20 porches this year minus PR field. Now, we can print here. Each edge is, we can tell him is age, age. Now if we print age, we will get an error. Why is that? Because age is an integer. And in order to print it out, we need to convert it to string using the STR function to make sure that we can concatenate strings together. Now, list is this OUT? Quran, say hi, my name is Ashley. My birth feels 1989. Now. Hello Ashraf, your age is 31. Okay. Now as you can see, we use a mathematical operation to calculate the age. We took it as a string, converts it to integer. Then we used it in an equation, then we converted back to string and concatenate it with this line. Now this is a very simple exercise that includes everything we have covered so far. You should try it out. And once you are done with this, you are good to go to the annexed exercise. Thanks for watching this lesson. If you have unquestioned, please ask in the Columbia board. 9. 9 Exercise Build a simple calculator app: Hello and welcome. Now let's try with another exercise to build a symbol calculate or app. Now that you have experimented with reading, input and creating variables, let's try a slightly more complicated Python program. Assemble additive calculator. Lists are by creating a new Python script file named calculator. Go up here, click File, New partial file, and then press enter. Now we have this new file. In the script file. We need to write the following program. First, we need to ask the user to enter the first number, and let's assign it to the variable named x. So x equals in both first number. Now, let's ask him to tell the second number and store it in the variable called y inputs into seconds. Okay, so right. Now, we need to add the two numbers together and assign the result to a variable named result. Now, results will equal x plus y. Did we forget something here? I will give you five seconds to guess what we have missed in this code. Okay? Now, what we have missed in this code is converting these things, as we know and Porter theorems as string. We need to convert this thing to integer and store it in an integer value or variable. So we need to write nth. And we need to off two parentheses here when you throw out nth. And we need to, to parentheses. Now, what we need to do is test this out and we need to print the results. Rent. Results. Now run upon say high K. No fun. Calculate or up until the first number five, the second number six. Now the result is 11. And this is it. You can add a few comments. You can answer your homeland. And this is the first number. This is the second number. And this is, there is also the just to make sure that we use everything that we have learned in this crash course. Now, this is it, this is how easy it is to create a simple calculator app that can add two numbers together. And what you need to do at this point is create a program like this. We can adjust the results. We can't blunt align, saying that the result of summing X plus X plus sign, I will explain it in a second. And y loss. Here we can add equal lossless. Now, this will bring the result of summing x, which is the first number. It will add the first number here plus the second number, which is y equals. We'll print and print the result. Now that result is an unbeliever here, so we need to convert it to string using the string function. And x here is also unknown bar y is also a number, so we need to use the string function to concatenate it. And we will explain why this. Now click Run 15 plus six. Now the result of summing five plus six equals 11. That's it. You can do the same for the multiplication. Let me adjust this. We can add some more, some results. We can add some result. And we can do the same x minus y. We cannot model publication is all the same x multiplied by y. And we can parcel out div result x divided by y. Now to bring these lines, we need to do the same thing. We can cope with this line. And we can share this with these four variables. Now some subtract multiplication, division, and hearing is to share the signs to minus multiplication. Okay, now let's just fell to see if it works. Around 55. As you can see, plus five equal five plus five equal to five minus five equals 05 multiplied by five equals 255 divided by five equals one. And you need to change this thing. You can remove the summering clean, as could see here, there's onto five plus five equals ten. And this is a very simple calculator in which we have implemented everything we have taken so far. Now if you have any questions, I'm here to help you. Thanks for watching this lesson. This is Ashraf. 10. 10 Conditional Statement: Hello and welcome to this new lesson. Don't child going to talk about conditional if-statements? Using the if statement is a vital part of building virtually any meaningful program. You can use it to automate complicated decisions so that it can be applied repeatedly and consistently to user input or data. When you use the Thayer called logic, all decision and loaded. We are referring to our ability to imbue our program with the ability to make a decision based on inputs. Base. On the decision. We can instruct the Python interpreter to run some code and skip over other codes. Now, who are going to learn how to do this using if statements. And we will use the if statement along with optional. Else if statement. Now, a Boolean expression is unequal, that returns a boolean value. And a Boolean value is either true or false. And we already covered that. Now, it's boolean is advocated data type and Python. And it's very important for if statements. Now, let's try Accords where we basically asked if the value equals seven, then print several. Right-click val enthralled to Python file, create new Python file and name it if else, tests. Now, let's go and enthalpy presentation modes. Now here we can assign a value and we can give it seven. Now to use if statements, basically what you need to write is simply write f. Then the condition. Now the condition is evaluated equals seven. Now, if this condition is true, we need to do the following. I'm going to print the value is seven. Once we are done, we can go back and trends finished. Now as you can see, we added rent inside the if statement, while this sprint is outside of f statement. And now if we added this print here, this means that this will only be printed if this condition is met. So if this condition is through, these two lines will be printed, otherwise, nothing will be printed. Now let's see this in action. Click run. As you can see. So this condition is through the value is seven, which is the first sentence, unfinished versus the second sentence are printed. If I change this to aids, let's run it again. As you can see, nothing is printed. Now to initial Vab, this is granted. Given the condition isn't true, we need to get out of this if statement by removing these spaces. And then now run. Since the condition isn't true, this line wasn't executed while this line was executed because it's not linked to this if statement. So it did print finished. Now again, we went back and make it through. The value is seven. That's it. Now, if is the key word here, that boolean expression is this one. And we have dots here. And this colon character is required after the boolean expression. So make sure you're not missing this one. Okay? Now, what comes next is just as important. The next line must contain a code block that runs if the Boolean expression evaluates to true. In Python, accord block is defined by using indentation, which is basically the spaces before the line. In this case, we use the Tab key to insert for individual cases. So each time I press, I press tab, it will add four on 2344 spaces. And these four spaces, we'll help the if statement know which lines to execute if the condition is through. This indentation tills the powerful enthalpy without that, this code belongs to that if statement up here and showed R1 will the Boolean expression evaluates to true. If the Boolean expression evaluates to false, all of the indented or indented showed be ignored by the Python interpreter. When you run the code, you should see the following output. The value is seven. Then finished. Now again, you can't share it the value and see if the condition is false, what will happen? Now? Let's update the code. Examples will include an ELL status. The L statement is an optional part of an if statement that can handle opposite case. In other words, when the boolean exhibition in the if statement evaluates to false. Run that called block that belongs to that statement instead. Now let's update our code to match the else statement. After the if, the Boolean expression, then this will be executed if it was through ends. And the colon. Then again, print. The value is not certain. Now let's list out the value is seven, now of which this 28. As you can see, the value is not seven, which is val statement. Now, this condition is, isn't true, so this line won't be executed, and it will execute whatever we have in the else part of the code. So what we have here is the value is not seven. As you can see here, the value is not certain. That's it. Now, we can also update our code to include the else if statement. Else if statement or rather e, l, f. I will show you this in a minute, is another optional statement that can be added below. An if statement. You can use the else if statement to test another unrelated Boolean exhibition. And that Boolean exhibition evaluates to true. The indented cold below. That builds if would run all called the blocks that belongs to another. If, else, if and else statements are ignored. Now, to make sure that you understand that let's use it. Let's split, add. Else if statement here, E, L, F. Now you need to add the condition are Boolean exhibition here. And you need to add a lie. Now, as you can see, we have missed the colon here. We must add it. Now, just like the if statement, the else if statement must begin with else if. It must include a Boolean expression. Unlike the else statement. Now, it must terminate by using a colon, as you can see here. Without it, it will show an error. And just as before on indented code below the else if is part of the code block that runs. If the Boolean expression evaluates to true. When you run the code, you will see that that ends if statement was executed because this condition is true. Now the value is eight and finished. It didn't execute this one or this one because this is false. And the else statement is only executed if these two conditions are false. Now, again, we can add more else-if statements. Here we can't print the value is nine. And of which this the line. And run, as you can see the value as nine. If we changed it to ten, since we don't have ten here, it will execute this one. The else clause, none of these is through. That's it. This is how you can use if, else, if and else statement, the conditional expressions. Now, there is also something that is called nested F. Now, nested F means when you add two if together, just this out, we come try this one. If the value or if condition. If a new condition is true, then we need to use other. If a value equals seven, let's use this line. Now. As you can see here, we have an error. Our soul through France will choose the new condition because we haven't create this variable. So let's create it. Now. Fair value, if value is all equals that, say 20, then 20. Okay? Now, let's this, this out. Now, as you can see here, the value is ten, so nothing was printed. So let's show that the 20, as you can see, the value is 20 was executed. Now, this was executed because the first if statement is true. Now if I change Daniel condition to false, unstyled thrown the chords, you won't see the value is 20 because the first condition is false and this boolean exhibition is false. So to want to go and shake them nested F or the internal if statement. So this is like a double f. If the first condition, bigger condition is through, go, uncheck the conditions inside it. Otherwise don't go. And all case it's not true. So if one chick down in our if statement, and this case is called a nested if statement. And it's widely used in programming. And specifically if statement. If the first one is through, go uncheck the second one, otherwise, exit the program. That's it for the if statements. If you have any questions, please ask in vector on the board. I'm here to help you. This is Ashcroft. 11. 11 Loops For Loop: Hello and welcome to the Tsinghua soon in ocean-going to exit plan loops. Now, loops in Python are basically wave or ways to do primitive commands or attributing statements. Now Boston has two primitive loop commands, while loops and for loops. Now, let's get started on programming languages need way of doing similar things. Many times. This is called iteration. Now when it comes to for-loop, the for statement is used to I iterate over the elements of our sequence. It's traditionally used when you have a piece of code which you want to repeat n number of times. The for loop is often recognized by our loop counter or low variable. You will understand this by an example. First slide for now, write counter. And you can't choose the range. So to say that we want to start a counter and this range between line six and we want to print that counter. Now, you need to add a colon here after the first line. And here you can easily print the counter. Let's test this out. As you can see, when we did run this, it printed the number from one, borrows from one to five. And now you can also derive the for loop like this and will give you the same result. You can't write numbers. The range controls the range function that takes two input from one to six. And you Carlisle before MOOC for count and numbers. Plant count. It will print the same thing as you can see, from one to five. And again from one to five. So these are two different ways to use for loop. And you can give this easily. Here we have the loop variable, which is the counter. A for loop is basically used for isolation of our sequence. That is either a list or tuple, dictionary, assert, or even a string. This is lists like the for keyword and other programming languages and works more like an iterator method as found in other object oriented programming languages. When the for loop, we can execute a set of statements, each for each item in a list, tuple, asset, or even artery. So for our example, we can create a new. Let's call it fruits. And let's give it some verticals. To print these items, we can easily write for x, n roots, trent x. So return this line layer then the hashtag sign, and run the loop. Okay, here we have a problem. Kay? Lets run this. Okay? Now as you can see, we have Apple, Banana, and Sherry, which are the elements of this array. We have also these numbers, which are elements of this range. Executed function. Affordable doesn't require an index and valuable to set beforehand. Or what you need to do is simply started by selecting the loop variable. The allocation of things you want to read or to plant also deal with. And here to cartelize whatever you want. Now, even strings are objects via contains a sequence of characters and you can easily read them using loops. So for x n, Let's say banana. We can print x. Now, free run the cord. As you can see, we have B, a, and D, and E. Now that says, this is how easy it is to use the for loop to read iteration. Now, there is something called the break statement. With a break statement, we can't stop the loop before that has looped through all the items. And for example, we can take this for loop. And inside this for loop we can add an if statement. If x equals manana. Special that certain Sam, then simply brick. And by breaking, we are telling the for loop to stop executing. Here. Sought won't print sharing. Now are free to run this code. As you can see, the last for loop printed a bill and printed banana. And once panelist was printed. There is an if statement that checked if that printed X, which is banana, and that case equals banana. So this condition is true. Then brick, brick means get out of this for loop and don't continue execution. That's why we don't have chair here printed after the banana. And this is the main goal of the break statement. Now, again, you can exit the loop when X is banana, but this time the brake can be placed before the prints. So if we blessed this if statement, here, you can imagine what will happen. Our last example, apple and banana, were printed. But in this example, only append will be printed. Because once x equals banana, you will check if x equals banana. If this condition is true, then break, don't print banana. So in this case, as you can see here, only Apple as glint. So the location of the if statement makes a lot of different or France and execution. And since we are placing it, follow the printing statement. Once the condition is through a tool break. And we'll get out of the for loop before printing the x value which has been on. Now, again, food blazed it back. After the print statement, we will get the banana printed here. As you can see. Now, we also have another thing that's called continue statement. With the continue statement, we can't stop the current iteration of the loop and continue with the next. Now to understand this, we can simply used this very same chords. Bless this if statement before that print and then sort of brake light continue. Now, what will happen here is basically it will continue the execution if this condition is true. And we'll skip the current iteration. Now, let me show you this. As you can see, it did drink apple and sharing. It didn't print banana. Why is that? Because we have continuing here. Now when x equals banana and this condition is true, that continue here was executed and continue here means go back to the for loop and execute the next one. Skip. That is still the code inside our for loop. So the cord skip that print and didn't print banana. As you can see here, are Brill and Sherry were printed. Again that continuous 13, stop the current iteration of the loop and continue with the next iteration. So it's like a skip statement for the current iteration. Now, we have other things that can't be treated. We already introduced the range function. And that hash function returns a sequence of numbers starting from 0 by default and increments by one, and ends at a specified number. So if we added one number inside this, let's sit in and clicked Run. As you can see, South Loop 0 and went all the way to line. Here. It comes in more than one shape. So you can use the image function and our two values from ten, let's say to 20. And when you run the code, you will see that it started with thin and with 19. It can even take three values. So it's up to you. Another thing that you can't do with for loops is use the else statement, the else keyword and affordable loop specifies a block of code to be executed when the loop is finished. So when this loop is finished, we can add else here. Plinth. Finally finished. Now, when this for loop is executed, once it's done, it will print the L statement. As you can see. Finally finished. Now there's something else that's called nested loops. And this third loop is a loop inside a loop like if statements, the inner loop will be executed one time for each iteration, the outer loop. And to try this out, we can use this very same example here, and we can add adjective here. Another way to solve some items, threads, big, tasty. And here we count all this. We can add another for loop inside this for loop, so forth. Y, n fruits. For x n objective. We need to own this print x. We have to add the colon here. Now let's see the results. As you can see what happens here. It did print reds big, tasty because we only selected x. We need to select x and y to grill them together. As you can see, Apple, which is x, upper limb with banana, read cheer, big apparel, big banana, and big cheery. Tasty apple. There's the banana anticipates shear. So it will take each of the x's and lou, the wives. So twill take the red, then loop, apple, banana, cherry will take big and loop. I will punish you. And then we'll take tasty and Lube, apple, banana, cherry. That's it. This is how to deal with for loops. And this is basically everything you need to know about for loops. There is still more, but this is all the basic stuff that you need to know about for loops and how to use them and you're recording. Thanks for watching this lesson. If you have any question, please ask and like you're on the board. 12. 12 Loops While Loop: Hello and welcome to the SR plus one, which we are going to talk about while loops. With Y loop, we can execute asset overstatement as long as a condition is true. And to test this out, let's create a new Python file. Score worthwhile tests. Now, create a new variable. Let's make it r equals one. Now, why then you have to either condition, let's say i is below six. Then are the colon. Print i. Now i equals i plus one. Or you can write it this way. I plus equal one. Now, let's explain what's going on here. Now, we create the new variable, we'll call it, I, give it one initial variable, a value. And this is the condition if pi is blow sex. Keep doing this. What we'll do here is we'll print the value, which is basically one to begin with. Then it will increase the i by one. So the next time this while loop is executed, it will shake. F2 is below six, and this condition is true. It will print two, then it will increase it, five will become three. And it will go back to check if three is below six, which is true. It will print three and to increase the value by one, so it will become four. It will go up here is four, was 4.06 or not? It is it will print for again, five plus six. Yes. And when it is six, is six below six, no, salt one, print sex. Now, let's run this code. As you can see, 12345. Now we can't shares this and make it thirsty. And run the code again, as you can see from one to 29. If you want to print thirsty, we can add below or equal as a condition. And now as you can see, we have failed three because we added equal. If you want to print out or to increase the value of oil by two, you can change this to two. And instead of 123, it will be 135791113151719 and so on. You can't change this will five, and again, it will be 161116, and so on. Now, the y loop requires relevant variables to be ready. And in our example we used and we set it to an initial value of one. We can use break statement inside our while loop. And to do this, we can't simply. Either condition, if i equals three, then brick, brick will in this while loop if this condition is true. So let's show this to one. Now let's run this code. As you can see, 123. Once this condition is true, once r equals three, it will break this while loop and get out of it. Now, we also have a continue statement that can be used. Now with the continue statement, we can't stop the current iteration of the while loop and continue with the next iteration. So if we did run this code, as you can see, if i equals three, it will continue. So it will go up here and it will increase i by one. This is while you are stuck, and three here. Now, to avoid this, we can't change the location of that increment up here. And as you can see here, we have a thrice. Now, 1234. And as you can see, one wasn't printed because we have the chance to hear. Now, let's do this. Ok. Now too. As you can see, we don't have three. Here. It's not printed because when r equals three, continue, continue means ignore the rest of this code and go to the next iteration. And this is the main goal of continue with the continue statement. We stop the current iteration are this line. We didn't execute this line, and we continued the next iteration. That's it. This is the more the ring gold from using that continuous statements. And there's also an insert statement that we can use to run a block of code once that condition no longer true or once, once we finished the while loop. To do this, we can simply write here, drills, print, done. And now, as you can see, once dun, turn move this year, once it's done from one to five, then it will print done, which is inside the else statement. Now, this is it. This is everything you need to know about the while loop. There's also something called nested while, where you can add two while loops together, just like the for loop. And you can even create while and for loops and the same scripts. Depending on your needs. Both of these will repeat the code inside them until the condition is true. But while is more, is more like four representative tasks. And you can easily add a condition. While for loop, you can't easily either condition. You have to stick to the iteration for lists, string at rays and other stuff. That's it for this lesson. If you have any question please ask in the Juan de ball, this is Ashraf. 13. 13 Exercise UserName and Password: Hello and welcome to this new lesson and which are going to apply what we have learned in the previous sections. Now we are going to create a program that asks the user to enter his username and password. So let's get started. Username. Let's say that those other name is Ashraf and the passwords is 123456. Now, to ask the user to enter the password, we need to use the input function. Enter your name. And to ask him to tell his passwords we, you, we need to use the input function. You pass it to ask for his username. Now, once he or his name, we need to store it inside a variable. Let's call it user and the password and saw the variable, let's call it pass. Now to make sure that what he entered is correct, we need to use the if statements. We can't start by, I think, if user equal user name. So if the first condition is true, we can ask folder. All trick if the password is through. So if pass worlds w, Then we can print. Now. We have to add double equal sign here and here. And their username and password are true. It will print welcome. Otherwise, you need to print Wrong password. Okay? Now lists this, this query run by user pass. Now to enter their username, it's partial off. The password is 123456. Now, did print will come. Let us try to tell then. Ashraf clue pass aloft. Now what if we enter the username? We need to run it again. As you can see when we enter a room username, it asks us for a password, which is not true. And we should change this. We need to make sure that if the username is wrong, if the username is not correct, we don't want to tell this area and Shake Bow password. Okay. And to do that, what we need to do if the username is through this area. Otherwise, use else. Print user name. Now list this, this out. J. As you can see, username was the username that who just entered is not correct. Now, to change this order or the order of these tumors is we need to move these two lines. Now. First we need to ask the user to enter his name or user name. And if there's our name is correct, then we ask him to his password. Now, with a password is correct. We can print will come. Otherwise we can't plan through password. The username isn't correct. We can go to the else and thrown username. Now, let's say that we have our own user name. As you can see, wrong username. And the program ended.