Python Tutorial For Beginners 2026 | Python Programming Tutorial | Python Full Course | Simplilearn

Simplilearn| 00:55:05|Mar 26, 2026
Chapters30
Provides an overview of Python’s importance across IT fields, outlines the learning path from basics to OOP, and hints at a quick quiz to test Python knowledge.

A practical, beginner-friendly tour of Python basics (variables, data types, structures, strings, operators, conditionals, loops) plus a friendly intro to OOP and setup with Jupyter/Anaconda.

Summary

Simplilearn’s Python Tutorial for Beginners 2026 breaks down Python fundamentals into a clear, hands-on path. The video begins by underscoring Python’s versatility across AI, data science, and software development, then reassures newcomers that the journey can be short and approachable. It guides learners through setting up Python (with Python.org, Anaconda, Jupyter, or PyCharm) and then dives into core concepts module by module: data types and variables, Python collections (list, tuple, set, dictionary), and essential string operations. Throughout, the instructor illustrates concrete examples—from printing a simple message to building and manipulating lists, tuples, and dictionaries, to slicing and basic string operations. The course also covers operators, conditional statements, and loops (for and while), followed by a primer on object-oriented programming: classes, objects, encapsulation, inheritance, and polymorphism. Interspersed are practical exercises, quick quizzes, and an emphasis on real-world usage, including how to structure code in Jupyter notebooks and how to install and use tools like Anaconda and PyCharm. The video closes with a note about downloadable course materials and an invitation to practice with the embedded notebook, plus prompts to explore related data science programs offered by Simply Learn.

