Python Tutorial for Beginners | Python Programming Language Tutorial | Python Training | Edureka

Python Tutorial for Beginners | Python Programming Language Tutorial | Python Training | Edureka


Hey everyone,
this is Neel from Edureka, and welcome to today’s
session on Python Tutorial. Now, the main objective of
today’s session is to help you build a good fundamental
knowledge in Python. Now, it’s always essential that
you have a good fundamental knowledge if you wish to master
any programming language. Now, keeping that in
mind, let’s move forward and look at today’s agenda. Now, we’ll begin the session
by first having an introduction to Python, and we’ll
understand who uses Python in the industry, and for what purpose. After that, we’ll be looking
at some of the main features that Python has to offer,
as well as the various operators and datatypes in Python. Then we’ll look at the flow
control management in Python, and functions in Python. Finally, towards the end of our
session, we’ll be discussing how you can perform file
handling using Python. So, any questions with
respect to today’s agenda? Okay, Sandeep is clear, John, RJ, Raj. Divya. So let’s move on and have
an introduction to Python. Now, Python was created
by Guido Rossum in 1989, and is one of the most easiest languages that you can pick up. Now, Python follows an interpreted logic, compared to the compiler
logic which most other programming languages follow. Apart from that, it is an object-oriented programming language,
as well as a high-level programming language
with dynamic semantics. Now, you can see in the image below, Python follows both
object-oriented programming style, as well as procedural programming style. And it’s a high-level language and is one of the easiest to pick up. So I have my first question
here: what is the difference between an interpreter and a compiler? Alright, Raj, so let me put it this way: in case if you are using
an interpreter to check the errors in your code,
so what happens is, the interpreter reads
every line individually. It reads one by one, and in
case if it finds an error in one of the lines, what it
does, it stops processing it, and it gives the user an indication that this line has an error. Now, when you look at a compiler, then what happens is that the entire code is processed in one go, and then you get the complete list of errors present. So I hope that was clear, Raj? Alright. So, anymore questions? So, Divya has a question here: what is the difference
between object-oriented and procedure-oriented? Now, don’t worry, Divya,
we’ll be discussing this in the upcoming slides,
so I just request you to be a bit patient. Alright, so I’ve got a
confirmation from Santoosh, RJ, asking me to move forward; great. Now, let’s look at who uses
Python in the industry. Now, here are eight companies
that make use of Python, in different domains. When I say domains, again,
I refer to how Python is being used for various
application development, various fields of interest, again. So let me give you a better idea. So let’s look at YouTube. Now, YouTube is one of
the most popular video sharing services present today. Now, YouTube is largely
written using Python. So, there, Python is
being used as a scripting, as well as a programming language. Again, when you look at Google,
which is its parent company, it uses Python to improve
its web search systems. So Python there helps you to
get better search results, as such. Now, on the opposite side
of this, when you look at organizations like
NASA, now, NASA makes use of Python for its scientific
programming tasks. So here again they’ll be
using a Python program that can be used to perform very large scientific calculations. Again, when you look at NSA, which is the National Security Agency of the US, they make use of Python for
cryptographic analysis purposes. So you can see how Python is being used across different domains,
different organizations, so if you see present
trends, Python is present in most of the domains as such. So I hope with this you’ve
got an idea of how Python is widely being used
in the industry today, and (muttering) given you a certain idea of how Python is presently
doing in the industry. Now, moving forward, let’s
look at some of the features that Python has to offer us,
and these are the key features based on which Python
is being used so widely, across in the industry. Now, to start off, you can see Python is simple and easy to learn. Now, the reason that Python
is simple and easy to learn, is mainly because it resembles
the English language a lot, and when you check out the
other programming languages, compared to them, it’s quite easy to read and write programs in Python. Now, after that, Python is also a free and open-source program, and
it follows the FLOSS philosophy where you have free and
open source software, so you can freely
distribute as well as create and modify its source code, and again, distribute it as well. So you may have different
flavors of Python, as well, and you can use any one of
them and distribute them without any problems. Okay, so JR has a question here: is Python simpler than Java and C++? Definitely, JR; when you
look at the comparison between C++ and Java,
definitely, I would assure you, Python is one of the most
easiest language to learn. Because let’s say if you’re
writing a program in Java that would take up about
200, 300 lines of code, here, using Python it would just be
about 50, 60 lines of code. So you’ve completely cut
down the number of codes to about 20 percent of your actual size. Now, moving forward, then you know, as you may be aware of,
Python is a high-level programming language, and
when we talk about high-level, it basically means that
you can write your code directly using English,
and Python will, in turn, convert it to the
low-level machine language. So when we talk about low-level language, it basically refers to the assembly level programming language. Now, those are written
usually in ones and zeros, but at any point, if you make any mistake, it becomes tedious, so through Python, what happens is you’ll
be writing your program in a high-level language and
then when you compile it, then it gets converted
to a low-level language for the machine to read and understand. After that, when we look at
the portability of Python, now Python is supported by most platforms present in the industry today. It could be a Linux platform, it could be a Macintosh
platform, it could be even a Windows platform, or let’s say, even your Playstation supports Python. Then moving forward, Python
supports different paradigms. Now, again, when we refer
to the programming paradigm, this mainly refers to
the four different styles of writing program; you have
the object-oriented style, you have the procedural
style, as well, paradigm, and then finally we have
the logical paradigm. Now, Python supports two
of these major paradigms, that is the object-oriented paradigm, as well as procedure-oriented paradigm. Now here, coming back
to your question, Divya, when we talk about object-oriented style and procedure-oriented style,
procedure-oriented style is mostly preferred when
you are going to be writing a program that has to be
executed step by step. So there you’ll be
using smaller operators, like functions, where you
divide your code into small bits and store it as a function so
that you can reuse it as well. Again, but when you look
at object-oriented style, you’ll be making use of
user-defined classes, objects, and so forth. Now, don’t worry if you’re
not completely clear on this. We’ll be talking more
about classes and objects in our upcoming session. Now, the final and perhaps
the most important feature is the extendability of Python. Now, when we talk about the
extendibility in Python, you can completely integrate
Java as well as .Net components and if you wish, you can even
invoke C and C++ libraries, as well; so again, you
can perform cross-language operations as well. So with this, Python’s
completely extendable to most popular languages. Now, I hope you are clear
with Python’s features. Okay, so Raj says clear, so does Santoosh. Matthew, John, Ron, Divya. That’s great to hear, guys. Please let me know, in case at any point you are not clear, then
I’ll be able to help you and clarify then and there, itself. And make sure you’re making
this an interactive session, because I want you to have a
complete learning experience. Now, before we move forward,
let’s begin by installing Python in our system. Now, to download Python,
all you need to do is go to Python.org and you can
download the version of Python present in their homepage. Let me show you how it’s done. So just open your browser
and type: Python.org. So on the homepage
itself, in the first tab, you can find download option present here. So, in case if you’re
using a windows system, you can directly download
Python version 3.6. So this is the version
that we will be following as part of our course, so
make sure you’re downloading Python 3.6 version, not 2.7.13. And in case if you’re
using any other system, let’s say for Mac for
example, just click on Mac. And then you can find all
the releases for Mac OS. So please go ahead and
download the version of Python, and the installation is quite easy. It’s just simple steps where
you have to keep clicking next and in case if there’s
any troubles, I’m here, I’ll be able to assist you. Okay, Sangita is asking me: why are there two versions of Python? Alright, Sangita, so this is
mainly because there are still organizations that make
use of Python version 2.7. So what Python has done is
it’s not stopped completely development with version 2.7, but still, it keeps adding
new features to Python 3.6. So I’d recommend you’d
follow 3.6 version, itself, and 2.7 is mainly for those organizations that are still working on 2.7 version. There’s not much difference,
but certain differences are there with respect to syntax. Don’t worry, you’ll be mostly
working on Python 3.6 version in the industry itself. Alright, so now that all
of you have downloaded and installed Python on your system, let’s move forward and install another IDE on which we’ll be coding our Python codes. Now, I’d recommend that
you download PyCharm IDE, as this is one of the most
popular and widely used IDE, and it’s very simple to use, as well. Okay, so, John is asking me:
why do I need a separate IDE? So, John, when you install
Python, by default an IDE provided by Python is already
installed on your system that is Idle, but let’s say you’re working on multiple files that
are related to each other, or let’s say you’re working
on a huge project itself, with multiple interrelated files as such. Now, in that case, Idle
would not be an ideal IDE for you to work on, and
that’s exactly why I recommend that you download PyCharm. Now, to download PyCharm, just
search for: download Pycharm. And then just click on the
first link that you see. So when you do that, you
will automatically be directed to the download page. Here you have two versions
of PyCharm available. One is community, as well
as the professional version. Now, I recommend that you
download the community version, as the professional
version is a paid version. And most of the learning,
as well as the practicals that you wish to execute, can be done on the community version itself. So please go ahead and
download and install PyCharm, in case if you’re facing any
troubles, do let me know. I’ll be able to assist you. Alright, so now that all
of you have downloaded and installed PyCharm,
it’ll be really helpful for us to simultaneously
learn and work it out. So when I’m showing you an
example, you can simultaneously try it out parallelly, so
in case if you’re not clear or you’re stuck at any
point, I can help you out. So let’s move forward
and look at the operators present in Python. Now, there are mainly seven
different types of operators present in Python. Now, the first is the
arithmetic operators, then we have the assignment operator, then comparison operator,
logical operator, following that is bitwise operator, after that is the identity operator, and finally we have the
membership operator. Now, don’t worry, we’ll
be looking at each of them individually as well as
(muttering) operators they have present in the list domains. Now, first off we’ll look
at arithmetic operators. Now, these are simple
mathematical operators that you’ve seen earlier: addition, subtraction, multiplication and division. And apart from these four basic operators, you also have exponential
operators, modulus operator, and flow division operator. Now, when we talk about
the exponential operator, basically when you have to write a number to the exponential power,
let’s say five power 10, then you’d be representing
five to the power 10, normally, but in cases where you’re
using it on Python, it’ll be written: five, double star, 10. So here you can see we’ve
written: two, double star, three. That is two to the power three
gives us the answer of eight. Now, after that is the modulus division. Now, normal division basically
gives us the quotient of dividing, but in case
of a modulus division, we actually get the remainder here. So there would be certain
cases where you wish to have the remainder
rather than the quotient, and this is where modulus
operator comes in handy. So, let me give you an example. Let’s say if you wish to
check if a number is even, then definitely you can
use the modulus operator and check if it is
completely divisible by two. And after that, we have the flow division. Now, when we talk about flow division, here basically what you’re
doing is that you’re dividing a number, and if there’s any
decimal part of that number, you’re rounding it off to the lower part. So let’s say if we get an answer for 5.6, then you’re rolling it down to five. So, don’t worry if you’re not clear. I’ll show you an example,
and that way it’ll be easier for you to understand. Let’s just open up PyCharm. So here, let’s begin basic
arithmetic operators. Now, two things to be kept in mind here. Firstly, you do not need
to declare a datatype for the variable that you’re using, and you do not need to
declare the variables before itself, before you use them. So in case if you’ve worked
with other programming languages, let’s say C or Java, there, what you need to do is at first you need to specify the variable name, then you need to specify the
variable type, and only then can you use that variable
as part of your program. But in Python, you can
keep declaring variables as per your needs. So let’s say you have two
numbers, lets say num1, which is equal to 10, and I have num2, which is equal to 20. Now what I’m going to do
is I’m going to directly display all the arithmetic operators. So, to print anything on to your screen, you can use the in-built operator print. So just type P and you can
see the print come out, directly prompted. Now, this is something
that is very helpful in case if you’re using an
IDE, because it directly starts predicting what
commands you wish to execute, or what variables you’re
going to be using. So let’s say print, and start
off with num1 plus num2. Equal to. Now, here put a comma,
and then you can specify the addition operator. So let’s say… Similarly, let me just copy
paste for all the arithmetic operators, so then we have subtraction. After that is multiplication. And then we’ll look at division. Then we have discussed three new operators that were exponential power,
modulus and flow division. So let me just give you
examples for them as well. Let’s say for exponential power, I’m going to compute five power three. For modulus, let’s say I’m
going to divide 20 by three. And finally, for flow division,
to help you understand, let’s take a very popular example. Let’s say I’m going to
compute 22 divided by seven. Now, we’re all aware that
this leads to the value of pi, that is 3.14, and goes on
to be a non-terminating. But let’s just see what
answer we would get when we do flow division here. Now, before I go ahead and print, there are a few things
that I want you to notice. Now, I’ve used double
parenthesis some places, I’ve use single parenthesis some places, but don’t worry, in Python,
it does not differentiate, whichever parenthesis
you do, Python definitely accepts it as part of the string. So let’s go ahead and run this program. Right-click on the workspace
and you can directly run the program by
clicking on run operation. So you have the results here,
for the addition you have 10, for the subtraction, minus 10, multiplication 200 and division 0.5. Now, five to the power
three has given me 1.125, and then when I modulus divide 20 by 30, I get a remainder of two. Finally, we have seen when
we perform flow division, the value which is supposed
to be 3.14 followed by multiple digits has
been rounded off to three. So this is what I was talking about when I talk about flow division. So are you clear with respect
to the arithmetic operators? So Rachel has a question here: what happens in case if my value is 1.7? Now Rachel, irrespective of any value, let us say (muttering) whole number. So let me just give you an example. So let’s say: 3.8 flow divided by two. Now, this is supposed to
give us a value of 1.9. Let me just show you what
output you’d be getting. So you can see you’re
getting the value as one. Now where it should have been 1.9, it has been rounded off to one. So is that clear, Rachel? Alright, so let’s move forward
and look at the next set of operators that is the
assignment operators. Now, before I go into
the assignment operators, there are two things
I’d like to put across. Now, the first thing is: when do you use an assignment operator? So let’s say I have three variables. So num3 equal to: num1 plus num2. So in this case, what happens
is that first the expression to the right is computed,
and then the value is assigned to the left variable. Now this is important that
you remember it’s always the expression to the
right is first computed, and then you’re assigning
to the left variable. Now this is in cases where
you’re using three variables. Let’s say you need to
use only two variables. Now what happens in that case,
is that when you say num3, equal to num3 plus num2. Now this becomes a
tedious task where you are repeatedly using this, so
Python actually gives us a shorthand writing, using
an assignment operator. So let me just command this. And here you can rewrite this expression that is num3 is equal to num3 plus num2, as num3 plus, equal to, num2. So this directly translates
to this expression. It is just that we’re
using a shorthand writing, using an assignment operator. So we are combining an arithmetic
operator to an assignment option, and then we’re
storing it into a variable. This comes in handy when you’re
working with two variables, so are you clear with this? Okay, let me just print it and show you, that way it’ll be easier
for you to understand. Let’s say: print num3. And I’ll print num3 here also. So if we just run it, you
can see the value 30 and 50. Now, 10 plus 20 is giving me 30. You can see we have 10
as num1 and 20 as num2. That is giving me the
value of num3 to be 30. That is getting printed here. And then when I’m performing
num3 plus equal to num2, that is, I didn’t assign num2 to num3. Then we’re getting the value as 50. So, are you clear with this? So now that you have
understood how the assignment operator works, let’s look
at some of the examples here. Now, we’ll begin by
first assuming the value of X to be five. Now when you perform divide and assign, what happens is five divided gets, gets divided by five and gets stored in X. Again, five modular five is stored in X, and you’re printing it as zero. Five flow divided by two. So where you would have got
2.5, due to flow division, it is being rounded off to two
and it is being stored in X. Similarly, five to the power
five, and the value is 3125. So this value is stored in X. So are you clear with respect
to the assignment operator? Okay, Divya says yes, so does Santoosh, Sandeep, RJ, Raj, Ron, Matthew, that’s great. So let’s move forward
to the next operator. That is the comparison operator. Now, using the comparison operator, you can compare two operands. So we have the greater
than, the less than, equal to, and not equal to. So in case if you were not clear earlier, single equal to when
you’re using is considered to be an assignment
operator, and double equal to is a comparison operator
where you’re comparing both the operands. Now the output of a
comparison operator is always a Boolean value. Now, don’t get confused
when I say a Boolean value. It just basically means it’ll
either be true or false. So let me just show you the
outputs of these operators. Let’s say: print. Num3, greater than num2. I take num2 equal to num3. Print, is num1 not equal to num2. Now, always make sure
you put a comma there, but in case if you do not
do that, what happens is you get a syntax error,
so make sure always, after you’re specifying a
string in this print statement, if you’re going to print a variable, then you specify with a comma. Num1, not equal to. Now, again, when you say not equal to, it’s an exclamation mark, and then you have an equal to operator. Let’s run this. Again, right-click on the
workspace and select run. So you can see: is num3 greater than num2? Yes, it is true, because
the value of num3 is 50. Similarly, is num2 equal to num3? No, it’s not. And finally, is num1 not equal to num2? Yes, it is not equal to because
num1 is 10 and num2 is 20. So any questions to here? Alright, now I’ll show you one thing now before you go ahead, you can
all, for commenting in Python, you can either use a hash operator, or let’s say if you’re
performing a multi-line comment, then use triple quotes,
and whatever you encode, enclose in this, is considered
to be a multi-line comment. I’ll just comment all
these print statements. Let me just re-run this
so that it’s easier for you to understand. So you can see here, again, in the output, is num3 greater than num2? It is true. Is num2 equal to num3, which is false, and finally: is num1 not equal to num2? Yes, it is true. So are we clear with respect
to the comparison operators? Okay, Matthew is clear, so is John. RJ is asking me to move forward. That’s great, RJ; I hope
you’re clear with this. Please, make sure you’re
trying out this code simultaneously so that you
can have a complete learning experience, and in case if
you’re facing any troubles, I can clarify that. So moving forward, we
look at logical operators. Now, when we talk about logical operators, there are basically
three logical operators. They are: and, or, and not. So when you talk about
and, it returns the value of X if X is false. That is, if X is equal to
zero or any negative number, it considers it to be false,
and otherwise, it returns Y. So you can see here two and three. Since two is greater than zero, therefore it is returning three. But at the same time, if
you’re using an or operator, if X is false, then it
returns Y, else it returns X. So two or three gives
me two, in this case. And finally, when we have not, not basically converts the value. So, when you say not
of one, then where one is consider true, then it becomes false. So let me just show
you how these work out. So let’s say X is equal to true. Now, in case if you’re
going to use standard values of true and false, make sure
they start with capital T and capital X, because
these are reserved keywords. And Y is false. Okay, so Sam is asking me: what do I mean by reserved keywords? So Sam, basically when
I say reserved keywords, there are certain keywords
that you cannot use as part of your program,
because these are already being used by the Python system, and they have a corresponding value set. Now, true is a keyword which
has a corresponding value of one and false is a keyword
which has a corresponding value of zero. So I hope that was clear. Alright, so let’s print. Let’s say: X and Y. Similarly, let’s print: X or Y. And finally, let me print: not of X. So you can see here, when
we’re using reserved keywords, they’re getting bolded, and
you can see them differently. To identify if they’re a
reserved keyword or not, your IDE will always prompt you, but in case if you have
disabled auto-prediction, then what you can see is
after you’ve typed it, you can see whether it’s bolded or not. In case if it’s bolded, then
you just consider it to be a system reserved keyword. So let me just run this. So here you can see X
and Y is giving me false, X or Y is giving me true, and not of X is giving me false. So X, we just initiate true,
is considered to be false, and you can see since X is
true, it’s returning the value of Y here, and similarly,
since X is true here, it is returning the value of X. So are you clear with respect
to the logical operators? Okay so Raj is asking me: where
do we use logical operators? Now Raj, logical operators
play a very important role when let’s say you’re
using multiple conditions for a condition statement. So in cases where you are using an if, where you also specify
multiple conditions, then these logical
operators come in too handy. Now, don’t worry, I’ll be
showing you a case where you’ll be using multiple
conditions inside an if statement, and you’ll be using a logical
operator to connect them. So any other doubts with
respect to logical operators? Alright, so seems like everyone is clear. So let’s move forward and
look at bitwise operators. Now, when we talk about bitwise operators, these operators are similar
to your logical operators, but what is important is that
you understand how they work. So in the case of a bitwise operator, what happens is that the
value that you specify, its bit value is considered. So let’s say in case you
are performing bitwise or on seven and five. Now, what happens is that
seven is converted to its bit value, that is 111, five
is converted to its bit value, 101, and then individually
on these numbers, you will be performing bitwise operations. So here, in this case,
you’ll be performing or. Now, in case if you’re not
familiar with the logic of the or operator, what
happens is that you get the output to be one, in
case if you have at least one one as the input. So you can see, we have two ones here, so the output is one. Again, you have one and zero,
so since one output is one, then you’re getting the output as one. Again, you have one and one,
and this final output value translates to seven. But when you look at an and operator, only in case if you have one
and one to be the inputs, then do you get the output to be one. So you can see in case
of the second value, one and zero is being considered,
but the output is zero. Now, apart from that, you
have the XOR operator. Now, in the XOR operator,
the output is given as one, only in cases if you have
all number of ones as input. So you can see, if you have two ones then the output is zero. In case if you have one one and a zero, then the output is one. So the XOR of seven and five
is giving us an output of two. So, let me show you an example of this, so that’ll help you understand better. So let’s go back to our PyCharm, and let me just comment this section. So here, let’s consider two new numbers. Let’s say num4, which is
equal to six, and num5. Which is equal to two. Now, the bitwise value of six is 110, and the bitwise value of two is 010. Now, what we are going to do is we are going to perform bitwise
operations on these. So let’s say: print. So we need to perform
bitwise and operation first, so let’s say, num4. Perform and, use the ampersand operator, and num5. Similarly, let’s say: print bitwise or. Num4. For or, you’re going to be
using vertical slash, and num5. Finally, bitwise XOR. Now, we perform bitwise XOR,
use the exponential key. And num5. Let’s run it and see. So for bitwise and you’re
getting your value to be two. Again, if you see for and I
had mentioned only in case if you have two ones do you
get the value to be one. So you can see only for the
center value you have one and one, so therefore the
value for bitwise and is two. But when you look at bitwise or, the value is said to be
six, because you have zero, then zero being compared,
one and one being compared, giving me an output of one,
and one and zero being, giving me an output of one. So the value is six, and
when you see bitwise or, only in case if you have
one and zero do you get the output to be one. So only for the first position
does it get the value of one. So are you clear with
respect to bitwise operation? Okay, so Santoosh is asking
me: what is the difference between bitwise operation
and logical operators? Now, again Santoosh, it
is basically the values that you will be working on. Whereas logical operators
work with the complete value, bitwise operators work on a bit level. That is, your value is
first converted to a bit representation and then you’ll
be performing the operations. Are you clear? Okay, so apart from these
three bitwise operations, we have two more bitwise operations. The first is the left shift and the second is the right shift. Now, when we talk about
left shift and right shift, what basically happens is that
first the value is converted to a bit representation. So here, in this case,
we are taking three. And then what happens is
you’re going to specify which type of shift you want to perform. So in case if you’re going
to perform a left shift, then you’re going to be
using two smaller than signs. In case if you’re
performing a right shift, then you’re gonna be using
two greater than signs. Now, once you’ve done
that, you’re gonna specify the number of places you wish to shift. So here, it’s been specified as two. So what happens, basically, is
that first one is pushed out and the second one gets
pushed into its position. Similarly, when you
perform the second shift, the remaining one gets pushed out, and it gets converted to the value zero. But when you look at left
shift, what happens is the value of the one keeps moving towards the left. Basically, you’re moving the
values according to the shift that you’re specifying by
the number of positions that you have set. Now, I’ll give you an example here. Let’s go back to our PyCharm. Here, let me print num4, and we’re gonna perform a right shift. By two positions. Let’s say we’re gonna
perform left shift on num5, so num5, left shift, by again, two positions. So let’s just see what
values we get as the output. So if you run it, you
get the value as one, because the first, the zero gets discarded and gets replaced by one. Similarly, that one gets discarded and replaced by second one. So you have one, zero, zero. That gets translated to
one, and when we look at the left shift operator,
two goes to fourth place and then from fourth place,
it goes to eighth place. So again, you’ve shifted
to the left by two places. So are you clear with respect
to left shift and right shift? Alright, so I’ve got a confirmation
from John, Matthew, RJ. That’s great to see. Now, moving forward, let’s
look at the identity operator. Now, the identity operator
is something that is really helpful when you’re writing long codes, and you’re not sure of the
current value of that variable. So, instead of always printing
and checking out the value, what you can do is that you
can use an identity variable. Now, let’s look at the
example mentioned here. So you can see X has
been declared as five. Now, somewhere between my program, I’m not sure if X is equal to five, so what I’m gonna do is that
I’m gonna use X is equal to five and then check the
corresponding output value. So since my value of X is still five, it is printing true, and
let’s say if you are checking if it is not equal to five,
then it prints corresponding. Now, I don’t think you need
an example to understand this program, so let’s
move forward to look at the membership operator. Now, when we talk about
the membership operator, this is something that deals with lists. Now, don’t get confused if
you’ve not heard of lists. This is a datatype that
is present only in Python. We’ll be discussing about lists and tuples exclusively in our next section. But let me just give you an overview here. List, basically, is a
collection of multiple objects. So this is somewhat similar to your array in C or C++ or Java. Now, the only difference
between the array and the list is that there is no restriction
on the type of variable that you can store in a list. So here, what we’ve done is
we’ve just stored numbers, but let’s say if you
wish to store a string, then you can store that as well in a list. So using the membership operator, what we are doing is that we are checking if a certain value is present in the list. So you can see here, three is
being checked in the list X, and you can see it is
giving us a value true, because three is present in the list. Similarly, when we see
that three is not in X, then it gives us a false. Now don’t worry, I’ll give
you an example of this when we’re talking about lists. So any questions with
respect to the seven types of operators that we have seen. Are we clear with everything? Have you executed the codes
as I was mentioning it? Please, let me know if you
are facing any troubles. I’ll be able to assist you and clarify your doubts right away. Okay, so I’ve got a
confirmation from Ron, John, Santoosh, Matthew, Divya,
that’s great to see guys. I’m, I really hope you guys
are learning in this session. Now, moving forward, let’s
talk about the datatypes that are present in Python. Now, as you’ve seen, Python
is a loosely typed language, and we’ve also seen that
we do not need to define a datatype for that variable. This is something that Python
defines as per the value that you have given for that variable. Similarly, as you have seen,
you can declare a variable whenever we need them. Now, here what you are
seeing is a list of six native datatypes present in Python. We’ll be talking about
the user-defined datatypes in our next session. Now, again, when you look at
the classification of datatypes they can mainly be classified
into immutable and mutable. Now, what we mean by
immutable basically is that if a value has been
assigned to that datatype, then it cannot be changed. Now, the best example for this is a tuple. So this is something
similar to the list itself, that we have seen earlier. Now here, what happens is that
once you’ve set the values present in a tuple, you
cannot update these values. Now, this is somewhat
similar to a fixed list, where you cannot modify
the existing values. Now, don’t worry; we’ll
be talking about each of these types in detail,
so let’s begin by looking at the numeric datatype. Now, in the numeric datatype, there are mainly three classifications. Firstly, we have the integer datatype, where again, you are
storing whole numbers. Then you have the float
datatype, where you are storing decimal valued numbers, and finally, we have the complex type. Now, when you look at
normal complex numbers, the only difference in
Python is that value, right? Real number plus imaginary
number, I, in the real world. Here, in Python, you’ll
be replacing I with a G. So that’s the only difference,
but the overall use and the operations that
you’ll be performing on these will remain the same. So are you clear with
the three numeric types? Okay, so John has an
interesting question here. So John is asking me: if
Python supports double type or long integer type. Now, by default, integers are
considered to be long int, and there’s no separate double type here, because what happens is
that the maximum range of these numeric types is set
based on your system memory. So, what happens is when
you’re using a decimal value, then it takes the maximum range. So are you clear? Okay, so let’s move forward
and look at the next datatype. That is strings. Now here again, when
we talk about strings, it is basically a collection of words. So, as you’ve seen earlier,
a string can basically be defined in either single
quotes or double quotes. And in case if you wish to
use a multi-line string, then all you need to do
is that, enclose it within six parentheses. Now, when I say six
quotes, it basically means you’ll be using totally 12 quotes. Six in the beginning and six at the end. So when you do that, Python
automatically recognizes it to be a multi-line string. So, RJ has a question here:
do we need to set a value for these strings? No, RJ, now, I assume that
you mean the size of a string. Now, I’m sure you’ll have
worked on programming languages like C or Java where you need
to first specify the range of that string, so let’s
say you’re going to be using a 25 character string, then you
need to explicitly define it first, then only you can use it. But here, since we’re not
specifically declaring any datatypes as well as a
variable before we use it, Python automatically assigns that memory. So that avoids the hassle
of assigning memory for that variable, as well. So coming back to your
question, you do not need to define a size for the
string before you use it. Are we clear? Alright. So let’s move forward and
look at some of the operations that you can perform using strings. Now, these are basic sequence operations that you can perform using strings. One of the most popular
is string concatenation. Now, again, to perform
string concatenation, all you need to do is
use the plus operator. So you have string one that is Python, string two is tutorial,
and it gets combined to: Python tutorial. Similarly, let’s say if we
wish to repeat a string, then all you need to do is
use the star operator once, followed by the number of
times you wish to repeat it. So that gets repeated, the number of times that you have specified. Now, when you talk about slicing, it basically means extracting
characters from a string. So you need to specify the
start point as well as the endpoint and then the
characters will be extracted from these values and you’ll
be getting the output. Finally, we have the string indexing. Now you can always access
individual characters of a string. This is basically what
is done using indexing. Now, rather than confusing
you all with theories, let me show you these practically. Now, let’s go back to our PyCharm. I’ll begin by declaring two strings. So let’s call them string1 and string2. Now, I’ll enclose my first
string in a single quote, and then let me write string2. I’ll put it in double
quotes, let’s say: tutorial. And then let’s begin the
operations that we have just seen. Now, a string concatenation,
let’s say: print, string1 plus string2. Similarly, for repetition,
I’d mentioned you need to use the star operator. String2, star three. Let me just show you the
outputs of these two operations. So you can see, string1 has
been concatenated to string2, and string2 has been repeated three times. Again, moving forward. Let’s talk about slicing. So here, what I’m going
to do is print string2, open a square bracket, and here, let’s say the start and end point. Now, Python’s indexing system,
that is the numbering system, starts from zero instead of one. So if you say the second
character, when you say two, it basically refers to
the third character. So let’s say three-comma-six. If I print it, we can see from fourth character
to the seventh character. Okay, who can tell me the
answer for this command? Let’s say: print, string2. Can anyone guess? Okay, so I’ve got multiple answers. Let’s check who’s correct;
let me just run it. And it is: TUT. So since there’s no start point, it is considering three
to be the start point. Now, let me show you
with respect to indexing. If I say just three, what happens? Let me just run it. It is taking the fourth character. What happens if I say minus three? Any guesses? Let’s run it. It is giving me the third
from the last position. Good one, Raj. So let me show you another thing. Let’s say: two, comma, minus three. If I run this, you can see
from the third position until the third to last position. So TOR is being extracted and printed. So are you clear with how
you can perform slicing and indexing as well as string
concatenation and repetition? Okay, that’s great. Now, moving forward, let’s look at some type
specific operations. So when we talk about
type specific operations, using the string object, you
can perform certain operations. So, these are just some of the examples, you have about four
here, so let’s say one, if you have string Edureka,
then if you use string.find, basically it checks the
sub-string that you have specified and its starting location
in the original string. Now, this comes in handy when, let’s say, you are using a multi-line string, and there you’ll need to
search for a single word. After that, you have replace. So let’s say if you wish to
replace a certain character or a sub-string, if it’s
a specific sub-string, then you can specify it here. So that we had ED, we are
replacing it with just E. Similarly, if you wish to split a string, then all you need to do is
specify the character based on which you have to split. So you can see here my
original string, Edureka, is separated where each alphabet
is separated by a comma. So I’m specifying my split
operation to be split as based on the comma, and
then you’re getting a list as to the output. So remember, this is not a string. This is a list as my output. And then finally, you
have the count operation. Now, in the count operation,
what you’re basically doing is that you’re checking
the number of times a specific character is present. So in this case, I have an
original string that is Edureka, in which I’m checking my number of E’s. After that, if you wish, you
can specify the beginning position and the end position
to which you need to confirm. So I’m checking from the first position to the sixth position. Now, it will be considered to be zero, because as I’ve mentioned earlier, Python starts its indexing from zero. So, you don’t need to
specify begin equal to zero and end equal to zero. You have to specify zero-comma-six, and then it would begin the counting. I will show you these four operations. Let’s say, in string1. Now, if you wish to check all
the types of specific method, just specify your string
object, then a dot operation. So automatically, Python will
predict you all the in-built type-specific methods
available for a string. So you can use whichever to your choice. I’m just showing you a few
of them, but I definitely recommend that you explore
all of these and in case if you’re not clear with
any of these functions, do let me know; I’ll
be able to assist you. So let’s say: count. I wanna count P in my Python string. And I’m going to set the
range to: zero to five. Now, before you run it,
let’s print it directly. So you can see: zero. Can anyone tell me why
it is showing me zero, when my string is starting from P? That’s right, Divya. It’s mainly because it is case-sensitive. So at the same time, if I
put capital P and I run it, then you can see it is
finding out to be one. So, always remember this is
a case-sensitive operation. Similarly, let’s say if
you wish to find something, so let’s say: print, string1.find. Now, let’s say the sub-string
that you wish to find in this, or the other string. So I’d say: O-N, now make sure
the sub-string is in quotes, and just run it. It says it’s starting from position four. And if you check, one,
two, three, four, and five. So, the reason it is showing
four is because my indexing starts from zero; always
remember that, because this is something that most people,
at times, make a mistake. Now, coming back, let’s say you have another set of operations. Now, this basically
talks about string.upper. Basically, if you want to
convert a string to completely uppercase, then you can use the upper. Now, max and min are some
of the most interesting string operations that I
like, so anyone can guess what these operations can do;
you can see the example here. Can anyone guess it? No John, it is not the
maximum occurring letter. Yes, that’s correct Sandeep. So here, when you use max
operation on a string, what basically happens is that
it takes the complete string and sees which alphabet is higher up in the alphabetical order; so
in case of the word Edureka, U is the higher-most
word, therefore you get U. But when you look at the
minimum-most word, it is A. When you use isalpha, it
basically means you’re checking if my string has alphabet. So, apart from isalpha, there
are certain other operations, let me show you. So, apart from that,
let me just say string. And you say: is operation itself. So here, you can see isalnum,
that means alpha-numerical, is it alphabet, is it decimal, does it contain digits,
does it have an identifier, is it in lowercase, is it
numerical, and so forth. There are so many operations that you can perform using strings. So I definitely recommend
that you try them out, but at any point, if
you do have any doubts, do let me know right away,
and I’ll be able to clarify. So go ahead and try out the various types of specific methods, and let me know in case if you are facing any trials. If we just print this, I can show an output for this operation. It says it’s true, that
means it contains alphabet. Now, one advantage of
using the PyCharm IDE, and one of the key reasons that
I’d recommend that you start with PyCharm itself, is
because of its predictability. Now, again, you’re using a
new function which you’re not familiar with, let’s say: string1. So let’s say you’re going
to perform string.split. So when you type S, itself,
it starts predicting the various operators. Now, apart from that, it
also tells you the arguments that these operators require. Now, for split, it asks,
it says that it’s going to be performing on itself,
it needs to understand a separator as well as the
maximum number of splits that you wish to put it in. Now, this will make your
learning process easier, as well as it’ll make
your, clear with respect to the arguments that
these operators take. So go ahead and try some of
the type specific methods, and I’ll be here to help you, in case if you face any troubles. Alright, so now that you’ve
tried out some of the string type specific methods, let’s
move forward and look at tuple. Now, we’ve discussed earlier a
tuple is similar to a string, but it is immutable. That is, you cannot change
the values that are present inside of a tuple. Now, to define a tuple, what
you need to do is specify the name of that tuple,
then put an equal to, and then the parenthesis; so
this is a curly parenthesis, make sure you use the
right one, because each of the datatypes use a
different style of parenthesis. Where tuple uses parenthesis,
lists actually make you use those square braces,
and when you come down to dictionaries and sets, they
actually use curly braces. So make sure you use the right
braces to define your tuples, lists and dictionaries. So any doubts with respect to tuples? Okay, John wants to know
how tuples are immutable. So John, I’ll show you that in an example. Before that, just give me two minutes. Again, these are the operations that you can perform using a tuple. You can perform tuple concatenation, you can perform tuple repetition, slicing, and similarly, tuple indexing. Again, so let me just
give you an overview here. So, I’ve set the name of
my tuple to be: my_tup, equal to, (muttering) curled braces. So in this, you can
define whatever you wish. Let’s say I’m going to give
the name Neel, (muttering). So Raj is here, so I’ll give his name in. Again, Sandeep, so Sandeep. Anyone else? Oh, I’m sorry, Divya is also here. Okay, so I’ll just stick
to these four names, and I’ll show you the operations that you can perform using tuples. So, when we talk about
tuple concatenation, so you can print directly
the concatenated operator. But one thing you need
to keep in mind is that: while you’re concatenating,
you need to be sure of what you specify as the second tuple. Now, I’ll just give you an example. Let’s say you put my_tup, plus. And here you need to be
sure that you’re specifying the second tuple, or the
second character that you wish. So here, you need to be
sure what you specify is inside curved braces. So, let me enter Ron into this. But if you specify only one character, it considers it to be a string. So what you need to do is
that you need to ensure there are more than one characters. So apart from Ron, let’s
say Sanjay is also here, so I’m gonna put Sanjay’s name. And let me just run this. So you can see, Neel,
Raj, Sandeep, Divya, Ron, and Sanjay are present. But don’t misunderstand,
these have not been added to my original tuple. It is just that when I’m printing, I’m adding this tuple detail as well. Now, you don’t have to
define it here, itself. Let’s say you have another tuple, as well, then you can directly specify
that tuple name here, itself. So are you clear? Alright, now when we
talk about repetition, again, you’re going to be
using the star operator. So if you just print this, you can see Neel, Raj,
Sandeep, Divya, again, Neel, Raj, Sandeep, Divya, Neel, Raj, Sandeep, Divya. So three times all the
elements of the tuple have been repeated in the same order. Then we come to slicing,
I’m gonna, let’s see. My_tuple of minus one. Any guesses? Divya has guessed it correct. That’s good, Divya, you’ve
guessed your name right. Okay. Now, here let me put it. One to five. Any guess what happens if I run this? Can anyone tell me what happened? Why am I getting Raj, Sandeep and Divya, when I had given one to five? That’s right: it prints still the maximum. It does not reach five. So this is something important. This does not give you an error. It basically prints to the end
that it can find on the list. So always remember, in case,
if you specify a wrong range you do not get an error there. So are we clear with respect
to tuples and tuple operations? Okay, Santoosh, coming
back to your question, so we saw earlier, using
strings, there were certain type specific operations
that you can specify. Let’s see what you can
do when you use my_tuple. My_tuple. You can count the number
of elements in the string. Index, that is you wish
to extract an index value. Apart from that, there
are no other operations that you can directly perform. Now, if you wish to add
an element to a list, now a tuple basically is a
list, but if you’re adding an element to the tuple,
you’re going to be using an in-built command called: update. But in the case of a
tuple, this is not present. We will be seeing this when we’re talking more about lists, and
I’ll help you understand how you can update a list. So any questions with respect to tuples? Okay, Raj is clear, so is Divya, Santoosh. RJ, Nehar, okay, let’s move forward. Now, moving forward, let’s look at lists. Now, you’ll have heard of lists a lot, but again, as I mentioned earlier, a list, basically, is a collection
of various numbers, strings, literals and so forth. So you can look at the
example here, itself. Now, when you see a list, basically, it’s defined in square brackets. So earlier we had seen it
was using a curved braces, but here you are using the square braces. Be sure if you are using a list,
then you use square braces, in case if you use curly braces,
it’ll be considered to be a tuple, and you’ll not
be able to modify it. Okay, let’s look at some of
the operations that we perform using lists; so the same,
similarly, you have concatenation, you have repetition, you have slicing, and then you have indexing. Now, you’ve seen the same for tuples, so I’m not going to repeat this as such, but let’s look at the
type specific operations. Now here you have append operation. Now, using the append operator,
I have a list that has one, A, and 2.5; now once I call list.append, and I specify the value
that I wish to add, then what happens is that
value gets added to my list. But let’s say if you wish to
extend your list to multiple variables, then you can
use the extend operator, inside which you’ll be
specifying another list, and these would be added
to my original list. So where I had one, A, and 2.5, once I use list.extend,
where I’m specifying C and D, then it gets updated to
one, A, 2.5, C and D. Now similar to the append and
extend is the insert operator. But using the insert operator,
there’s something specific that you can do, that is you
can specify a certain position in your list where you
wish to add an element. So here what I have done
is I’ve specified two, and then B, so basically
what it means is that I need to add B, third place from
the start of the list. So, again, when I say two,
our indexing starts from zero, so this basically means B
would come between A and 2.5. So you can see the output: one, A, B, 2.5. Finally, is the pop operation. And the pop basically is
removing one by one element from the list, so this actually
follows a top-down approach. Now, the last value that
was inserted into the list, so here you have C to be the last value. That would be removed from that list. So let me just show you
some of these examples. So let’s say I have my list. So again, don’t forget, the define a list, you’re going to be using a square bracket. And here, let’s set certain values. (muttering) colors, so I’ll go with green, and you have red, now make
sure these are in quotes, because these are strings. Then there’s blue. Yellow. Well, Divya wants pink,
but okay, I’ll put in pink. So let’s see some of the
list-specific operations. My_list. We have pop, we have append. So let’s begin by append. So, to my existing list, I wanna add gray. And I’ll print it. Let’s just run this. And you can see, gray has
also been appended to my list. Similarly, let me show
you the extend operator, how it works. So here, make sure you’re
specifying whatever value you want in square braces. So I’ll add in white and black, so white. And if I print the list again. So, now we’ve extended
our list, lets run this. Right-click, click on run. As we can see, the two new
values have been added. So these values can, you
can either specify them, or let’s say if you have
another list, then again, you can use it. So Raj, coming back to
your question on how tuples were immutable and lists are
mutable, I hope you’ve gotten your answer; you can see the
values present in my list have been getting updated as I’ve wanted. But in my tuple, I did
not have this choice. So, are you clear, Raj? Has this helped you out? Okay, that’s great to hear. So now that we’ve seen
lists, lets move forward and look at the next datatype;
that is dictionaries. Now, when we talk about
dictionary, it is one of the most flexible built-in datatypes in Python. Now, dictionary basically stores your data in a key value fashion. So, where you have a key
and corresponding value. Now, when you look at the example here, you have myDict is equal to one, and the value for one key is Josh. Similarly, for two you have
Bob, and three, you have James. Now, don’t get confused
that this is the only way that you can use a dictionary. Now, there are mainly four
examples of dictionaries that you can see here. Now, first, you can either
have an empty dictionary, where you can add values
later, as you wish, then you have the integer key dictionary. So this is an example
that we had just seen, where you have integers to be keys, and their corresponding value. But this is not the only way
that you can have a dictionary. You can even have a mixed
key where you have a string to be a key value, as well
as you can have an integer to your key value. Similarly, in my value position, I can even have a list as well. Let’s say you already have
a sequence present here, and you wish to add your dictionary, then you can do that, as well. So are you clear with the types of dictionary that we can have? So John has a good question here. John is asking me: what happens
when I have the same key repeated in my dictionary? So John, basically, I think
you were trying to say if you have duplicate keys
present in your dictionary? Yeah, alright, so in that case, John, basically your dictionary
does not accept multiple keys, but even if there are multiple key value combinations present,
that is you have duplicate keys present in your dictionary, then the latest value for
the key would be considered and all the values before
that would be discarded. But again, you may get an
error depending on the version of Python that you’re using. I’ll just show you that; don’t worry. So. Equal to, now, here as I mentioned, dictionary comes in curly braces. So we have key value
combinations, one key, my value is going to be: green. Two key is giving me blue. It’s giving me blue. And then we have three key,
which is corresponding to red. And then what I’ll do is I’ll
put in two key with my color value to be gray. So you can see already
that there’s an error that is showing here. Dictionary contains duplicate key. But let me see what
happens when I print it. So let’s say: print my_dicto, and if I run it, I have one green, two to be
gray, and three to be red. So you can see what is happening here. Two, initially, I had defined to be blue, then when I had repeatedly
defined it to be gray, it has taken the newer value. So does this answer your question, John? I hope this example was clear to you. Alright, that’s great to hear. Now, coming back with dictionary, we have certain methods
that we can perform. Now, with dictionary, there
are certain operations that you can perform, so let’s
say if you wish to identify a value for a specific key,
then all you need to do is that you need to specify
the value as an index to that dictionary. So, here I have printed my dictionary. So if I say: three. And if I re-run this, then I get red. So what it basically means is
that for the key value three, my corresponding value is red. Okay, apart from that you
have operators like length, now using length you can
get the number of key value combinations that are
present in your dictionary, and then let’s say if you wish
to extract all the key values then you can extract it
using mydictionary.key. So this will print the
complete list of keys present in your dictionary. So in this case, I have only one and two, so one and two is being printed. Now, again, let’s say if we
wish to identify all the values present in that dictionary, you
can use the values function. Now, apart from that, let’s
say if you wish to have a complete combination,
that is the key value and you wish to have
the corresponding value present to it as well. Then you can use the items option. Now, when you use the items option, it completely prints
the key value directly, and it makes it easier
for you to identify it. Okay, Sandeep has a question here. Sandeep is asking me if
I can have multiple keys with the same value. Now, Sandeep, you can definitely
have multiple key values, which have the same value. Was that clear, Sandeep? Okay, now let’s say if you
wish to extract a value for a key, then again, you
can use the get function, which will give you the value for the key that you have specified, and
if you wish to update any value to your dictionary, then you
can use the update command. Now, I’ll show you how it works out. So let’s go back to PyCharm. So we’ve seen how we can print
the keys in the dictionary. Let me show you how we
can print the values. Let’s say: print. My dictionary object.values. Run it. Then you can see the values
present in that dictionary. Now, let me show you how
to update your dictionary. Let’s say: my dictionary.uptate. So here, make sure you’re
using curly braces, and then set your key value combination. So I’m gonna specify four and
then the corresponding value. So, let’s say: white. And then let me reprint my dictionary. So you can see here the key four, as well as the value white, has
been added to my dictionary. So any questions with
respect to dictionary. Okay, so Divya wants me
to give her an example where we’ll be using a dictionary. Now, Divya, the dictionary
literally translates, the same natural dictionary
that you’re using, like where for every
word you have a meaning. But let’s say you’re
writing a huge program. This program is not going to
be seen only by you as well, so there’ll be multiple
programmers working on this. So here, let’s say you’re
going to be using variables. (muttering) Now, using a dictionary, what
you can do is that you can set the variable name as the key, and then in the value section, you can give an explanation
as to why this variable is being used, or where it is being used, or what is its purpose. So this, in turn, will help
the developers to understand the use of that variable. So was that helpful, Divya? Alright. So any other questions
with respect to dictionary, or can I move forward? Great. Now, after dictionary, we have sets. Now, a set is basically
an unordered collection, but the thing here that
makes set a separate datatype is that you cannot have duplicate
elements present in a set. That is, a set can have
only unique elements, okay? So, I have a question here from John. John is asking me: what
happens if I specify duplicate elements in a set? Okay, John, let me show you this directly with an example, itself. Let’s go to set. Let’s say: my_set. Again, set is defined inside curly braces. So here, I’ll just give numerical values. So let’s have one, two, five, seven, let me put another five, 10, eight, two, one. Now, what I’m gonna do is
I’m gonna print the set. If you run it, you can
see the output yourself. So, I have one, two, five, seven, eight and 10. The repeated values are not
considered to be part of my set. Is this clear now, John? Alright, now moving
forward, let’s look at some of the operations that you
can perform using sets. Now, there are mainly three operations that you can perform using a set. Similar to the mathematical
set that we’ve all seen, you have the union operation. You have the intersection operation, and then you have the
difference operation. Now, similar to the
normal union operation, let’s say you have two sets. You have set one and set
two, and you perform union. All the elements from both
these sets are combined, but these are only unique elements. So you have one, two, C and B. Where, originally between both
sets, you had six elements, after the union, you have four elements. Now, when you look at intersection, basically what you see is
the elements that are common in the first set, in
comparison to the second set. Are there common elements
present between the sets? And that is your solution
to your intersection. Again, when you look at
difference, what you’re seeing, basically, are the
elements that are present in your first set, but
not in your second set. So, when you say MS1 minus MS2, you can see two is present in set one, but not represented in set two. If you’d have done the inverse,
that was MS2 minus MS1, then can anyone tell me what
the value would have been? That’s right, Rahul, the
answer would have been B. So, I’ll just show you these outputs. So, one thing you guys
will have just noticed is that you cannot use
spaces while you’re naming any variables in Python. So, it is always recommended
that you use an underscore if you wish to separate the
characters, but you cannot use space when you’re naming
a character in Python. So let me put in two, five, nine, and then 15 and 20. Now, we wanna put in the union. So for union operation, this set one, and a vertical slash. For my_set_2, similarly,
I’ll do it for intersection. So, for the intersection, again, who can tell me what the operator was? Yes, Rahul, that was and. It’s good to see that
you’re involved in this. And finally, for the difference. Okay, Divya had this minus. Let’s run this; you can see the union has all the unique elements,
as well as all the elements present between both the sets,
intersection checks which elements are common between
the first and the second, and you get the output there. And difference gives us the
elements that are present in the first set, but
not in the second set. So, are we clear with respect
to sets and how they function? Any questions with respect to sets? Okay, so I’ve got a
confirmation from Raj, Santoosh, RJ, Divya, Shweta, Nehar, that’s great. That’s great to see all
of you are interested, and will have caught up. So, it’s great to see that
all of you have caught up. Now, again, if you are facing
any troubles while executing these commands or if
you’re not clear with any of these concepts, do let me know. We can clarify it then and there, itself. If you are facing any errors, let me know. I can help you clarify that. Now, moving forward, let’s look
at flow control statements. Now, when we talk about
flow control statements, there are majorly seven
statements through which you can change the flow of a program. Now, if else, and if elif else. Now, these are actually
related conditional statements, where if basically checks
with only one condition, else tells you if that condition
is not true, what to do, and elif can be used in
case of multiple conditions. And then when you look at for and while, these statements are
mainly used when you wish to perform loop operations. Now, I have a good set of programs that you’ll be working when we’re talking about looping statements;
stay tuned, don’t worry. And when we talk about break
and continue, these basically define how the flow of
the program should go. Now, don’t worry, we’ll be going
in-depth with each of them, one by one, so let’s start
with the if statement. Now, when we talk about the if statement, so as I’ve mentioned to
you earlier, you basically check if a condition is true. Now, in case if my condition is true, it executes a set of
programs that are branched inside this statement. So here, in the syntax,
you see if, then you have the condition, and then
you have the statements to be executed in case
the condition is true. But in case if my condition is not true, then what happens is the control
goes to the else statement. Here there is no checking of condition, so work through a statement
that you have specified inside else will execute, if
the condition of if is false. That is, if it doesn’t
go to execute block one, then it goes and executes block two. So are you clear with respect to if? Okay, so, Divya is asking
me: what do I do in case I have five different conditions? Good question, Divya. Now, in that case, what
happens is we’ll be using the next control statement that is the if, elif, and else statement. So here what happens is first
you’re going to be checking the if condition. Now, if it is not true, then let’s say you have
other conditions to check. So those will be defined as
inside the elif statement. So you will have one if, and
then you’ll have multiple elif conditions; so each one
will be checked individually. Whichever would be found
true, you’d go inside that condition and execute
that statement there. In case none of these conditions are true, then you’ll reach through the else part and execute the final
statement present here. So are you clear now, Divya? Okay, so what I will do
is I’ll write a program in which I’ll use if and else so that way it will be easier for you to understand. So, let’s take one of the
most popular examples here. Let’s say we’ll consider marks. So my marks is equal to 75. I’ve got 75 marks in one subject. Now, if, then you’ll open a condition, my marks is greater than 80
percent, that is 80, there. So to enter into the condition,
make sure you specify a colon, and then press enter. Always make sure you’re
following the correct indentation, as this is
something that’ll really help you out while you’re debugging your code. So if I’ve got 80 percent, then print: Grade A. That is, if you’ve scored
above 80 percent, then, print Grade A. Elif. Again, you need to specify your condition. That is, marks are
greater than 60 percent, and I also have another condition here. If my marks are less than or equal to 80. So basically what you’re doing is that you’re checking if my marks
lies between 61 to 80. So, in that case, put a colon here and let’s enter the elif condition. So here, let’s print Grade B, print. Let’s put another elif. Marks, greater than 40 percent. And, marks less than equal to 60. Then I’m gonna give them Grade C. So, if it is, if my marks
are less than or equal to 60, then what I’m gonna do is
I’m gonna give them Grade C, so print. And finally, I’m going to
define the else condition. That is: if he gets below 40, then I’m going to give him: Grade D. So are we clear with respect
to the flow of this program? So, I already defined my marks to be 75, so first we’ll check if
marks is greater then 80. If it is, it’ll go into this
statement and print Grade A. Else, it’ll go into the elif part, again, check if my marks is greater than 60, but less than or equal to 80. So here you’re using a logical operator, so only in case if both of
these conditions are true, will it go inside the statement. Similarly, if it is less than 60, then it’ll come back
to the next statement. We’ll check if it’s greater than 40, and it is between 41 and 60, and then it’ll print
Grade C if it is true, and finally, if it is below 40, the it’ll print Grade D. Let me just run this. And you can see, we are getting: Grade B. So, any questions with how if-else and if, elif, and else works? Okay, so Divya is clear,
so is John, RJ, Matthew. Jessica, that’s great to see. Now, let’s move on to look
at looping statements. Now, basically, you’re gonna
be using looping statements when we have to repeatedly
do certain actions. That is, a certain set
of instructions or codes have to be executed
multiple number of times. Now, based on the number of
times that you wish to execute this code, you can use two of
the types of loop conditions that we have; now the
first is the while loop, and the second is the for loop. Now, the main difference
between when to use while loop and when to use for loop,
is that you need to be aware of the number of (muttering). That is, if you know
how many times the loop has to run, then you’ll
be using a for loop. Or let’s say you are not
aware of the number of times that the loop has to execute. Then you’ll be using a while loop. So any questions with respect to these two loop statements, and what a loop statement is? Okay, so John is clear, Jessica is clear. So is Tyler. RJ, Santoosh, that’s great. So now let’s look at while statements. Now, basically the while statement just takes a single condition. If it is found to be true,
then it moves on to execute the statements that are defined inside it. So if you see here what
happens first is that it checks the condition, and if
it is found to be true, then it goes on to execute the block. And again, it goes back to the while loop, the start of the while loop, the condition is again checked. If it is found to be
true, it keeps entering, and the code gets executed
until the condition is to be found false. Once it’s found to be false,
then you exit the loop and execute the statements
that are after it. So I’ll be giving you a
situation where you’ll be using while statements. That will help you understand how the while statement works better. So let’s go back to our PyCharm. Now, before we go forward,
what we’ll be doing is we’ll be finding the sum of N numbers. Now, this N value, that you’ll
be accepting from the user. So here, I’ll also help you
understand how you can take an input from the user. So what I’m going to do is
that I’m going to store it in a num variable. Num is equal to input of… Now, here let’s say if you
wish to print any statement then you can put it in quotes. Enter the value of N. But one thing you need to remember here is that when you’re taking
an input from the user, it is considered to be a string. So we need an integer
value to be taken as input, so we’re gonna convert the type. So we need to say: int of input. Then here what you’re doing
is that the input taken from the user is considered
to be an integer value. Now, are you clear with
what we’re doing here? Okay, so Tyler is clear, so
is John, Matthew, that’s good. Again, please remember when
you’re taking an input value from the user, it is
considered to be a string. So if you need an integer value, then you need to convert it to int. So let’s say, the first
thing that you’ll be doing is that you’ll be checking
if the number is greater than or equal to zero. Now, this is important
because to proceed forward, it makes no sense to
compute the sum if the value is lesser than or equal to zero. So let’s say: if my number is
lesser than or equal to zero. Then I’m gonna print: enter a valid value. Then come to the else part. Here let’s begin by first
initializing sum is equal to zero. Now, my sum is the variable
in which I’ll be storing the overall sum. Now, after that, let’s
use a while statement. Now, while. Now, I note the value of my
N, and I know it is going to be counted down to zero,
so what I’m going to do is I’m going to write:
num greater than zero. So here, what you’re
basically gonna do is that we’re gonna add the value of
the number that you have taken as input and then keep
decrementing this value until zero. And then getting the overall sum. So are you clear with the logic? Alright. So again, put a colon. Sum plus sum plus equal to, my number. So I need to decrement my
value of number by one. So minus, equal to one. Now, this will execute until the value of number is greater than zero. Now, once you’ve completed with that, let’s just print the value of sum. Now let me just execute the statement. So it’s asking you for the
value of N, so I’ll say 15. And you can see the value to be 120. So any questions with respect to how the while loop executes? Okay, so Santoosh is clear, John, Matthew, RJ, Tyler, that’s great to see. So again, you can try out
these programs simultaneously. In case if you’re facing
any troubles, let me know. I’ll be able to assist you. Okay, so now that we have
understood while statement, let’s look at the for statement. Now, the for statement is
something that you will be using when you know
the number of iterations that has to occur. So the syntax for for basically is, you’re going to write the for keyword, then you’re going to
specify the iterator name. This can be the name of any variable, or any iterator that you wish to set, and then you’re going
to be using a sequence. Now, the sequence can either
be a range of numbers, it can be a list, it can even be a tuple. So, based on the data in
the tuple or the list, you can execute this for,
until the number of elements present in that range. So are you clear with this? Now, one thing to be kept in mind here is that you do not need
to increment the value of incremental; it automatically
gets incremented by one every time the statements get executed. Okay, now coming to the
execution of for statement. So, before I go ahead, how
many of you are familiar with the beer song, that
is the 99 beers song? Okay, that’s a good number. So for those of you who are
not familiar with the 99 beers song, this basically is a
sequence of strings that are, let’s say, the lyrics of
the 99 song, let me show you how it looks like: so this
is the sequence of strings that you’ll be printing in the 99 song. So you start off with 99
bottles of beer on the wall. Then you have 99 bottles of beer. Take one down and pass it around, you have 98 bottles of beer on the wall. Then, again, you start from 98
bottles of beer on the wall, 99 bottles of beer. Take one down and pass it around, you have 97 bottles of beer. So here, what you’re basically doing is that you’re executing a set of statements, multiple number of times,
but the value present in them keeps changing. So, I’ll just show you how
you can write this using, so this actually goes from
99 and goes all the way down until you have zero bottles left. So you can see, finally,
when you’ve reached the end, no more bottles of beer on the wall, no more bottles of beer. Go to the store, go buy some more, 99 bottles of beer on the wall. Now, I’ll just show you how to
write the score in 15 lines. Yes, it’s going to be only
15 lines long; don’t worry. Okay, now, we’ll start
off with a for loop, itself, directly, so for, I’m gonna use a variable called: quantity. So let’s take Q-U-A-N-T. Quantity in. Now, I wish to execute it 99 times. So what I’m going to use is
another function that is range. Here, I’m gonna start from 99, and it has to go down to zero. And finally, it has to
increment by minus one. Now, this basically means
my starting position is 99 and my end position is zero. Now, to reach here, you’re
going to specify a common increment value that is minus one. So are you clear with
respect to this command? For, quant in range
99, zero and minus one. Alright. Okay. So Tyler wants me to explain range again. So Tyler, range basically,
when you use range, it specifically refers to
a range of numerical values that you want; so let’s say if
you wish to iterate the loop 10 times, okay, then what
you’re going to do is that you’re going to
specify the value of range just to be 10. So here, where I want this,
I want my quantity numbers to start from 99, and then
it has to reach to zero, but it has to keep
decrementing by minus one. So what I will do, I wanna
specify my start point, I wanna specify my endpoint,
and my increment value. So are you clear now? Alright. Yes, quant is the name of the variable that I’m gonna be using. Okay, so let’s say, so first
thing that I’m gonna check is if my value of quant
is greater than one. So, if it is greater than
one, then I’m gonna print the value of quant,
comma, then I’m gonna say: bottles of beer on the wall. Again, then you have quant. Now, this sentence is basically
similar to this statement. So if you can take any statement, you have the corresponding current value, bottles of beer on the wall,
then again, the current value and the bottles of beer
statement repeated again. So, this is what we’re
achieving by printing this. Now, this is only in case if
my quant is greater than one. So let’s say, so again, let
me check if my quant value is greater than two. Then, I’m gonna use a new
variable named a suffix. Which is basically a
string in which I’ll store my next statement. It’s equal to: str of quant. So here what you’re doing
is that you’re converting the quant variable into a string value, and then with that, you’re concatenating. So are you clear what you are doing here? We’re first converting the
value of quant to string, and then concatenating this
value to the corresponding statement that is bottles
of beer on the wall. So you can see that is the next one. So this is a statement. Now, if this is not true, then else, my suffix, equal to one bottle. Now, with this, we’ve defined
the general conditions that have to be executed if
my value of quant is greater than one, so in case if my
quant is greater than one. So we returned the conditions
that need to be executed, if my quant is greater than one, but let’s say elif my quant
is equal to, equal to one, then print… And print: one bottle of beer. Finally, since I have only one bottle, so I have to update my suffix as well, so suffix becomes… Take one down, and pass it around, and after this, we’re
gonna put in the suffix that we have just computed. Okay, now this may seem
a bit complicated to you, but trust me, it’s very
simple once you execute it. You’ll understand how it works. To differentiate each
statement, I’m gonna put: print. So let me explain the statement again. So first, you’re gonna
compute your for loop from a specific range from 99 to zero, if the value of your
quant is greater than one, then you’re gonna print the value of quant followed by the statement,
and if your value of quant is greater than zero,
then you’re specifying the suffix value to be this statement. Now, in case if it’s equal to
one, then you’re gonna print: one bottle of beer on the
wall, one bottle of beer, and no more beer on the wall. So, let me just execute this
and show you how it runs. So here you can see how the
for loop starts from 99, and then it goes on all
the way until you have one bottle on the wall, take
it down and pass it around, no more beer. So are we clear with
how the for loop works? We’ve known that we have
to execute these set of statements 99 times,
so what we’ve done, we’ve put it in a for loop, and then we’ve gone ahead and executed it. Okay, so Matthew is
clear, John, Tyler, Divya. That’s great. So now coming back, when we
talk about the break statement, now, the break statement
is something that mainly helps you in coming out of a loop, in case you have met a certain condition. Now, let’s say you’re dividing
a number inside a loop. So here, what happens is you
can put a statement that, if that number is equal to zero, then you need to come out of that loop. Because dividing beyond
that actually gives you an invalid answer, so if your
number that you’re dividing is equal to zero, then you
can come out of that loop. So what happens is once
this condition is met, then when you’ve specified the
break condition inside that, it leaves the loop and comes out of it. So are you clear on how
you use a break statement? So for helping you understand
how the break statement works, let me begin by using a variable count. Which I’m going to assign as zero. Then we’ll use a while loop. Now, the while loop is set to run an infinite number of times. Because when you say Y is equal to true, it will run until you
specify a break condition to come out of it. Now, what I’m going to do is
I’m going to print my count. And then keep incrementing it. So count, plus, equal to one. So, the value of count is
going to be incremented by one, every time. Then what I’ll do is I’ll
write an if condition. If my count becomes greater than 10, then execute a break. Let us run this. So you can see a loop
that was supposed to run an infinite number of times has
been restricted to 11 times. Starting from zero, it
goes all the way to 10. The moment the value of
count increases to 11, you break out from this loop. So are you clear with respect
to how break helps you, coming out of the loop? Okay, now similar to the break statement, we have the continue statement. Now, what continue statement does is that it ensures that if the
condition has been met, then the statements that
follow the continue keyword does not get executed. So let’s say you have a
certain set of statements that are written after continue. If the continue gets executed,
then these statements do not get executed, and then you go on to the next iteration. Now, to give you a better
understanding of this, I’ll give you an example of it directly. What I’m gonna do is
that, let’s say for X, in the range of 20. So here, Tyler, what you’re doing, coming back to your previous question, is that X is my variable, and range means I’m going to execute this loop 20 times. So what I wanna do is
that I’m gonna print all the odd numbers present in this range. So, if my X mod two equals zero, then put a colon, and then continue it. Now, if it is not, that is, then what you’re going to
do is you’re going to print the value of X; and just run this. So, I just run this code. So you can see here, all
the odd numbers from one to 20 have been printed here. So any value where divided
by two gives me a value of zero has been removed from this. So any questions with respect to how continue statement works? It is just that if this condition is true, then you do not execute
the print statement, and you go to the next
iteration of that flow. Are we clear with respect to how the continue statement works? Okay, so John is clear, so
is Santoosh, Sawati, Nehar. Divya, that’s great. So, with this we’ve come to an end of the flow control statements. So any questions with respect to any of the flow control statements? That is the if, elif, else,
looping statements like for, while, continue and the break statements. Alright. So, after this, we have the functions. Now, when we talk about functions, there are mainly two types. There’s the user-defined function
and the built-in function. So, we’ve actually seen some
of the built-in functions earlier when we were using
the type based functions. So, the type based method
were some of the built-in functions that we have seen. Apart from that, we can also define our user-defined function. But again, coming back
to the basic definition of what a function is, it
is basically an organized set of rules or instructions
that you wish to perform multiple number of times. So every time that you
wish to perform this set of instructions, all you need to do is that you need to call them. So this is one of the
main components of one of the major methodology styles, that is the procedural style. So in case of a procedural
style, you will be following the key uses of functions. Okay, so let’s come to the
definition of functions. So here, basically, you have
a function which helps you in adding two numbers. So before you begin any function, you start off with the keyword: def. After that, you will
be specifying the name of that function, as well as the arguments that this function takes. Once you set that, put
a colon and then specify the operations that you wish
to perform in this function. So here, what I’m doing is
that I’m computing the result of the two arguments
that I’ve taken as input, and then I’m returning
it to my function column. So again, I’ve read my number
one to be one, number two to be two, and then I’m
calling the add function here. So this is basically the
reference to that function, and this is a return to that function. So whatever value would be computed here, would be returned to the function called, and it will get printed here. So, any questions with respect
to the function definition or what a function is? Okay, Rajul is clear, so
is Tyler, John, Matthew. That’s great. Now, moving ahead, functions
use pass by reference methodology; again, when
you say pass by reference, you’re going to follow the
call by object reference. Now, to help you understand this concept, let’s look at the image here. So, what I have here is I have a function that modifies my list
that is passed as input. So, let’s look at the original list. So we have a hero list
where you have hero’s name as well as its villain’s name, and then you’re calling
the function from here. So, what happens is the
values present in this list is gonna be stored in the input.list, and when you’re upgrading this value, it does not affect this list. And you can see that clearly when you’re executing this list. So when you’re trying to print the list for the first time, you
can see the original value has been set as same, even
though you are calling the function to modify this value. So what happens here is that the reference to both these lists are pointing
to two different objects. It is not the same object
that gets modified here. So are you clear with this? It’s important that you understand this, because this is basically
how functions work in Python. Alright, now, to help you
understand how a function works, let me write a function here. Now, what we’re gonna do
is that we’re gonna define a function which will help us
compute a Fibonacci series. So, start with def, which
means you’re going to define a function, then the function name, and then the argument that
the function will take. So let’s say N, and then a
colon to help it understand you’re starting your function. I have A is equal to
zero and B equal to one. This is basically the start
of my Fibonacci series. Then, for my X in range
of N, basically I’m going to increment the for
loop N number of times. What you’re going to do is that, A is gonna be equal to B, and B is gonna be equal to A plus B. Here, there’s this print A. I’ll put in a new line character, as well. And finally, what I’m gonna do is I’m gonna return the final value. Now, all I need to do
is that I need to take the input from the user
and then call the function. Now, let’s say num equal to, again, int, as I’ve discussed, we need to typecast it. Input. Enter the value of N. And then we call the Fibonacci series. So, print, fibo of number. Let’s execute this. So, let’s say I wish to compute the first 50 Fibonacci series, so you have the value for the first 50 Fibonacci series. I’ll re-run it; let me
execute for the first 5,000. So again, you can see Python
has calculated the first 5,000 numbers of the Fibonacci series. So, are you clear with respect
to how to write a function and how a function works? So you have the function
name, you start with the def function, then if you
wish to return a value, you’ll be using return,
and then make sure you’re using a correct function call. So, please let me know in
case if you have any queries in respect to the function,
because this is an essential component of our Python
programming concepts. Alright, so Tyler is clear. So is John, RJ, Matthew,
that’s great to hear. Now that we’ve finished
understanding functions, let’s go into file handling in Python. Now, using Python, you can
mainly perform all the file operations that you wish. Now, there are mainly four
stages of file handling in Python; you begin by opening the file, then if you wish to perform
a read, you perform a read, then there’s a write, then
finally, once you’ve completed your operation on the file,
then you need to close the file. Now, it’s important
that you close the file because every time that you open a file, there’s a log mechanism set too. So in case if you forget to
mention closing the file, then what happens is once
you’ve completely executed that program, it becomes hard
for any of the applications to open that file. So always, if you are opening a file, make sure you close the file. Now, this is an example of
file handling happening. So, what you’re going to
be doing is you’re going to be using a file object. This is basically a reference
to the file that is present. Then once you’ve specified
the open command, you need to specify the
location of that file. Now, there are 12 different
modes in which you can open a file, and I will discuss
them individually, in detail, in our file handling classes, but let me just give
you an overview of this. You have a read, you have a write, you have a read plus where
you can both read and write, you have a write plus where
you can both read and write, then you have the open mode and so forth. So if you wish to perform a file read, then you always need to specify
file_object.read functions. This, again, is a type specific operation. So using this, what happens
is that you’re going to be reading the contents that
are present inside the file. And if you wish to write into the file, you’re going to be using object.write, and then you’re going
to specify the string, or you’re going to specify
the multi-line string that you wish to write into that file. So I’ll just show you how it’s done. Let’s say I have a file pointer, FP, equal to, open. So here, let me specify the path. So I’m going to say: D. So then let me specify
the path of that file. Now, I do not have a
file present at current, so what I’m gonna do is
that I’m gonna create a new file in the directory D/Edureka, and with the name: Python.txt. So D/Edureka, /Python.txt. Then the mode in which
I’m gonna open the file. Now, since this file does not exist, what I’m gonna do is
that I’m gonna open it in the write plus mode, where
I can read it and write it. And since the file is not present, what will happen is a new file
will be created in this mode. So, open the quote, W plus, then I wanna write certain
lines into the file. So let’s say: FP.write. And the string that I
wish to add into that. So let’s say: Python is fun. Now, before I read the contents
in the file, what I need to do is that I need to move
the file point to seeker. So, the seeker is basically
a point in your file where you’re currently located in. So if you’ve written 10
lines, then your seeker would be present in the 10th line. So what we need to do is
that we need to set it to the zero position, that is the first line, and then start reading from there. So that way we can read the complete file. So to do that, just use FP.seek, and then the position. Then, let me print the
contents of the file. FP.read. And finally, as I’ve
mentioned, always make sure you close the file; so FP.close. So let me just run this. So you can see, Python is fun
has been printed into my file. So let me show you the file. So if you go inside my D
drive, you have Edureka folder, and you have Python.text. So here, Python is fun has been printed. Now let’s say I want to
add another line, say, FP.write. Here let’s say: this was a great day. So can anyone tell me, if
these lines will be either added to the existing
line, or will it overwrite the existing content? Okay, so I have both
answers from most people. So let’s just run this. So Python is fun, this was a great day. If you open the file, you can
see it has overwritten it. So in the W plus mode, if
there’s any content present in that file, you’re
gonna be overwriting this. Now, don’t worry, we’ll be
talking about the file management in detail in an upcoming session. Now, to summarize what
we’ve learned today, we started off with an
introduction to Python, then we moved on to
understand who uses Python, as well as the features of Python. Then I helped you out with
the Python installation. And then we saw the
various Python operators. Then moving ahead we saw
the seven different types of data that are present in Python, and then we saw how you
can control the flow of a program in Python, as
well as we wrote a user defined function and we managed the file. So any questions with
respect to today’s session that I can help you clarify? Okay, so with that, we come to
a conclusion of the session. In case if you do have
any queries or feedbacks, do let me know and I hope
you have a great day. Thank you. I hope you
enjoyed listening to this video. Please be kind enough to like it, and you can comment any of
your doubts and queries, and we will reply to them at the earliest. Do look out for more
videos in our playlist, and subscribe to our Edureka
channel to learn more. Happy learning!