Key Takeaways

  • Python is the common skill powering AI, ML, data science, data analytics, software development and more, making it a foundational language for IT professionals.
  • The course demonstrates Python basics in a notebook-friendly way by showing how to define integers, floats, strings and booleans and how to print and inspect them.
  • Lists, tuples and sets are introduced with practical examples: lists are mutable and ordered, tuples are immutable, and sets enforce unique elements with unordered storage.
  • Dictionaries are covered as key-value stores that are mutable and maintain unique keys, with hands-on editing of values and keys.
  • String operations include concatenation, length, upper/lower case conversions, and slicing to extract substrings.
  • Python operators cover arithmetic ( +, -, *, / ), floor division (//) and exponentiation (**), including a simple example-driven calculator.
  • Conditional statements (if, if-else, elif) and loops (for, while) are taught with concrete examples like grading logic, even/odd checks, and a basic multiplication table generator.

Who Is This For?

Perfect for absolute beginners to Python who want a practical, example-driven foundation. It’s especially useful for aspiring data scientists, software developers, and analytics professionals who need a solid grasp of Python basics before tackling more advanced topics.

Notable Quotes

"Python is one of the most popular programming languages for software development, AI, machine learning, all those things."
Intro emphasizing Python’s broad applicability across fields.
"The syntax is really simple. Let’s say I want to print something like 'welcome to simply learn' and done—that's all you will get."
Demonstrates Python’s straightforward syntax through a basic print example.
"A list is an ordered set of elements... while a set cannot store duplicates, and a tuple is immutable."
Key differences between list, set and tuple introduced in the data structures section.
"Dictionary stores data in key value pairs. A dictionary is ordered in modern Python versions. It is changeable."
Core properties of dictionaries highlighted with an edit example.
"The init method is the constructor used to initialize object properties."
Intro to object-oriented programming concepts.

Questions This Video Answers

  • How do I install Python and set it up with Jupyter Notebook?
  • What is the difference between a list and a tuple in Python?
  • How do I create and modify a Python dictionary?
  • How can I perform string slicing and concatenation in Python?
  • What are the basics of Python object-oriented programming (classes, objects, encapsulation, inheritance, polymorphism)?
Python basicsPython setupPython variablesPython data typesPython listsPython tuplesPython setsPython dictionariesPython stringsPython operators with examples (+, -, *, /, //, **))
Full Transcript
[music] Hi there, welcome to Simply Learns YouTube channel. If you're looking to start your journey in software development or data analytics or data science or generative AI or literally any IT domain, you see one skill in common and it's Python. In the current IT industry, Python covers some of the most exciting fields like AI, machine learning, data science, data analytics, software development, the web development, and the list goes on. That's the true power of Python. And don't go just by the looks just because the list is long. The Python learning journey doesn't have to be so long. Trust me, even if you have never written a single line of code before, you can start and still easily follow along and learn Python. Python is so simple and the syntax is so readable that it shrinks the learning journey exponentially so that one can master it in less than a month. In this course, we are going to start from the absolute basics and gradually build your confidence step by step. Having said that, let's discuss the agenda for today's session. We will start off with a basic introduction to Python. Then we will look into Python variables and data types. Followed by that, we will take a look into Python collections or also known as data structures in Python. Here we will learn list, tpple, set, dictionaries, strings etc. Then we come across operators in Python. Up next we will have conditional statements in Python. Then we will dive into loops in Python. And lastly a quick introduction to Python object-oriented programming. This should give you a basic foundational understanding of Python to proceed along with your learning journey into data science, data analytics, AI and machine learning or software development. That's it. If these are the type of videos you'd like to watch, then hit that like and subscribe buttons along with the bell to get notified whenever we host. Also, just that you know, if you want to upskill yourself and master data science and data analytics skills, then you must explore simply learn of various data science and data analytics programs. Simply learn offers various masters, professional certifications and post-graduate programs in collaboration with some of the world's leading universities. Through our courses, you will gain knowledge and work ready expertise in skills like Python, Tableau, PowerBI, generative AI and over a dozen others. After completing these courses, thousands of learners are transition into a data science or data analytics role as a fresher or move on to a higher paying job and profile. If you are interested, then make sure to check out the link in the pin comment and description box below to find a data science or data analytics program that fits your experience and areas of interest. Now let's get started with our Python course with a small quiz. Which Python data structure is ordered and mutable? Your options are A TLE, B set, C list, and D dictionary. Please do let us know your answers in the comment section below. Now over to our training. So we can start by you know having a quick uh walk around of how to install Python. So I've already got the Python installed. But in case if you're new to this, then you can just pause the video and go to this link where you will understand how to download Python. But also I'll also give you a quick briefing. You can just navigate to python.org. And here uh you can just download Python and get it installed. And then we have another option as well. So you can also install Anaconda. And if you just download and uh just go through the basic protocols and recommended settings by Anaconda, you'll have everything installed in your PC. You can also uh check in every other box that uh the installer shows you. You can add the Python path file to your environment variables etc. And you'll have a quick briefing in the tutorial I've linked in the description box below. So once uh Python is installed you can just open up or fire up Anaconda or Jupyter notebook or you can also go with PyCharm any of the online compilers or any of the ID which is comfortable for you to use Python. So I'm going with Jupyter notebook here. So we've already got the entire workbook on this particular Python tutorial. So we'll be going stage by stage or module by module. So let me quickly fire up a new terminal or a new notebook and uh I'll name it as select kernel and I'll name it as uh python basics so that we can execute each and every command in our modules here you know stage by stage and for safe side I've also got this uh code saved in my notebook as well notepad as well so we can run them. So let's begin with the basics. So here I'll execute this particular one. So Python is one of the most popular programming languages for software development, AI, machine learning, all those things and we can quickly start. You can just command these anyways I must command them. There you go. The basics happen. So now we will start with module one. So here you have two sections uh code and markdown. So I'll enter markdown. So wherever I have uh some module headings or titles, I'll use uh this particular section as a markdown and then we'll switch to code. So if you are familiar with any of the basic programming languages like C or C++, then you already know you have a lot of boilerplate code like you might have to import the uh you know uh studio.io input output operations or any of the extra libraries that you need. But in this case the syntax is really simple. Let's say I want to print something like uh welcome to simply learn and done that's all you will get the code executed. So it's just a basic understanding of how simple the syntax of Python is. Now we will dive into the next module where we will understand the fundamentals like data types and all those things. So we'll quickly switch to module 2 and I'll like to place the same code here and I'll name it as data types variables and I'll deem it as markdown and execute the code. Now let's start with the first uh data type which is integer. So I'll call it as role number is equals to 10 and the next would be u you know I can give float it is equals to 57 and the next can be a name which could be a string type and it would be Alice is student this could be a boolean and I'll name it as true. There you go. So we have created a profile for a candidate and now let's say I want to check the data type and it's really simple. you can just print of and the variable names. So I've got role number here, I've got height and I've got name and also a boolean value which says is student or not. Let's quickly run this cell and there you go. So you have integer, float, string and boolean. So just like any other programming language, Python also supports a wide variety of data types. So these are the basic data types and variables that you will be coming across in Python programming. And now let's proceed with some naming conventions. So uh naming convention basic or best practices. So uh try to avoid any blank spaces in variables. So whenever you're naming a variable, try to avoid any of the blank spaces. You can take an example of student name in place of student name. Right? So this avoids a lot of confusion if you're dealing with the data frames or any of the real time analytics or any of the real-time programming situations. Now that we have a basic understanding of the data types, variables and the best practices, we can now dive into the third module which will be about the data structures in Python or data collections as well. And here we will be having all those uh collections which will be the set tpple and all those things. We can start with list. So what is a list? So list is an ordered set of elements or collection of elements of different data types or unique data types as well. Unique or similar data types. For example, let's say I want to create a list of fruits and it will start with a square bracket. Remember the square bracket. So apple, orange. Now I want to print fruits. Now let's understand something. So we have four different collections here. We have list, we have a set, we have dictionary and we have a tpple. So all of these will have similarities but they also differ in few situations. Now a list and a set are similar. They also are capable of storing different data types and all those things. Right? Let's say I want to include a collection of data types like name which is a character data type or a string data type and then I want to include the float data type which could be 10 point with decimal value and then I want to include role number which could be an integer they all store all those things now how they differ is the type of execution in the end let's say I entered some fruit names here apple orange grapes etc and if I want to append a new name I can also append a new name. If I want to delete something, I can delete something. And when I print, it stores the order. Let's say I entered apple in the first place. So apple could be coming in the first place, orange in the first place and gra in the first place. This happens in list. But when you come across set, that particular order cannot be executed. It might miss the order. It might go with orange in the first place or grapes in the first place and then comes the next no names. And when it comes to set, let's say I have a duplicated element here. Let's say I type apple for two times. Apple apple orange grapes. The set will not print apple twice. It will only print it once. Now this is one specular difference between a set and a list. And when it comes to tpple, is also same. It can also store different data types in one particular tpple. But the problem is tpple will not allow you to change anything. It is immutable. Now this is the second difference. Both set and list are mutable but tpple is not mutable. You might also face an interview question where an interviewer will ask you to change something in a tuple which can be done with a little trick. So that's uh have it executed using the inclusion of list inside a tpple. So this is possible tpple will include a list inside itself and vice versa a list can also include a tle in itself. So we'll go through all those things. Now first we have created a small list with names apple origin grapes and we are able to print that particular list here and we can also go through some uh simple operations. Let's say I want to append mango to to this particular list. So I can simply use it as fruits append function and uh the name of the fruit that I want to add will be mango. There you go. And I'll execute this. Now let's say I want to print fruits again. There you go. I have mango added to this particular list. And now let's say I want to remove uh something. So I'll simply use fruits dot remove function. And uh let's say I want to remove grapes. So I'll type down grapes. Close the function. Execute this. And now let's say I want to print again. There you go. So we have successfully removed grapes. Now this was the uh basic fundamental operation of adding or removing any element from a list. Now let's go through another example where we try to store different types of elements. Let's say I want to go ahead with Alice example. Once again here Alice is the string type and let's say her height is 5.7 ft and her role number is 10 and uh is she a student? Yes. There you go. Close the list. And now I want to print the items here. So you can just casually print items. And there you go. Now let's say I want to also uh understand the data types here. So I can just use the same print command. print type and since we using list here so I can go ahead with items which is the list name and I can give the cell address there you go and we can also make some modifications to it so it's quite understandable so the cell address 0 represents the first element in the list one will be the second element second will be the third element and third will be the fourth element so uh the addresses start from zero in list And when we execute we can understand it can also store string, float, integer and boolean data types in one single list. So now let me give out a single clue to you to understand list. So it might also be an interview question for you in future. Uh they can just give you an input and say identify if it is a list or tpple or a set or a dictionary. Then if you see the array or any um data type data structure starting with a square bracket then understand it's a list. Now so far with our understanding let's uh give a quick definition to list. So I have mentioned the definitions here. Let's quickly enter them here as well. So a list is a heterogeneous data structure meaning it can store multiple data types such as integers, floats, strings and booleans within the same list. Although Python allows mixed data types, in real applications, developers usually keep lists for better uh readability and processing. Let's say in real time you're using list then most recommended best practice is use a single data type so that you may not face any confusions with that. Now with that let's move on to tpples. So we'll mark it down as module 3 here the list and now here we'll start with tpple. Now let's start with the second data structure here which is tpple. So to define a tpple is an ordered collection of elements but it is not uh changeable or you can also term it as immutable and it is completely similar to list but there are some differences. If you want to add a new element to an existing tpple you may not. And if you want to delete something from an existing tpple, you may not. And if you want to make any kind of modifications to it, you cannot. That's the difference with separates tpples from list or any other data structure in the upcoming modules. Now, so uh another best way to identify if it is dppel or not is it will always start with an open bracket or parenthesis and closes with a parenthesis. Now swapping elements, inserting any elements, removing, reordering is not possible in this particular data structure and you can also use any type of uh append or delete operations. Now let's go with the same example. Let's say I want to add fruits. The only different was make happens here is you can just change the type of bracket and there you go. Now it's a tpple. Now let's say I want to print this particular tpple. There you go. it retains the order as well. Now apart from that let's say I want to add different data types inside a tpple. I can also do that and I can also type to repeat and I can also try to extract the data types as well. Now remember that interview question that we discussed changing an element inside a tpple. It is possible when you try to include a list inside the tpple. So let's go through an example of that as well. I will take an example of the same list that we have here or we can also create uh a new variable IQ which is interview question or a question is equals to let's say I try to enter some elements 1 comma 2 3 and the last element will be a list. Let's say I want to enter four and five inside the list and close the bracket. Now let's print the question and now you have the tpple printed. Now let's say I want to change one of the element inside this particular tpple which is inside a list. Let's say I want to change four five to 56. Now what you can do is you can simply type down the same question here and you can say question remember this addressing that we did here this particular one the same we can try to address the elements here. So we have the 1 2 3 right the third element is 4 5 so it starts from zero I want to allocate this particular list what 3 0 is equals to let's say six and now if I print this particular question then I have six right so there you go we have now successfully changed the element inside a tpple now we can proceed with our next data type which would be a set. Now let's quickly go through the definition of a set. Now so far we have understood what a tpple is and what a list is. Now to understand set you might have to go through the similarities that we had with list first. Right? So the only difference what separates a list and a set is the type of parenthesis we use. So here or the bracket we use in the list we used a square bracket in tpples we used a rounded bracket in the set we will use a flower bracket that's the only difference and apart from that if you want to include any kind of duplications inside a set that is not possible so for that let me go through an example let's say I want to create a new set here and the set could be named as numbers is equals to and it starts with a flower bracket 1 comma 2 comma 2 comma 3 comma 3. See I'm deliberately trying to enter some duplicate entries here. Now let's say I want to print numbers. So these particular duplicate entries will be eliminated and only the unique values will be printed inside the set. Now I can also go through the same example that we used before which is this one fruits name. And if I want to print fruits, sometimes the order may exist and sometimes the order may change. That's the difference between a list and a tpple. The orders might change here. So you can see grapes took the first position, orange to the second, and apple to the third. And if you want to add or remove any elements to this particular fruits set, you can also do that by a simple add method. Let's say I want to add some berries. There you go. If I print fruits again, I will have the new element added. Let's say I want to remove an element. So I can also do that by just using the remove f method or remove function. And let's say I want to remove apple. I can do that. And if I print fruits again, the element will be removed from the list. With that, let me also drop a quick comment here. The best way to identify a set is it always starts with a flower bracket. Now a set will also be capable of storing multiple data types as well. So we'll use the same example and here we have two different items but it is showing one once because it is considering the integer value of one as a unique element and the float value of one as a duplicate element of one including the boolean value of true here. That's the one reason why we just get one repeated once and the name is shown once. Right? That's the reason why we have it here. But in case if you really want to uh find out the uh data types of all elements here, you can just go through a for loop here. And here you have the one value which is integer name value as string 1.5 which is the class and this particular one is called as float here. And with that now we enter into the fourth collection or data type which is dictionary in Python. So dictionary is nothing but a key value pair. Let's say you wanted to store some elements inside a dictionary. The only difference with separates dictionary from all the other three data types is it stores the elements in a key value pair. Now let's go through the examples for that as well. Before that let me add up the definition. This is the definition. Dictionary stores data in key value pairs. A dictionary is ordered in modern Python versions. It is changeable. It stores data as key value pairs and keys must be unique which means you cannot use one key for different type of elements. Let's say I try to add uh a key name as ABC and I store some value inside it and again I reuse the same ABC key and store a different value in it. Here what happens is Python will save the latest entry into ABC and it will remove or eliminate the previous entry. You can also go through that example. No worry. Now let's create a new dictionary as student. And here I'll use name of the student. We can use the same name which is Alice. And let's say age is equals to 20. Let's add a course for Alice which could be Python. And now you can close the dictionary. Since it is key value pair, we're supposed to use colon not equals to. And we need to separate them by comma. There you go. Now let's print student. There you go. Now we can make some mild changes to this particular code segment and try to identify the data type as well. Now let's go through this particular element which is defines the dictionary as changeable. So I'll use the same code segment and I'll try to change the name or course of Alice. Let's say I want to change the course from Python to data science. So we have successfully changed the course name from Python to data science. And now if I print student again, the course will be changed here. Now let's say I want to add a new element to this particular dictionary. Let's say I want to add the location. So student. So I've added a new element to this particular dictionary which is location of Alice. Now let's try to print student details. And now we have the city name New York. And now let's say I want to remove an element. So I can use simply the delete command. I can simply use the delete command and the element that I want to remove. We can remove the city which we have recently added and then now there you go. So city was not included in this particular code segment. So that's why it did not recognize. Now let's say if I want to print student once again there you go. City has been successfully eliminated. Now let's discuss about the duplication of keys. Let's say I try to store data or I'll name it as duplication. Create a set. Create a dictionary and then I'll use name is equals to XY Z. Similarly, I'll try to reuse the same code segment. I'll create a duplicate entry and name it as ABC. Close the list. And now let's say I want to print. Yeah, we missed a comma. Let's say I want to print this particular dictionary. Now what happens is it will save the latest entry alone not the previous entry. Now that we are done with the data structures or collections in Python which was set list and dictionaries and tpples we can now dive into the string operations. So we can understand string data structures in a much better way. Let's start with some most commonly asked questions like string slicing or string matching etc. Such type of examples will help us understand what is the basic functionality of strings and how to implement them in real time. So we can start with string functions strings from here. So let's say I want to concatenate two strings. Let's say I have two strings here and I want to combine those two strings. Now let me give the string first one as first name. Remember the uh declaration best practices that we discussed, right? So we will have uh the underscore separating the variable names so that we don't have any blank space or you can also go with this type of uh you know representation but I'd like to go with this one. So first name let's say we will give uh John and uh second name is equals to now let's say I want to combine this together and save it in a new variable which says fill name. So I what I could do is I'll just copy this and I'll paste this over here. And then I'll use the concatenation which is the plus symbol. And then we will also use double quotes to save a space there. And then another concatenation symbol which is plus. And I'll copy paste second name and I'll place it over here. And then I can just go ahead and write the print command and copy this full name and paste it over here. And you can also add a text saying the combined string result is equals to the first name or the full name. There you go. Run the code and there you go. So you have combined string right here. Now another most commonly asked interview question is you might have to you know find the length of the string. they might give you uh some random text and they will ask you to find the string length of this particular thing. So let's try that as well. So I'll write down a text which says uh let's go with Python programming. This will be our string and uh let's imagine that this is your question and they will say find out the length of this character or length of this string. So let's declare another variable which says length is equals to we will say the string length in this particular variable. Now we will use the length function and we will copy paste this text here inside the length function. Now we will use the print command and uh we will type down length of the given string is length. There you go. The length of the string is 19. Now similarly you can also face another question which says convert to upper case or lower case right convert to upper or lower case. So it's really simple. We can use the same uh string that we have used in the previous example. So you can write down here and then you can directly write down the text as well which says print text in upper case from print text in lower case. So mild functionalities will be you can copy paste this one and change this part and you can paste text right here and you can call the upper function. So dot since we're in lower we'll call lower function first lower function and close the bracket. Similarly you can copy this and paste it over here. You can see how simple the context and syntax is in case of Python. You can just see it. You can just call it as upper and Python will automatically understand that the uh user wants to print some text in lower case and upper case and there is no complexity here as well. There you go. So the text was Python programming and we have I think we have missed an O there. There you go. So let's run the case again. Python programming in upper case and Python programming in lower case. So, so far we have converted the text into upper case and lower case and we covered three uh interview questions and answers to understand the functionality of strings. Now we can go ahead and understand string slicing as well. So let's say this is the string slicing question and they give you some text. Let's consider text is equals to learn Python with simply learn. This is my text. I'll enter the text in double quotes. Now I want to split uh a part of this text. Let's say I want to print the first 1 2 3 4 5 6 and another six. So let's say I want to print the first 12 characters, right? I want to slice the string into two halves and I want to print the first 12 characters which is learn Python. So the first five is learn space is the sixth what I feel and next is the sixth which is python learn space python are the first 12 characters. Now I want to print these first 12 characters. So I can just copy this print command here and I can say the first 12 car and now here I want to make slight changes. So here I want to make slight changes. So I'll take the text and I'll use a double quote and I'll place a colon and then I want to count the number of characters. So I want 12, right? So I'll just write down 12 and close the square bracket and close the bracket over over here again. Now if I print this, I will have the first 12 characters. Now let's say somebody asks you to print the rest of the string. Let's say I don't want the first uh n elements of the string. I just want to print the next elements of the string. You can also do that. So the only change is you will replace the colon in the first place to the next place and the number of elements that you want to omit. I want to omit the first 12 characters here and then the rest of the characters which are with simply learn I want to print them here. So just a mild replacement of colon from left to right and then that's done. If you execute this we have the rest of the characters which is with simply learn. Now we can go with the next interview question which is can be considered as text matching or you can also consider as text replacement. So first you need to match the text and then replace the text right. So both in one shot text matching and replacing. So the text can be let's consider I like programming. Let's say I like programming in Java is my text. So let's encode this inside double quotes. And now I want to replace uh this particular text which is Java with uh Python. So it is really simple. Uh let us take a new text variable. This is my new text variable. And here I want to use the text replace function. So I'll just take this particular variable text and I'll put it here. And I'll call the replace function. And now I need to provide what needs to be replaced by what. So I want to replace term Java with uh Python. So I'll separate that with column and mention the new term which is Python. And there you go. And now we can just print the new text here. So I'll copy paste the print command and then I'll just call print new text and that should be done. So there is a small error. Okay, I did not write the spelling correctly. So replace there you go. Now we have replaced term Java with Python. So simple, right? You can just identify and then replace the text. Now let's go with another interview question and let's say here I want to find out if a given text element is present or not. We can consider the same text here as well. So let's say I like programming in Java. check if a specific part of string is present. So now this is my text right I like programming in let's say I'll go with not Java I'll go with Python. So I'll replace Java with Python. Now I want to identify if Python is available in this particular text or not. So this is a little bit early for conditional statement but it's not a big deal. It's really simple. So we will be using conditional statement. Again we will be learning a lot of other conditional statements as well or loops as well. So we will be having if l if and else if a lot of those but this is a little bit early but not too complicated. So we will be using if text here or if condition here. If this particular element is present in the text then we can print yes this present this is present in the text. Else no is not identified is not present in the text. So we will go with a simple if condition. So if the term Python is available which is in text. So this is our text right. I'll copy paste this one here. If it is available in text and colon then print text is or uh text is found or element is found else element is not found. So since we are printing the text form of output we will encode this inside double quotes and then we will have L here. So else double quotes we will use the same print statement. Element is not found. As simple as that. Now let's execute this. There you go. Since we have Python, we have found the element or text. If we replace this with Java and try to execute this, element is not there. So element is not found. Now this was a most common interview question that we dealt with next module which is about operators in Python. So let me uh name it as module 4 which is operators in Python. And since this is a markdown, I'll make the cell as markdown and save it. Now operators are nothing but the mathematical operators or arithmetic operators that you most commonly use in any of the programming language which could be plus, minus, division, multiplication, floor division, modulus etc. or even sometimes exponents in a very rare case. So let's go through those all those examples in one shot. And most of the time she might also face this interview question where the interviewer might ask you that prepare me um some uh function or something like that which takes the input from my end. Here we will go through an example where we give the input but interviewer might ask you to provide a program that can take the input from the user and then execute the output. So we'll go through all those things in one shot. So uh let me declare a few variables. Let's say a is equ= to 10 and b = 20 or two. Let's go with two. And then uh we can directly start with writing the print statement. So I'll write down the print statement. Addition of two numbers is equals to a + b. There you go. Now we can just copy paste this and simply paste a couple of times. And uh difference of two numbers is a minus b. Multiplication of two numbers is a star b. Division of two numbers is a divided by b. Floor division of two numbers is double slash. And exponent of two numbers exponent value of two numbers is just replace the star with double star. And there you go. I can execute the code and you have all the outputs in one shot. There must be an error somewhere. Yeah, we missed out this one. Let's execute again. There you go. So, you have addition, difference, multiplication, flow, division, exponent, all those things in one shot. Now, coming to the interview question where you might have to go with user input. So, it's really simple again. You just have to declare a couple of variables which take the input along with the input uh command. So let's say I want to take uh two inputs. So I'll declare num one is equals to I just want to go with uh a data type here as well. So let's go with float for the safe side. I want to go with float and I want to go with the input command or input function where it takes the input from the user. So we can give it uh a text message as well. Enter the first number and close the bracket. There you go. You can copy paste the same code here and paste it. And again we will call it as num to enter the second number. So far so good. Now we can have a third variable which says result and you can name it as predition. So we can use the same quotes from here as well. Instead of a + b, we will replace that with result enclos the brackets. And result will have num 1 + num 2. Let's execute this function. So our first number could be 10. Second number could be two. And the result is there. You see? Now you can copy paste the same command or same code and try to perform some subtraction as well. So you can just replace plus with minus and difference of two numbers. There you go. 10 2 8. Now for division, there you go. Now for multiplication, plus will be replaced by a star. There you go. You can also go with floor division. So I think you already know what is a flow division. So flow division is something where you give u an odd number to an even number and it will give you uh just the u uh remainder part without decimal values. Let's say if you try to divide 10 by 3 uh the actual result will be 3 33 3 something like that right but you'll just get three here and apart from that you can okay we did not give a complete flaw division we just gave a regular division so uh let's go with 10 again and three so that's the value you'll just get uh you know the whole number it's like a rounded value of uh so that's what the floor division is and you can also go ahead with exponent value as well let's say you just Replace the forward slashes with double stars and you can give exponent exponent value and run. Uh you can give three three three cubis uh 27. So that's how you go with uh the uh user input related mathematical operations in Python. And let me also give you a small assignment here. The assignment would be uh prepare me. Let's consider this as an interview question. You might face this. Who knows? Prepare a small calculator that takes user input and also has an operation that asks for what kind of operation it needs needs to be done. So let's say the user might ask give me the sum of two numbers and might give the input or he might ask you multiplication of two numbers and give the operation as multiplication. Right? That's the kind of uh output that we want. So this is your assignment. Consider this and do let us know if you want the answer or do let us know if you already found the answer. You can paste that in the comment section below. Now we will enter into the module five which will be conditional statements and you can also combine loops as well. This is a module five and loops. Conditional statements and loops. Since this is a markdown cell, I'll replace this to markdown and execute the cell. And there you go. So we will be having if statement and we will also have if else statement and we will also have nested if or in this condition we will call it as l if and apart from that we will go through a couple of more like uh for loop while loop etc. for loop statement by loop and all those things. If we have missed out anything we'll go uh for it on the go. So far so good. This is our uh quick agenda for module five. Correct. So these are the uh common conditional statements or loops that we will be facing. But um we will also learn these in a perspective where we are trying to question something. Let's say if you want to go with the if statement uh we can go with theory. If functions like this you'll have a condition if this satisfies then that. But in instead of that theoretical approach we can go with a practical approach so that you can understand in a much better way. Let's say we consider an example. We have a variable which takes the input from the user which is a numerical value and if that particular numerical value is negative then that is a negative number. If it is equals to or greater than zero then it should be a positive number. So you are kind of understanding how it goes right. So let's try that example with if condition. So let me take an example or we can take this particular code from here and just try to place it here and uh we will uh name it as num and we'll take uh integer type of input and the enter the number. This would be my condition and this would be my message to the user. And now comes my condition. If number is greater than or equals to 0. Basically it should be uh greater than 0 not equals to 0. But in case if somebody gives zero that could be we can go with that in an else if condition but for now it's okay. Uh print the text as so this is the condition. Now print number is positive and close this. So since it's a text type of output, so I'll enter it in double quotes. So we didn't mention an else condition just for the sake of understanding how an if works. Now I'll press some number is positive. Now we'll go with the if else statement here so that we understand what happens if somebody gives me a negative input. Right? So I'll copy paste the same code. And now we will proceed with an else statement here. else print we can use the same code as well number is negative right let's enter and now let me enter some number as minus 19 so the number is negative so that's how an if and else statement works now we can proceed with another uh statement where you can have nested if statement or in common terms we can also call it in terms of python as l if statements so let's copy paste the same recommend here and paste it over here and uh instead of numbers let's mark it as marks in an exam and we can go with the float data type and enter the marks if uh marks are greater than equals to 90 I would say class as distinction and l marks are greater than equals to 65 I'll deem it as first class marks are greater than equals to 45 then we can deal as second class another lf 35 then pass and the last option where this particular loop should close or conditional statement should close is where comes the else part and here I can print fail there you go now we can quickly execute this statement let me give some marks which are fail so there you go fail and if I execute again and if I give about 91 marks then I got distinction. So this is how the multiple else if statement or the nested else if statement or lf works in Python. Now we come across the rest of the two condition statements which is a while loop and a for loop. So let's go with for loop first and while loop next. So I'll go with for loop. We need a small let's go with list. I want to add the same fruits example and I want to enter a couple of fruits. let's say apple then I want to use grapes then we can go with the mango so these are the couple of uh elements which I want to have in my list and now I want to print these elements so for that we can directly go ahead with the print statement but in case if I want to print them one after the other then I need a counter variable and using that counter variable the control flows through this particular loop one time at a time until all the elements are printed out. So for that let me assign a counter variable. So in normal terms we can use any counter variable. So I let me name it as I as my counter variable. Let me comment this I here in this code is a counter variable which basically maintains the count of uh the number of times the control went through the loop. Now let me write down the for loop for this. So for i in the list fruits print i. There you go. So I missed a colon here. Indentation problem I guess. There you go. So we have printed apple, grapes, and mango. So whenever you're writing a loop, make sure that you don't miss this particular part which is a colon and the indentation. So if you miss the indentation and colon, sometimes the error may pop up. Now with that, let's dive into the while loop. So you can use the same condition here. We can also uh make use of another example. Let's say somebody asks you a question to print uh five numbers using a loop statement. So you can use while loop there. So while loop so I mentioned that in a comment. Let's go with a counter variable. So I'll mention it as count is equals to zero and while count is less than five. Again I missed the colon there. Count and count should be you know uh it should be increasing every once it goes through a loop statement. So equals to + one. So count is equals to count + one. Basically every time a loop runs you need to increase the value of count by one. So zero becomes one after the first loop. Then two and so on. So I want this loop to run for five times. So I will have five element. So once you execute this while loop, we have the first five elements printed here. And if we had declared some other variable to this count, then we might have got the five count from there. So it's how it goes. Now we have also a couple of common interview questions based on conditional loops and loop statements here as well. We can go through this. We can share this particular workbook in the comment section below. And let's say if we wanted to find out a number is even or odd, you can also do that. Let's say I want to provide a number which is odd. So if the modulus of the number is resulting in zero then that particular number is even. If not it is an odd number. And you can also print uh some couple of number uh let's say start from 1 to 10 then you have it here. The only thing is you need to declare the variables range here. Let's say I wanted to print from 10 to 110 or let's say 20 and I have to change the input variables here and I'll have a 10 to 20 or 19 variables or numbers resulted in this particular section right here. And let's say if you wanted to find out the largest number of three which we already done with the LF statement uh you know kind of resulting in mass what's the output. So here you just change that particular instance here you can declare three different variables and it takes three different inputs and based on that you will get the output. So let's say I give the first number as 10, second number as 20 and the third number as 30. So the same l if statement works here. The nested else statement works here. If A is greater than B, then B is greater. If B is greater than A or C, there's another. So there you go. Largest number here is 30. Now here we have print multiplication table using a loop. Right? And here you need to provide the number. Let's say I want to go with five. And the five table is right in front of my eyes. And count numbers greater than 50 in a list. So there you go. And now we have the list here. and based on then the any element which is greater than 50 is 55 and 60. So we have 89 as well. So we have three elements which are greater than 50 in this particular list. Let's say if let's say if I add another number or two then I run this command and again and I want to find out how many number of elements are there in this list which are greater than 50 then I'll get the result as five. So we have about 55 60 89 90 and 67. the find numbers which are greater than the given number which is 50. So these are a couple of more interview questions we can go ahead with in the form of conditional statements and loops. So this particular workbook will be shared with you and apart from that now we enter in our last module which is object- oriented programming. So object-oriented programming is usually the next step in Python fundamentals because it teaches you how to organize code into reusable and scalable components. So uh the core components of object-oriented programming are classes and objects and apart from that we have encapsulation, inheritance and polymorphism. First let's go with classes and object. So a class is a blueprint for creating any object and an object is the instance of a class. Let's consider it in this way. A class let's go with the blueprint example. Let's say you build a very nice blueprint to create a device or a mobile for a computing device like a laptop or something like that. And once you have a finalized blueprint, you can create n number of devices out of it. The same way if you have a completely structured class for you, then you can create n number of object out of it. So in our case, we have a class with state student and the object that we yield out of this class student is this one s1, right? S1 is the first uh that we're creating here and student is the class and s1 is the object created around the class. Suppose we were supposed to create the class first and then if we run the object then we have the object creator which is John H22. Now comes the important part the init constructor. So the init method is the constructor used to initialize object properties. Whenever you declare a class and then if you want to create an object out of the class you need something to initiate the process of building an object. So that is the init constructor here and let's run this code. So that we have created a class and use the init process and assign the object which is Alice age 21. Now comes the encapsulation which is one of the fundamental pillars of object-oriented programming. Encapsulation as the name speaks for itself. Encapsulation means restricting the direct access to some variables. In Python this is commonly done using private variables. So here we have the bank account class and inside the bank account class we have the init method, deposit method and the show balance method. So we will be calling these methods and executing our outputs. So let's execute this code and see the output. So there you go. So the initial balance was 1,000 rupees or 1,000 INR and then we are trying to call the deposit function and add the balance to it which is right here. Uh balance is equals to plus the amount. The amount was 500 and the final balance is 1,500 as you can see here. And now we come into the inheritance which is the next pillar in objectated programming. Inheritance allows one class to reuse the properties of another class. And here we have two classes which is employee class and the manager class. And then we have the developer class as well. So here we will be using the properties of the employee class and display the employee details and their salaries. So let's run this code and call the output. There you go. So the employee is Alice and her salary is 90,000. Alice approved the leave request and the employee was Bob and his salary is 70,000 and Bob is writing the Python code. Basically he's a Python developer. Now we come across polymorphism and polymorphism allows different classes to use the same method name with a different behavior. So here you can see we have a method definition which is named as pay. But the classes are credit card payment, PayPal payment and UPI payment. All these three classes have the same method which is pay and the name of the method is also the same but based on the function call the method will be initiated. Let's say I want to call payment from a specific class. So if I call the uh credit card payment class then this particular payment method will be activated or called and if I call from PayPal class this particular payment method will be activated and same goes for UPI. So let's try to call all those three in one go. There you go. So you see certain amount was paid using credit card, certain amount was paid using PayPal and certain amount was paid using UPI. So this is how you can go through the object-oriented programming in Python. Now don't worry, we will have this uh complete Python tutorial notebook saved for you from starting to the beginning. Right? So this is where we started and this is where we ended. All these code documentations and the code segments will be saved. We will download this and we will share it with you so that you can have access to it and this particular file will be mentioned in the description box below. So you can download it and run it through your Jupyter notebook and follow along with us. And with that we have come to an end of this session on Python tutorial for beginners. And with that we have reached the end of this session on Python fill course for beginners. Should you need any assistance or any other resources used in the session like code documentations and others, please feel free to let us know in the comment section below and our team of experts will be happy to assist you at the earest. Until next time, thank you for watching and stay tuned for more from Simply Learn.

Get daily recaps from
Simplilearn

AI-powered summaries delivered to your inbox. Save hours every week while staying fully informed.