100 thoughts on “Python Tutorial for Beginners | Python Programming Language Tutorial | Python Training | Edureka”

  1. Got a question on the topic? Please share it in the comment section below and our experts will answer it for you. For Edureka Python Course curriculum, Visit our Website: http://bit.ly/2FBUtO7 Use code "YOUTUBE20" to get Flat 20% off on this training.

  2. sir the video is very good,even being from a non IT branch i learned a lot.Sir i am in a fix that there are 72 videos in total and of AI and ML also,it would be greatfull if you can tell me what videos to download further to have a good knowledge in python as i m a beginner.

  3. Anirudh reddy Basani

    WooW…you just almost told all the basics of python within a span of watching a movie..and that was amazing and so informative…keep up the good job and make sure you upload these kind of videos on other concepts too..

  4. msg=input('Please enter a sentence….n')
    print(reversed(msg))
    .
    .
    .
    .
    .
    Why the print(reversed(msg)) doesn't give me the reversed string?

  5. Neeraj Sir I am extremely thankful to you for such a great learning experience throughout the video. Sir, if you can tell me where would I get the next video in this series.

  6. sir this whole course is suitable for learning python from beginnners to end and i have no knowledge about machine learning till yet then its creating a problem for me two learning a python or not plss give me answer as soon as possible.

  7. which is the compatible version of python for windows XP. python 3.6 or 3.7 can not be installed in this windows version.

  8. M a little confused about the code that you have given for Fibonacci series. From the code that you have given, the output sequence was 1,2, 4,8,… But as per my knowledge, the fibonacci series is of the sequence 0,1,1,3,5,8,…Am i goin wrong somewhere?

  9. Thank you so much! I had been pushing off learning this language for a while. I really liked how the intro covered who uses it, what it's for, and what apps you need to run it. Super helpful.

  10. Thanks Neeraj. Wonderful session. You clearly explained with Examples.. that's the best part..thank you very much sir i really learned a lot and all because of you sir Best wishes

  11. Is python a programming language or scripting language ?
    If it is both what is difference between them and their applications?

  12. I am very thankful for this python training course available on youTube , and your teaching style is amazing neel sir , THANKU !

  13. Dear Edureka,

    This was my first Python tutorial, thank a lot for explaining to a beginner with such an ease.
    I Thank you for that.

    One program in the end around 1:39:00 , the Fibonacci sequence, allow me to produce the correct program for it.

    ############
    def fibo(n):
    a=0
    b=1
    for x in range(n):
    print(a)
    c=a+b
    a=b
    b=c
    return a
    num=int(input("Enter the value of n:"))
    print(fibo(num))

    ############

    i thank you again to provide it for the General public.

    Best Regards,

    Joy

  14. dear sir you are explaining in a very good manner and especially the video presentation was very good (the step by step process) I understand in a better way…I really thank you and your team members for giving this platform to study python…thank you so much sir

  15. Hi, Really nice tutorial. I got to learn so many things over here. However I think the program logic for writing fibonacci series is wrong. Can you please check it once. Thanks

  16. Hi team basically am a ece background so am not from programming background so am planning to join for Python soo is it good ahead and is it difficult to Python n get a job a fresher ???

  17. An excellent video of python which we can learn all basics. and thanks edureka! for helping me in passing of my semester exam and u have uploaded any other programming videos .

  18. Thanks edureka!. Wonderful session. You clearly explained with Examples.. that's the best part. and u helped me of passing my semester . their any other programming videos which u have uploaded.

  19. ajaysaichandu srirangam

    Sooo, I didn't understand the assignment operater part, where
    Num3=num2+num1 okk it's clear
    Then What is the meaning of this
    #Num3=num3+num2
    Please explain me I didn't understand

  20. Neil, you are definitely one of the best lectures i have listened to period, in the classroom and online! Keep up the great work.

  21. Sir what is the difference between procedural programming language and object oriented programming language???

  22. x = input ("Pleae entre")

    print(x)

    my python print() is not working. When I entre a value of x, don't not show anything. Please help

  23. Hi . I notice that Pycharm helps and prompts a user when typing command,, but what does the parameter 'self' mean? Foe example in the .append command, you have self and object as parameters. If i am unsure of what the parameters are and what inout form they should take, is there a resource where i can see examples?

  24. Seetharaman Mohan

    Good tutorial for beginners in python. If we want to add just one string inside a tuple, we can do it this way.
    my_tup + ('Ram',)
    By adding comma, the interpreter considers it as a tuple instead of string.

  25. Really appreciable work to bring out such a useful and helpful tutorial….Gud work guys…Keep it up✌️

Leave a Reply

Your email address will not be published. Required fields are marked *