Python Unit-1 Oneshot 🔥 Btech aktu 2nd year| with handwritten notes #btech #aktu #unit1 #python — Transcript
Full transcript
- 0:00So hello everyone, welcome back to my
- 0:02YouTube channel, Concepts Engineering.
- 0:05Today, we are going to start Unit One
- 0:07of Python. What are we going to cover
- 0:10in this? We will discuss our entire
- 0:13syllabus, and after that, we will solve
- 0:15the 12 important coding questions you
- 0:17have. Okay? So, let's start our Unit
- 0:21One. Our syllabus unit is named
- 0:25Introduction to Python, in which we
- 0:27need to cover Python variables, its
- 0:29operators, Python blocks, and data
- 0:31types in detail. So, let's start by
- 0:35covering our first topic, Python. First
- 0:37of all, if the unit name is
- 0:39Introduction to Python, you should know
- 0:41what Python is. This question can come
- 0:44for two marks. Okay? What is Python? It
- 0:47is a high-level, interpreted,
- 0:48object-oriented language. Interpreted,
- 0:51high-level, meaning we have three
- 0:53levels. High-level, middle-level, and
- 0:55low-level. Out of these three, Python
- 0:58is high-level. Interpreted means there
- 1:02is no need for compilation before
- 1:04execution. No compilation is required
- 1:08before execution, and it is an
- 1:10object-oriented language. Meaning it is
- 1:13a high-level, interpreted, and
- 1:15object-oriented programming language.
- 1:17You have three points right here. If
- 1:19asked what Python is? Python is
- 1:21high-level. Python is interpreted and
- 1:23an object-oriented programming language
- 1:25. Who developed it? It was developed by
- 1:28Guido van Rossum. When was it done? In
- 1:311991. It is easy to learn because its
- 1:34syntax is simple and similar to the
- 1:36English language. It is the easiest
- 1:38language. We can learn it easily. Why?
- 1:42Because its syntax is very simple and
- 1:44similar to our English language. Like
- 1:47if you want to run your first program,
- 1:49Hello World, in Python. Okay? Hello
- 1:52World program. So, you will directly
- 1:54write print and inside double quotes
- 1:56what will you write? Hello World. That
- 1:59is your Hello World program. Simple, if
- 2:02this were Java...if it were C, what
- 2:05would you do? You would write a header
- 2:08file #include, as you did in your first
- 2:10year. Then you would create a main
- 2:12function here, there is nothing like
- 2:13that in this. Then you would do your
- 2:16semicolon; in this, you just have to do
- 2:18it directly. It is like English syntax,
- 2:20it is the easiest. You just have to
- 2:22print it directly, okay. Now let's come
- 2:25to the features of Python, what are the
- 2:26features of Python? We just read that
- 2:28it is an interpreted language. Meaning
- 2:30there is no requirement for compilation
- 2:32before execution. It has a simple and
- 2:35readable syntax. Meaning it is the
- 2:37easiest and most readable. You can read
- 2:39it easily. It is platform independent.
- 2:43It is platform independent. Meaning we
- 2:46can run the same program on Windows,
- 2:48Linux, and Mac OS. So, what is this? It
- 2:52is platform independent. Okay? Meaning
- 2:55the same program can run on Windows,
- 2:57Linux, and Mac OS. It is free and open
- 3:01source. It is free and open source. It
- 3:04has a large standard library. It has a
- 3:07large standard library which contains
- 3:09many built-in modules. Okay? Now come
- 3:13its applications, what are the
- 3:15applications of Python? So, the first
- 3:17is web development. You can use it in
- 3:20web development, AI, and machine
- 3:21learning. In IoT, internet of things,
- 3:25game development, or cybersecurity, we
- 3:27can use it for all these. Next come the
- 3:30advantages. We just saw what the
- 3:32advantages are. It is easy to learn and
- 3:35also to write. It requires less code,
- 3:38has a large community that supports it,
- 3:41and is portable. Different OS support
- 3:45it. Okay? Now, what are the
- 3:47disadvantages? Its execution speed is
- 3:50slow. Compared to what? Compared to C
- 3:53and C ++, what is slow? The execution
- 3:56speed. The speed to execute your code
- 3:59is slow. Compared to C and C ++. It
- 4:02consumes more memory. Meaning it is
- 4:05fine and simple, but it uses more
- 4:07memory. And its execution speed is also
- 4:10? It became slow. Not commonly used for
- 4:12mobile application development. We do
- 4:15not commonly use it in mobile
- 4:17applications. It is less suitable for
- 4:21high-performance system programming.
- 4:24Okay? Now, our Python basics start from
- 4:27here. Meaning we just read its
- 4:29applications and advantages. Now, some
- 4:32coding tools start from here. For
- 4:33example, let's study the first topic.
- 4:35Identifier. What is an identifier? An
- 4:39identifier is a name used to identify
- 4:41variables, functions. Meaning whatever
- 4:46variable you write, function you write,
- 4:48class you create, object you create,
- 4:50whatever element you have, whether that
- 4:52element is a variable, function, class,
- 4:54or object, we provide a name to
- 4:56identify them. What do we call that
- 5:00name? An identifier. An identifier is a
- 5:03name used to identify something in a
- 5:05program. Just like our identity. We are
- 5:09provided with a unique name. Like
- 5:11Pratibha. So, what is this? This is my
- 5:13identity. So, this identity has been
- 5:16provided to me. Similarly, we provide
- 5:20names to variables, functions, classes,
- 5:22or objects—to all these elements. And
- 5:26what do we call that name? An
- 5:28identifier. Okay? For example, what is
- 5:32the name? It is Rahul. What is the age?
- 5:34It is 20. What did we do? We have to
- 5:36display it. Which means, what should we
- 5:38do? Print the name. So, what will
- 5:40happen here? Rahul—we have given
- 5:43Rahul what? We gave a name to whom? To
- 5:45'name'. So, what is this 'name'? It is
- 5:48an identifier that is defining Rahul.
- 5:50Similarly, 20—what is 20? It is the
- 5:53age. We assigned 20 to age, so what is
- 5:56this? This is also our identifier. What
- 5:58is display? This is also an identifier.
- 6:01Any variable name, class name, or
- 6:03object name—anything at all—is what
- 6:06for you? It is an identifier. Okay? Now
- 6:10let's move on. Now, how do we name an
- 6:12identifier? Why did we write just 'name
- 6:14'? Could we have written 'Rahul' equals
- 6:17'Rahul' and we want to put this into
- 6:19what? Suppose we want to put this not
- 6:21inside 'name'. We wrote this, we made
- 6:24this our identifier name. Is this valid
- 6:26? Can we write 'Rahul' inside this? So,
- 6:29there are some rules for this. You have
- 6:32to use 'name' as is. Is this valid? To
- 6:35check if it's a valid identifier or not
- 6:38, meaning does Python support that
- 6:39identifier or not? So, what are its
- 6:42rules? First point. First of all, your
- 6:45identifier can be anything. If it
- 6:49contains letters from A to Z, both
- 6:51capital and small, or 0 to 9, and an
- 6:53underscore. Meaning, it should contain
- 6:57these characters. Any alphabet from A
- 6:59to Z or any number. Okay? Now comes the
- 7:02second point: start with a digit. It
- 7:05cannot start with a digit. It can never
- 7:07start with a digit. Like here, if I
- 7:13want Rahul equals, and I write one and
- 7:15then name, it can never start with a
- 7:17digit. One can come after 'name', but '
- 7:22one-name' will not work. So it cannot
- 7:25start with a digit, and it cannot
- 7:27contain spaces. We cannot write "Name
- 7:32Little" and then write Rahul; spaces
- 7:34are not allowed inside it. Okay, it
- 7:39cannot use special symbols. It cannot
- 7:42use special symbols either. Like @Rahul
- 7:45, it cannot use this either. Any
- 7:49special symbols at all. Python keywords
- 7:51cannot be used as identifiers. We will
- 7:54study keywords soon as well. But what
- 7:56is the point? If you have Python
- 7:58keywords, you cannot use them as
- 8:00identifiers. Because what are they?
- 8:02They are reserved words. They are
- 8:04keywords. We cannot use them for
- 8:06identifiers. Let's look at the next one
- 8:08. Python identifiers are case-sensitive
- 8:11. Case-sensitive means it treats
- 8:14uppercase and lowercase differently.
- 8:18Suppose I wrote RAHUL, this one. Now I
- 8:21wrote the whole thing here in capitals,
- 8:23RAHUL. So it will treat both of them
- 8:25differently. For it, this will be one
- 8:28identifier and this will be another
- 8:30identifier. Now, why is that? Because
- 8:32how is Python? It is case-sensitive. It
- 8:35treats uppercase and lowercase
- 8:37differently. Right? These are our
- 8:41identifiers and we saw the rules. Right
- 8:43? Like I explained case-sensitivity
- 8:46here with an example. Python is
- 8:48case-sensitive. Why? Because we just
- 8:51saw we wrote Name and here the 'n' was
- 8:53...Small here and capital here. So it
- 8:56is case-sensitive. It will take both
- 8:58differently. Name equals to, this is
- 8:59also an identifier. This is also an
- 9:01identifier. Why? Because we gave a name
- 9:04to this A. We gave a name to this B. If
- 9:06we provide a name to something, then
- 9:08what is it? An identifier. Now comes
- 9:10your keywords. What are keywords? We
- 9:13just studied identifiers. Identifiers
- 9:16are what we build ourselves. You must
- 9:18have seen whatever we wrote. We wrote
- 9:20Pratibha. So we were providing a name
- 9:23to Pratibha. Right? We did what from
- 9:26here? Identify. We identified this
- 9:28Pratibha. But what are keywords?
- 9:31Keywords are reserved words that have
- 9:33their own special meaning. Meaning,
- 9:36Python predefines them beforehand that
- 9:38these words are reserved. These are
- 9:41reserved for Python. It has predefined
- 9:43them. When will they be used? When some
- 9:45specific task needs to be done, we can
- 9:47use them. Otherwise, we cannot use them
- 9:50. Okay? So, what are keywords? They are
- 9:53reserved words or special words. For
- 9:55example, if you are writing 'if' and
- 9:57then providing a condition, then what
- 9:59is that? That 'if' is a reserved word.
- 10:03You cannot write it like this. if
- 10:05equals to Rahul. No, can you make the
- 10:08identifier and that the same? No. An
- 10:10identifier was supposed to go here,
- 10:13whereas 'if' is what? A keyword. So, we
- 10:18learned in our point that Python
- 10:19keywords cannot be used as identifiers.
- 10:25Python keywords cannot be used as
- 10:27identifiers. So, what is this 'if'? It
- 10:30is a reserved word. Meaning, it is a
- 10:32keyword. else, for, while, break,
- 10:34continue, what are these? These are
- 10:36reserved words. For example, we defined
- 10:39age as 20. So, what is this 20? This '
- 10:43age' is an identifier because we gave a
- 10:46name to the number 20. We provided a
- 10:49name that this is now 'age'. So, this
- 10:51became an identifier. But let's see
- 10:53what keywords are. Now we gave a
- 10:55condition, the value of age is 20. If,
- 10:58now we applied a condition: if age is
- 11:00greater than 18, check if age is
- 11:02greater than 18? So, what is the age?
- 11:0620, so is 20 greater than or equal to
- 11:0918? Yes, it is, so what will print?
- 11:12Adult. If it wasn't, what would print?
- 11:15Not adult. So the 'if' we used here,
- 11:17what is it? This 'if' is a keyword for
- 11:20us. And the 'else' used here is also a
- 11:23keyword for us. But what is age? It is
- 11:26an identifier. Python already knows the
- 11:30meaning of if and else. Python already
- 11:33knows the meaning of both 'if' and '
- 11:35else'. Okay? Now, there are comments in
- 11:38Python. Comments mean, suppose I wrote
- 11:41that I want to store any line as...in
- 11:43the form of notes. Like I wrote
- 11:47Pratibha Pursuing M.Tech. Okay? I wrote
- 11:58this: "Pratibha is pursuing M.Tech."
- 12:00Now, I want this as a note, meaning I
- 12:02don't want to print it. I just want to
- 12:05note it down. It should just be a note.
- 12:08It should have no effect on the example
- 12:10or code we are writing. So, what did
- 12:13this become for us? It became a note in
- 12:15a way. Okay? It is not part of your
- 12:17program. Meaning, it is not part of the
- 12:19execution. It is part of the Python
- 12:21program. But it is not part of the
- 12:23execution. So, what is this? We call
- 12:25this a comment. If this is two, then
- 12:27what is it now? Currently, it is one
- 12:29line, so it is a single-line comment,
- 12:31and we represent single-line comments
- 12:33with a hashtag. If I put a hashtag
- 12:35before it, it will not print. Suppose I
- 12:38wrote print Hello World. Okay? This is
- 12:42your code. I wrote Hello. Now, what do
- 12:44I need to do? Now, I don't want to
- 12:46print this. I just want to keep it as a
- 12:48note. So, what will I put in front of
- 12:49it? A hashtag. So, what has it become
- 12:51now? It has become a comment. Now it
- 12:53will have no effect on execution.
- 12:55Neither will it execute, nor will it
- 12:57give any output. It will just be
- 12:59treated as a note. Okay? So, a comment
- 13:01is a part of a Python program. What is
- 13:04a comment? It is a part of a Python
- 13:05program. That is not executed by Python
- 13:08. Which is not executed by Python. It
- 13:12is just what? It is part of the program
- 13:14. Comments are notes written inside the
- 13:16program. What are these? These are
- 13:19notes written inside the code, inside
- 13:21the program, for humans so they can
- 13:23understand it easily. It is for the
- 13:26computer; the computer understands it,
- 13:28but who is this for? It is for humans
- 13:30so they can understand it easily. How
- 13:32many types are there? There are two
- 13:34types. Single-line and multi-line.
- 13:36Meaning, if you are writing a note in
- 13:38one line, then what is it? Single-line.
- 13:40If you wrote something from here to
- 13:42here, then it is multi-line. What do we
- 13:44use for single-line? A hashtag. Okay?
- 13:47What does it start with? A hashtag.
- 13:50Like print Hello World, this program
- 13:52prints a message; I wrote this and put
- 13:54what before it? A hashtag. So now what
- 13:57is this? This is a comment. Okay? This
- 14:00will have no effect on this code. It
- 14:02will still run. But if there is a
- 14:05reader, someone reading it, they will
- 14:07see that this program is...nobody knows
- 14:09. So, they will see that this program
- 14:11is printing a message. This comment is
- 14:14not generating any output. It will just
- 14:17run for the user so they can understand
- 14:19it easily. Then comes multi-line.
- 14:24Python doesn't have a separate
- 14:26multi-line comment symbol, but triple
- 14:28quotes. You have to use triple quotes,
- 14:30either these ones or those ones. Can be
- 14:33used for multi-line text that is not
- 14:35assigned to a variable. Like, what did
- 14:37I put? I put three quotes. Triple
- 14:39quotes. And wrote that this is
- 14:41multiline. That there will be two or
- 14:43three extra lines. Okay? Or maybe
- 14:45closed it. There is no need to close
- 14:47this. It needs to be closed. And what
- 14:49will it print? Hello. So these are your
- 14:52comments. Let's see the next one. The
- 14:57next topic is lines and indentation.
- 15:00What is this? There are two topics
- 15:01within it. We will study lines and we
- 15:03will study indentation. So what is a
- 15:06line? A line. A line is a single
- 15:08instruction. What is a line? It is a
- 15:10single instruction. It is a single
- 15:12statement written inside a Python
- 15:13program. Like this is one line, line
- 15:16one. This is the second line. Second
- 15:19line, this is the third line and this
- 15:21is the fourth. So how many are these?
- 15:23They are four lines. So these are lines
- 15:25. Meaning a single instruction. This is
- 15:27a single instruction. These are single
- 15:30instructions or statements. So what are
- 15:32they? Lines. But here comes indentation
- 15:34. What is indentation? The spaces or
- 15:38tabs you give at the start of any line.
- 15:41Like it is starting from here. Suppose
- 15:43this. So what are you doing here? Now
- 15:45you wrote here, let's see with an
- 15:47example. We wrote name equals Pratibha.
- 15:54Okay? Then wrote class = 9 here. So the
- 16:01amount of indentation, how many tabs or
- 16:04spaces I gave here, what is that? That
- 16:08is your indentation. Okay? Now look at
- 16:14the example. If age is greater than or
- 16:17equal to 18. If the age is what?
- 16:19Greater than or equal to 18. Then we
- 16:22don't put curly braces here. What do we
- 16:24put here? We put a colon. Okay? So what
- 16:27happened? Inside Python. If this were
- 16:30Java, what would we use? Curly braces.
- 16:33If age is greater than or equal to 18,
- 16:35then print that you are an adult. So
- 16:38look, after 'if', you must have seen
- 16:40that when it is an if-else, brackets
- 16:42come here like this. Similarly,
- 16:44brackets after else. So this tab is
- 16:47provided to you automatically. Meaning
- 16:49you are given indentation here. So it
- 16:52is the same inside Python. If age is
- 16:54greater than or equal to 18. So here,
- 16:57instead of curly braces, a colon is
- 16:59placed, and it will automatically
- 17:01provide indentation. Meaning the print
- 17:03line will start after some spaces or
- 17:05tabs. Print "You are an adult." So what
- 17:08is happening here? Here, the second
- 17:10line has a space before "print". What
- 17:12is before "print"? There is some space.
- 17:14This is called indentation. What do we
- 17:16call this space? We call it indentation
- 17:18. Python understands that "print"
- 17:21belongs to the if-elif statement
- 17:23because it is indented. Now Python will
- 17:29automatically understand that this "
- 17:30print" line belongs to it because we
- 17:32have indented it here. Okay? So it will
- 17:37automatically understand that this is
- 17:39its own......statement. Okay? This is
- 17:42what your lines and indentation are.
- 17:45Let's look at our next topic. Your next
- 17:48topic is variables. What are variables?
- 17:51What did we study before this? You
- 17:54studied identifiers. We covered that.
- 17:57After that, we covered...After
- 17:59identifiers, we covered our variables.
- 18:03We studied variables, what variables
- 18:05are. Then after that, we studied lines
- 18:09and indentation. The most important
- 18:11ones were variables and......
- 18:13identifiers. Now comes your variables.
- 18:15Okay? Let's look at variables. What are
- 18:18variables? So, what are variables? A
- 18:21variable is a name given to a value or
- 18:23data. What is a variable? It is a name
- 18:27that we provide to a value or data.
- 18:30What is this? That is your variable. It
- 18:34is used to store data in the computer's
- 18:36memory so that we can use or change it
- 18:38later. We use it to insert data into it
- 18:43, to store data so that we can change
- 18:45it later or use it later. Okay? In
- 18:49simple words, a variable is like a
- 18:51container that holds a value. If you
- 18:54don't understand anything, you can just
- 18:56write this definition: a variable is
- 18:58like a container that holds a value.
- 19:01Like, what is Rahul? A value. So who is
- 19:05holding it? Name, this "name" is
- 19:08holding it. Similarly, age is a value.
- 19:1120 is a value. And who is holding it? "
- 19:14Age" is holding it. Just like we
- 19:17studied that we have identifiers to
- 19:18provide a name to something, so what
- 19:20was that? That was an identifier.
- 19:23Similarly, we have our variables. So
- 19:26what are variables? They are something
- 19:28that holds any value of ours. So what
- 19:31do we call that? Variables. Like name,
- 19:33age, marks, these are all......
- 19:35variables. We can use these to print
- 19:38them later on. Like if we write print
- 19:41name, then it will print Rahul. Print
- 19:43age, then it will print age; print
- 19:44marks, then it will print marks. We
- 19:47create Python variables when we assign
- 19:49a value to them. When we need to assign
- 19:52a value, like the value Rahul, we need
- 19:54to assign it, so what do we do? We
- 19:56create it. We don't need to declare the
- 19:59data type separately. It's not like we
- 20:01have to declare the data type of Rahul
- 20:03here. Like if it's 20, we don't have to
- 20:06write int to declare it or write float
- 20:08to declare it. We don't even have a
- 20:10need to do that. To write its data type
- 20:13. A variable can store different types
- 20:16of data. A variable can store different
- 20:18types of data. Alright? What are these?
- 20:21These are your variables. Now this is a
- 20:23most, most important topic, that what
- 20:26are operators? Basic operators. We have
- 20:29to study operators. How many operators
- 20:30are there in your Python? I have
- 20:32covered all the operators in detail for
- 20:34you. So what are operators? They are
- 20:37special symbols or keywords that we use
- 20:39to perform our operations. Like, what
- 20:43is the value of a? It is 10. The value
- 20:45of b is five. Print a + b. Alright? So
- 20:50this plus, what is it? We must have
- 20:52studied this normally too. This is an
- 20:54operator. Here, plus is an operator
- 20:57which we use to add a and b. So
- 21:00similarly, we have multiple operators.
- 21:02Which ones? Arithmetic, comparison,
- 21:05assignment, logical, and bitwise are
- 21:07all our operators. Now, inside this
- 21:10arithmetic, there are many operators as
- 21:12well. Like the plus ones, plus, minus,
- 21:14multiply, which are our BODMAS ones.
- 21:17Alright? These all come under what?
- 21:19They come under arithmetic operators.
- 21:21Alright? Like plus. What does this plus
- 21:24do? It adds. What does minus do?
- 21:26Subtract, multiplication. This division
- 21:28, this modulus. This addition, like in
- 21:31the example 10 + 5, so what result will
- 21:33it give? 15; in subtraction, 10-5, what
- 21:36result will it give? 5; 10*5 is 50. Now
- 21:39what will this give? Like you divided
- 21:4210 by five, 5*2 = 10, right? Now this
- 21:47two is given by your division operator.
- 21:51What does this give? The modulus one
- 21:53gives the remainder. Like you divided
- 21:5610 by three. 3*3 = 9, so 1 remains.
- 22:00This remainder is given by the modulo
- 22:02operator, which provides the remainder,
- 22:04while division gives the quotient.
- 22:07Alright? In the output, these are your
- 22:09arithmetic operations. Next, as we just
- 22:11saw in the example, what does this do?
- 22:14For instance, the value of a is 10. b
- 22:16is 3. Now we want to perform arithmetic
- 22:18for addition. So, print a + b. It will
- 22:21give 13 as the answer. Similarly, do
- 22:24a-b for 7, a*b for 30, so this is your
- 22:27first one. Now comes the second,
- 22:30comparison operators. We use comparison
- 22:32operators to compare two values. You
- 22:35will have two values. You will compare
- 22:37them. Like checking if both values are
- 22:40equal. To check for equality, we use
- 22:42the double equals sign. So for equal to
- 22:45, is five double equal to 5? If it is
- 22:48true, it will show true. We use not
- 22:50equal to. Meaning, is 5 equal to 3? No.
- 22:53So it will return true for that. Then
- 22:56we compare two values, five and three,
- 22:58using greater than. Similarly for five
- 23:00and three, use less than and less than
- 23:02or equal to, and what do you need to
- 23:04remember? You just need to remember one
- 23:06equal to, one less than, and one
- 23:08greater than. This one is for equal.
- 23:10Its opposite is not equal to. Similarly
- 23:12, do the same for less than. Less than
- 23:14or equal to and greater than, you only
- 23:16need to remember these three. According
- 23:18to these, your others will be covered.
- 23:21For example, the value of a is 10 and b
- 23:24is 5, so is a > b, meaning is 10 > 5?
- 23:28Then it becomes true. Similarly, is 10
- 23:32= 5? Then false will be printed. Next
- 23:36comes your assignment operators. We use
- 23:39assignment operators to assign or
- 23:41update values. For example, what is the
- 23:45operator? Equal. x = 10, we assigned
- 23:48this value of 10 to what? To x. So now,
- 23:52what is the value of x? 10. Similarly,
- 23:55plus equals is an assignment operator.
- 23:57Now, what happens in plus equals? Write
- 24:00x + = 10, 5, or 15. So now, what does
- 24:04this mean? x = x + 15, meaning 15 is
- 24:09being added to this x and the value is
- 24:12being stored back into x. Like, now I
- 24:17wrote x-= 5, right? What does this mean
- 24:20? x-5 is happening. x and it is
- 24:24subtracting 5. But in what is that
- 24:26value being stored? It is coming out
- 24:28equal to x itself. It is denoted like
- 24:30this. Look, multiply = x*= 5 means x =
- 24:35x*5, that is what it implies. Like if x
- 24:41= 10 and we need to do x + = 5, then
- 24:43tell me what will be the value of x? So
- 24:47right now the value of x is 10. Then we
- 24:49did x = x + 5, so what will the answer
- 24:52be? 10 + 5, which is 15. Okay? Okay?
- 24:57These are your assignments. Next come
- 24:58your logical operators. Why do we use
- 25:01logical operators? To combine. There
- 25:03are multiple conditions. There are two
- 25:05conditions or multiple. What do you
- 25:07have to do to them? Combine them. So
- 25:09how many are there? There are three
- 25:11main logical operations. Which ones?
- 25:13AND, OR, NOT. AND means both conditions
- 25:17must be true. Like I wrote any true
- 25:20condition here. I wrote true here as
- 25:23well and put AND in the middle. This
- 25:26means this condition must also be true
- 25:28and when this condition is true, only
- 25:30then will your answer be true; if this
- 25:32is true and this is false and then you
- 25:34used AND, the answer will be false.
- 25:37Both your conditions must be true. Then
- 25:39your answer will be true. And for OR,
- 25:42if at least one condition is true, what
- 25:44will your answer be? It will be true.
- 25:48NOT means just reverse it. Suppose I
- 25:51wrote that x = 5, now we have to make
- 25:54it not equal. We have to negate it. So
- 25:57x is not equal to 5, then what happens?
- 26:00There are three logical ones: AND, OR,
- 26:02NOT. Both conditions are true. Even if
- 26:05one condition is true, it works, but in
- 26:07this one what will happen? It will be
- 26:09reversed. For example, age = 20, what
- 26:13is the value of age? Print 20. Age is >
- 26:1818, meaning print only when the age
- 26:20value is greater than 18. 18. So is age
- 26:24greater than 18? Is 20 greater than 18?
- 26:26Yes, this is true. Now check the next
- 26:29one. We used an AND operator here; age,
- 26:31meaning 20, is 20 less than 30? Yes,
- 26:34this is also true. This also came out
- 26:36true. This also came out true. We
- 26:38combined both with AND, so what will
- 26:39the answer be? It will be true. Here,
- 26:41both conditions are true. So what will
- 26:43your output be? It will be true. Next
- 26:47are bitwise operators. What are bitwise
- 26:49operators? What do they do? They work
- 26:52on the binary representation. Binary
- 26:55means they work on zero and one. Who?
- 26:58Your bitwise operators. They work on
- 27:00zero and one. For example, the value of
- 27:03a is five, and b is three. Now you have
- 27:06to print A and B. So, for binary, you
- 27:08need to convert five into binary. And
- 27:10after that, three as well. There is a
- 27:12short trick for this. Write it like
- 27:14this. 2 power 0, 2 power 1, 2 power 2,
- 27:172 power 3; this means if you want to
- 27:19convert to 0, 1, I am telling you how
- 27:22to do that. So, 2 power 0 means one, 2
- 27:26power 1 is 2, power 2 is 4, and 2 power
- 27:293 is 8. You get 8, 4, 2, 1, and the
- 27:33series continues: 16, 32, and so on.
- 27:36Now, what do you need to do? To make
- 27:40five, take any two or more numbers from
- 27:438, 4, 2, 1, and what do you do with
- 27:45them? Adding those numbers should give
- 27:50you five. Will adding eight and four
- 27:51give you five? No. Not four and two, no
- 27:54. Not two and one, no. But if you add
- 27:57four and one, you get five. So, adding
- 28:00four and one gives five. This means
- 28:02select these two numbers. Write one
- 28:03there. Select this number, write one
- 28:05here, and put zero in the other places.
- 28:07So, what does it become? 0 1 0 1, so
- 28:09five is equal to what? 0 1 0 1, that is
- 28:131 0 1, okay? Here, zero below 1 0 1,
- 28:17now do the same for three. Again, write
- 28:208 4 2 1, and pick any two or more
- 28:22numbers that add up to three. So, two
- 28:26and one, put 1 1 and 0 in the remaining
- 28:28places, which means 0 1 1. Now what to
- 28:31do? Perform the AND operation and solve
- 28:33. Okay? This is your bitwise operation.
- 28:36Next is your topic. Your operators are
- 28:39now complete. Now let's come to blocks:
- 28:42what are blocks in Python? So, what are
- 28:45blocks? They are a group of statements.
- 28:48Meaning these statements form a group,
- 28:49and we have made it into what? We made
- 28:52a block. Which we treat as a single
- 28:54unit. This becomes unit one. In Python,
- 28:57blocks are mainly identified using
- 28:59indentation. We studied indentation,
- 29:02right? Lines and indentation. We cover
- 29:05it by using that. Unlike languages such
- 29:08as C or Java, Python doesn't use them.
- 29:10What do C and Java use? They use curly
- 29:13braces. It does not use those for
- 29:15blocks. If we had some C code, what
- 29:18would we do? From these curly braces to
- 29:21here. We would know that this is a
- 29:23block. But in Python, it is not like
- 29:26that. So what do we do? In this, we
- 29:30define blocks as a single unit. For
- 29:33example, if age is greater than 18,
- 29:35then here: A colon, and it
- 29:37automatically tabs here. Print "You are
- 29:40an adult" and also print "You can vote.
- 29:42" Now here are two indented prints. One
- 29:47is this, and one is that. This if, this
- 29:49print, and this print too. Are from the
- 29:52if block. So what does this become?
- 29:54This if is a block. And what are its
- 29:56parts? This and this, meaning what does
- 29:58this become? It becomes a complete
- 30:00statement. If this condition is true,
- 30:02then this part will also execute. And
- 30:04this too, so this becomes block one.
- 30:06And what do we call this block? A
- 30:08Python block. Okay? Let's see the next
- 30:11one. A Python block generally starts
- 30:14after a statement. When does a Python
- 30:17block generally start? After a
- 30:19statement ending with a colon. After
- 30:22the colon, like an if condition or any
- 30:24condition, statement one and statement
- 30:26two follow. So this colon indicates
- 30:30that a new block is about to start. As
- 30:35we saw in the example, check this:
- 30:37marks = 75, if block runs, print "pass"
- 30:40, otherwise in else, print "fail". So
- 30:44you checked this colon. The print after
- 30:47this colon and the other print formed
- 30:49this. A new one, this tells you that
- 30:53the block starts here and your block
- 30:54one is formed. Similarly, you checked
- 30:57the else part. A block starts from this
- 31:00colon, and this became your block two.
- 31:03So this is your block. Next come your
- 31:06data types. What are data types? A data
- 31:09type tells Python what kind of data a
- 31:11variable contains and what operations
- 31:13can be performed on the data. What does
- 31:16a data type tell? It tells Python what
- 31:19kind of data a variable can contain.
- 31:25Suppose I wrote marks = 10, now it will
- 31:27tell what type this is, is marks an int
- 31:29or a float? Meaning, will the data
- 31:35stored here be decimal or integer? So
- 31:38what is that? That is your data type.
- 31:40Int, float, boolean, set, and tuple,
- 31:43what are these all? These are your data
- 31:46types. So let's look at the first one.
- 31:48The first one is your integer data type
- 31:50, int. An integer is a whole number
- 31:52without a decimal point. Integer means
- 31:54there is no decimal point. So like, a =
- 31:5720, marks = 10, now what used to happen
- 32:00here? We studied in C that if you want
- 32:03to write age and it is an int type, you
- 32:04had to write int here. You had to
- 32:07define its data type, that this age is
- 32:09of integer data type. Or that these
- 32:12marks are of float type. But what will
- 32:15Python do? It will automatically
- 32:17understand that if 20 is written here.
- 32:19Now there is no decimal in it, so it
- 32:21will automatically decide that it is an
- 32:23int type. If I write 10.5 here, now if
- 32:25I put five here. Then it will
- 32:27understand what its data type is. Its
- 32:29data type is float. So what did this
- 32:31become? It detects it automatically.
- 32:34Similarly, there is float. Float for
- 32:36decimal numbers, suppose you wrote this
- 32:39value 0.50 here, so it automatically
- 32:41detected it. It is a float data type.
- 32:43Alright? That's how it is. Now comes
- 32:45boolean. What is boolean? It has two
- 32:47values. Inside a boolean, it will
- 32:49either come as true or false. It is
- 32:51mainly used for conditions or
- 32:53decision-making. Like check if is_pass
- 32:55is true. Is_raining is false. So this
- 32:58is in boolean type. It works only on
- 33:00true/false. Next comes list. What is a
- 33:03list? It is an ordered and changeable
- 33:05collection of your values. Like you
- 33:08provide values inside marks. Changeable
- 33:11values like 80, 75, what does it mean?
- 33:13It became an ordered set. It became a
- 33:15set of values inside a list. It is not
- 33:17like that. You didn't just write 80.
- 33:19You have provided multiple values. Now
- 33:21it is not necessary that they are the
- 33:23same value. 80, 75, 90, same data type.
- 33:26It can be like this. You gave the first
- 33:28value as integer. Then you gave a
- 33:29string. Then you gave a float. So you
- 33:32can provide this inside a list too.
- 33:34Next comes your fifth, tuple. What is a
- 33:37tuple? A tuple is an ordered but
- 33:40unchangeable collection. Meaning it
- 33:42won't change later. Like numbers = 10,
- 33:4620, 30, or 40, what are all these?
- 33:49These are tuples. If it is created,
- 33:52then we cannot change it normally.
- 33:54Whereas we could change a list. We
- 33:57cannot change a tuple. It is
- 33:59unchangeable. Next comes your numeric
- 34:03data type. So, what are these numeric
- 34:05data types? We just studied them. Look,
- 34:07we just studied data types, I'll show
- 34:09you here. We just covered our data
- 34:12types. These are the data types. We
- 34:14studied five types. Int, float, bool,
- 34:17set, tuple. Okay? Similarly, what do we
- 34:20have? Numeric data types. Meaning,
- 34:23those that work on values. So look, int
- 34:25also has values. 1 2 3 4, same with
- 34:28float. And one more gets added to this,
- 34:31complex. These two will remain the same
- 34:33inside it. But one more will be added,
- 34:36your float. So these are your three
- 34:39types. Two, one is int, float, and one
- 34:41is complex. Just one extra is added,
- 34:44complex. Okay? Now, Python has several
- 34:48numeric data types to store data. But
- 34:51which ones are the main ones? Int,
- 34:53float, complex. Int contains integer
- 34:56data types. Float contains decimal ones
- 34:58. We have already covered these two.
- 35:00Complex contains complex numbers. Like
- 35:045i + 3j, so what are these? These are
- 35:08your complex numbers. These are also a
- 35:11type of what? Data type. Unlike
- 35:13languages, this is the most important
- 35:15point. Unlike languages such as C or
- 35:17Java, Python doesn't require it. Like
- 35:20what happens in C and Java? If you want
- 35:22to write age, you define its data type
- 35:24for 20. For this, float. In this, there
- 35:27is nothing like that. What do you have
- 35:29to write? Simply write age is 20 and
- 35:31price is 50. Python will automatically
- 35:34determine that this age is what? It is
- 35:37of integer type because it will check
- 35:39with 20, and what type is price? Its
- 35:42data type is float because it detects
- 35:44it automatically. Okay? This is your
- 35:47most important point. Let's see the
- 35:49next one. Next comes yours. We have
- 35:53already covered this. What is an
- 35:55integer? It is for storing. Age 20, all
- 35:57these. Here, age, marks, and temp are
- 36:00what? These are integer variables. We
- 36:02can check their data type. According to
- 36:05type, we will write age 20 and print
- 36:07type of age. So in output, it will show
- 36:10you int. Okay? Next comes your floating
- 36:14point. What do we use float for storing
- 36:16? Decimal points. Like price,
- 36:19percentage. We can also check this
- 36:21using type. You will write print and in
- 36:23type write to show the type of price.
- 36:25So it will tell you the answer, it will
- 36:27be float, that it is a float data type.
- 36:30Similarly, you have complex numbers
- 36:32which consist of. One real part and one
- 36:35imaginary part. There are two parts to
- 36:38a complex number. Okay? Python uses J
- 36:41for the imaginary part. Like 3 + 4j, so
- 36:45this three, what is it? It is your real
- 36:49part and this four j is your imaginary
- 36:51part. So what did we conclude from this
- 36:54, that there are two parts. One real
- 36:56and one imaginary. The real part is
- 36:59this three and the j is what represents
- 37:01your imaginary part. We can also check
- 37:04its type. The same way we have been
- 37:06doing. Suppose this is your equation.
- 37:10Now you want to check what data type
- 37:12this Z is? So what will you write?
- 37:14Print, and print what? Its type, that
- 37:16is type of Z, so what will the output
- 37:18be? Which one is it? Complex. Okay? The
- 37:21output will appear. So these were your
- 37:24three data types. Now let's come to
- 37:27type conversion of numeric data. You
- 37:29need to change them. Meaning, which
- 37:31ones were the numeric ones? There were
- 37:33three: int, float, and complex, so how
- 37:35will you convert from int to float or
- 37:38float to complex. So how will you
- 37:40convert them? Suppose your data type is
- 37:42integer. But what do you want to do?
- 37:44You want to convert it into float, so
- 37:46you will put the value directly. Like,
- 37:48what is your x? 10, now y, what do you
- 37:51want to convert it into? You want to
- 37:55convert this into float, so you will
- 37:57take a separate variable y, inside it
- 37:59you will write float of x, and print y.
- 38:02Now, similarly, if you want to convert
- 38:04from float to int, what will you do?
- 38:06Suppose this is a float and you want to
- 38:08convert it into what? Int, so you will
- 38:11take the same variable and whatever you
- 38:13want to convert it into (int), you will
- 38:15write int (x) and print y. Now, if you
- 38:19had to convert from integer to complex?
- 38:21This x is an integer. Now what do you
- 38:23want to convert it into? Into complex.
- 38:25So, take y or take z. You took this,
- 38:28put x into the complex, and printed z.
- 38:31Then your output will appear. Okay? Now
- 38:34, here come your most important coding
- 38:36questions. You must not skip these 12
- 38:39to 14 questions. These 12 questions are
- 38:42your most, most important questions.
- 38:45These have appeared in PYQs or there
- 38:46are chances they might come this time.
- 38:49So, this is basic. What is this for you
- 38:51? This is basic. When you write any
- 38:53code, it is the first program. You have
- 38:56to write a Python program in which you
- 38:57will print Hello World. Okay? So, the
- 39:00first code is your basic one. You will
- 39:02write print. Directly Hello World. What
- 39:04will the output be? Hello World. It's
- 39:06the most basic, simple, and easiest.
- 39:08Now, we will gradually increase the
- 39:10level from basic. Now comes the second,
- 39:12you have to add two numbers. When do
- 39:14you add two numbers? When you have
- 39:16those two numbers, five and three. You
- 39:18have to add them. So, first of all, you
- 39:20must have five and three. So, you will
- 39:22ask the user for any two numbers, "give
- 39:24me any two numbers." They will type it
- 39:26with the help of the keyboard. Like you
- 39:27see, when you write code, it says "
- 39:29enter two numbers." So, what does the
- 39:32user do? They provide those two numbers
- 39:34. Then they press five and three on the
- 39:36keyboard, and then your answer comes.
- 39:37So, you will take those two numbers
- 39:39from the user. So, how do you take
- 39:41those numbers? A is a number. B is a
- 39:43number. This number is A. The user will
- 39:45provide it. This is B. You will write
- 39:47int because what type is it? Of int
- 39:49type. You are taking input from the
- 39:51user. So input, and it should say "
- 39:53enter first number." Similarly for B,
- 39:55write int. Input "enter second number."
- 39:57Now what to do? You have to add both
- 40:00and store them in another variable, c
- 40:03or 'sum', in these... 'a' +...Sum =, a
- 40:06+ b, so sum = a + b. You will add both
- 40:10and put them into 'c' or 'sum'. Print
- 40:13the 'sum', whatever the answer is. This
- 40:16'sum' that came, print it, and how to
- 40:19print it so it says 'sum = 8'. So, 'sum
- 40:23equals to' should appear in the text.
- 40:25Whatever should appear as it is, write
- 40:27it inside curly braces or double quotes
- 40:29. This is also easy. Take a number 'a'
- 40:32from the user, take 'b', and make the
- 40:34sum 'a + b'. All right? And print the
- 40:37sum. What will be displayed now? First,
- 40:39this will be displayed on the screen. "
- 40:40Enter first number," then "Enter second
- 40:42number" will be displayed. And then it
- 40:45will be solved, and "Sum = 30" will
- 40:47appear. All right? Now comes the third.
- 40:52Third is to find the square and cube of
- 40:54any number. So, first you take a number
- 40:56, like if you want to do it for five,
- 40:58you take five from the user. So, same
- 41:00as this, n = int input "Enter a number"
- 41:03. Now the user has entered five. Now
- 41:05what is the formula for a square? Look,
- 41:08if you want the square of five, or any
- 41:10number, you multiply that five by five?
- 41:13You multiply five by five, right? You
- 41:16do it like this to find the square of
- 41:18five, and how do we write this square?
- 41:20Whatever the square of someone is, it
- 41:22means 5 If 2 is written like this, it
- 41:27means 5 squared. So? Multiply n by two.
- 41:31If you want to find the square, you do
- 41:33it by two, right? If you want to find
- 41:35the square, but if you had to find the
- 41:36cube, how would you write the cube of 5
- 41:38? 5 3. So to find the cube, this is
- 41:43basically once multiplied, so n would
- 41:45be multiplied by three. But this is not
- 41:48multiplication, this is power; meaning,
- 41:50print that number's power of two as the
- 41:52square and print that number's power of
- 41:54three as the cube. So what will the
- 41:57output be? It will say "Enter a number,
- 42:00" you will enter the number five, the
- 42:02answer will come: square = 25 and cube
- 42:05= 125. The fourth question is, you have
- 42:07to check if it is an even number or an
- 42:10odd number. Take any number from the
- 42:13user and then check whether it is even
- 42:15or odd. So, n equals, took the number
- 42:18from the user, now how to know if it is
- 42:20even or odd? You divide that number by
- 42:22two; if the remainder, this is the sign
- 42:24for the remainder. If your remainder
- 42:27comes out to be zero, then what kind of
- 42:29number is it? Even. If it doesn't come
- 42:32out to be zero, then it's odd. So what
- 42:34do you do? If you divide it by two.
- 42:37Equals, equals, if it comes out to be
- 42:39zero, then print even number. If it
- 42:41doesn't come out to be zero, then print
- 42:43odd number. Now you have to find the
- 42:45greatest number. You have three numbers
- 42:49, A, B, and C. Check which of the three
- 42:51numbers is the greatest. So, what will
- 42:55you do? First of all, you need to do
- 42:58what with those three numbers? You need
- 43:00to enter them. A number A, B, and C.
- 43:03You entered all three numbers from the
- 43:05user, as input. Now, check A and B
- 43:09together to see if A is greater than B?
- 43:13Check it. A should be greater than B
- 43:15and also greater than C. If A is
- 43:17greater than B and also C. Then
- 43:18directly write that A is the greatest.
- 43:20Suppose you have an eight, a five, and
- 43:23a six. You checked this is A. You
- 43:25checked it, it is greater than five. It
- 43:27is also greater than six. If it is
- 43:29greater, then what is your eight? It
- 43:30became the greatest. So, the same
- 43:32condition is applied. Check A. Is A
- 43:34greater than both B and C? If it is
- 43:37greater, then print it. A is greater.
- 43:39Now, if it is not, then what do you
- 43:41check? Take B. Check B. Is B greater
- 43:44than A and C, all of them? You took B.
- 43:49This is A, this is B, and this is C.
- 43:51Here is 8, here is five, here is six.
- 43:54Now, check B. Is it greater than five,
- 43:57eight, five, and six? If it is greater,
- 44:00then print B. Okay? Greatest is B. But
- 44:03if neither A nor B is greater, then
- 44:05which one will be the greatest? Without
- 44:07a condition, C becomes the greatest.
- 44:10Okay? Look, let's see with an example.
- 44:16Here we have 5, 3, 8; you checked
- 44:18according to the first condition, is 5
- 44:20greater than both of these? No. It went
- 44:24to the second elif. Now you checked, is
- 44:273 greater than both A and C? No. In
- 44:30else, without checking the condition,
- 44:32just say C is the greatest. Eight is
- 44:34the greatest. So, that's how we check.
- 44:37Next, check this. Whether the number is
- 44:40positive, negative, or zero. So first,
- 44:42you will take that number from the user
- 44:44. If a number is greater than zero,
- 44:45then if that number is greater than
- 44:47zero, then what is that number? It is a
- 44:50positive number. So if that number is
- 44:53compared to what? Smaller than zero, if
- 44:55that number is greater than zero, then
- 44:57we know it's positive. But if a number
- 44:59is what compared to zero? If it is
- 45:01smaller, then we know it is negative.
- 45:03If it is zero, then print zero. Next
- 45:06comes checking for a leap year. So,
- 45:08which one is a leap year? If a number
- 45:11is divisible by 400, or here the
- 45:13condition of 'or' comes in. If a number
- 45:16is divisible by 400, and it is
- 45:18divisible by four. It is divisible by
- 45:21four but not divisible by 100. Then
- 45:24what should it be? The year should be
- 45:25what with respect to 400? Completely
- 45:29divisible, or it should be divisible by
- 45:31four but not by 100. So that is your
- 45:35leap year condition. Divisible by 400,
- 45:37divisible by four. It should be
- 45:40divisible by either one of these, or
- 45:42four, but it must not be divisible by
- 45:44100. If this is the case, it is a leap
- 45:47year, otherwise, it is not. Next, you
- 45:52have to print a multiplication table,
- 45:54like 5*1 = 5, so you print a table for
- 45:56any number. Suppose for 12, 5, or 13,
- 46:00you take the number for the table from
- 46:03the user. Then check using 'for i in
- 46:05range', we will use a for loop. From
- 46:08one to 11, meaning it starts from one
- 46:10and ends at 10. Now what will you do?
- 46:13Print the number taken, which is n.
- 46:15This will print, so it becomes n. Into
- 46:18cross multiply, n into, then i should
- 46:21come. Meaning the value should keep
- 46:22increasing. 1, 2, 3, 4, i, then equals
- 46:26comes. And what is this? What is being
- 46:28multiplied? n and i. n*i Right? So this
- 46:33is how your multiplication table works.
- 46:36Next comes finding the factorial. Find
- 46:38the factorial of a number. So let's see
- 46:41how we do that. So let's look at the
- 46:43factorial. What happens in a factorial?
- 46:45If you want to find the factorial of
- 46:47any number, suppose you want the
- 46:48factorial of six, what do you do? You
- 46:50write six as it is. *5*4*3*2*1, how
- 46:53long do you keep doing this? Until one,
- 46:58until the end. Exactly. Right? Meaning
- 47:00you keep multiplying from one to that
- 47:02number. First of all, what will you
- 47:04take? You will take n. Meaning you will
- 47:06take that number as input. You will
- 47:08create a variable 'fact' and insert the
- 47:10value one into it. Now you will apply
- 47:14the same for loop from one up to n + 1.
- 47:17Now look here, we applied the loop up
- 47:19to n + 1. Meaning, we applied a loop up
- 47:22to the value we took. Right? And what
- 47:25did we do after that? fact = fact*i.
- 47:28What is the value of fact right now?
- 47:30One. And what is the value of this one?
- 47:33One. Okay? How much will this also be?
- 47:36One. That is how you will do it. After
- 47:38that, you will print the factorial. And
- 47:40how long will this loop run? It will
- 47:41run until it becomes n + 1. For example
- 47:44, you took the number six, to find the
- 47:46factorial of six. So, what will you do?
- 47:49You will run the loop from one, and 6 +
- 47:511 becomes how much? Seven. So it will
- 47:53run up to seven. Meaning the loop will
- 47:55run from one to six. And it will print
- 47:57the value up to six. Now, how will it
- 47:59do that? What is the value of fact? It
- 48:01was one in the beginning, and what is
- 48:03the value of i in the beginning? It is
- 48:05one. So 1*1, how much did you get? One.
- 48:08This last one has arrived. After that,
- 48:10what is the value of i now? Two. Now 2*
- 48:13, what is the value of fact right now?
- 48:15Its value has become one. Now how much
- 48:17did it come to? Two. Now in the next
- 48:19turn, 3*1, 3; in this way, the value of
- 48:21fact will keep increasing and you will
- 48:24keep multiplying 5*4. Likewise, we have
- 48:27reverse. You have to do a reverse.
- 48:28Suppose you have any number. Your
- 48:32number is 1 2 3, this is your number.
- 48:34Now you have to reverse it. You want to
- 48:37make it 3 2 1, so you need this number.
- 48:39You need this number and you need this
- 48:41number. So what will you do? First of
- 48:43all, you took input from the user. They
- 48:45wrote 1 2 3, that is 123. Now you took
- 48:48a reverse variable. Inside that, we
- 48:50inserted a zero value. Now check n. Is
- 48:53n greater than zero? If it is greater
- 48:55than zero, that means it is a positive
- 48:57number. Then what should you do with 10
- 48:59? Divide it, and how should you divide
- 49:01it? Using the modulo operator. Look, I
- 49:04told you that you also have to keep
- 49:06checking why you need to do the modulo.
- 49:09Look, this is the part where the
- 49:10remainder is left. It writes down the
- 49:13remainder that is left. So what will we
- 49:15do? It is 1 2 3. Dividing it by what?
- 49:19By 10. So we divided by 10. 10*1 = 10,
- 49:22two remained. Then after that, three.
- 49:2510*2 = 20. Now what is left here? The
- 49:27remainder is three. So this three,
- 49:30which is the starting number at the end
- 49:31, will be extracted. This three is out,
- 49:35which you have written down. Look, this
- 49:37number is being extracted using this
- 49:39modulo. In 1 2 3, the last number three
- 49:41is extracted. It arrived at the first
- 49:43one. Now what to do? Do reverse equals
- 49:46to reverse*10 plus digit. Now reverse
- 49:49was zero. What is in your reverse? Zero
- 49:52. Now you need to store this reverse
- 49:55into reverse equals reverse. So what is
- 49:58your reverse? 0, so 0*10 plus what was
- 50:02your digit? It was three. The remainder
- 50:06that came was three, so reverse = 0*10
- 50:09makes 0 + 3, three you got from here.
- 50:13Okay? Your first number came as three.
- 50:15Now what to do? Do n = n/10. Meaning,
- 50:18what to extract from this? Just your
- 50:21this number, meaning from 1 2 3, now
- 50:23what do you extract after dividing? 10*
- 50:261 = 10, this was coming, right, 12? So
- 50:29this 12 is left. From here 12 is left,
- 50:32just 12 is left. Now you went back,
- 50:35divided this 12 again by 10. When you
- 50:37divide 12 again by 10, then 10*1 = 10,
- 50:40again what is left? Two. Earlier three
- 50:43was left, now two is left. So your two
- 50:45numbers came as 32, now this two is
- 50:47here, now you solved this equation/
- 50:49question. After that, came back again.
- 50:51Now you divided this 12 by what? By 10.
- 50:54So what is remaining? One. Now went to
- 50:56one, so 3 2 1 is left for you. What
- 50:58does this mean? What do you have to do?
- 51:01You have to divide 1 2 3 by 10 once for
- 51:03the remainder, whatever that number is.
- 51:06Okay? Here you will be left with 10 2 3
- 51:0920 and 3, suppose this is left. Now you
- 51:14have to take this number once. Take
- 51:16this one once. Okay? When you take this
- 51:20, you have to store that number in
- 51:21reverse, and with this, you keep making
- 51:23that number smaller. So this is your
- 51:27reverse. Now comes palindrome. Which is
- 51:32a palindrome number, the one that
- 51:33remains the same even after being
- 51:35reversed; you reversed it here, but if
- 51:37it stays the same, then what is it?
- 51:40Palindrome. So you will write the same
- 51:42code, this reverse one. Okay? Wrote the
- 51:44same reverse code. Reverse = 0, n
- 51:46should be greater than zero. Divide by
- 51:4910. Reverse*10 and this n is the same.
- 51:52Now check if this answer you got in
- 51:54reverse is equal to the original? The
- 51:56one that was your first number 1 2 3,
- 51:58are both the same? If both are same,
- 52:01then print palindrome. If not, then
- 52:03print not a palindrome. So, this is how
- 52:06it's done. All right? For instance,
- 52:09take 121. If we reverse it, it will
- 52:11return 121. So, this is a palindrome
- 52:13number. You need to write the reverse
- 52:15code. Just add one if condition. Check
- 52:18if your original number is equal to the
- 52:19reverse. If it is, then it's a
- 52:21palindrome; otherwise, it's not. Next
- 52:25up is your Armstrong number. What is an
- 52:27Armstrong number? If there is a
- 52:29three-digit number, suppose 153. Now,
- 52:33what do you do with it? Since it has
- 52:35three digits, cube them. 1 cubed, 5
- 52:37cubed, and 3 cubed. 1 cubed is one. 5
- 52:41cubed is 125 and 3 cubed is 27; add all
- 52:44three. If it becomes the same number
- 52:48again, it is an Armstrong number. When
- 52:51we add 1 + 125 + 27, it becomes 153.
- 52:55And that was our original number too.
- 52:57So, what is it? It is an Armstrong
- 52:59number. For instance, if it were 196,
- 53:03what would you do? You would cube 1,
- 53:06cube 9, and cube 6; get the results,
- 53:08add them, and if you get the same 196,
- 53:11then what would it be? Not palindrome,
- 53:14sorry, Armstrong. If not, then what
- 53:16would it not be? It would not be an
- 53:17Armstrong number. So, how will you
- 53:19write the code? You will take a number
- 53:21from the user, store n in an original
- 53:23variable, and zero in sum. The same
- 53:25code you had, which one? The palindrome
- 53:27one; you have to write that same code,
- 53:29but what do you do? Take a sum variable
- 53:31instead of reverse, and here you need
- 53:33to perform what on the digit? Power of
- 53:35three. Look, sum plus, sum has come as
- 53:37zero. Keep it that way. Now, what are
- 53:39you doing? You are cubing whatever the
- 53:41digit is, right? So this is how you
- 53:43cube. If there were only one star, it
- 53:45would mean multiply. But I told you, if
- 53:48there are double stars, it means the
- 53:49digit's power; it’s like digit raised
- 53:51to power three. So, you will divide in
- 53:54the sum exactly the same way. Like you
- 53:56do in this one. Look, the code for all
- 53:58three is exactly the same. What will
- 53:59you do first for this one too? You will
- 54:02do modulo and then divide. Similarly,
- 54:04here you do modulo and divide; in the
- 54:06middle line, reverse*10 plus digit
- 54:08happens, and here sum plus digit to the
- 54:10power of 3; I have explained the logic
- 54:12for this as well. Now it's solved. Then
- 54:14after that, you check if the original
- 54:16and sum are the same. If they are the
- 54:18same, it is an Armstrong number. If
- 54:19they are not the same, then it is not
- 54:21an Armstrong number. So, these are your
- 54:25...These were your 12 important coding
- 54:27questions that appear in PYQs or have a
- 54:29high chance of appearing. So, we have
- 54:33solved those. And with that, our unit
- 54:35one is complete.
About this transcript
This page contains the full transcript of Python Unit-1 Oneshot 🔥 Btech aktu 2nd year| with handwritten notes #btech #aktu #unit1 #python by Coreconcepts:engineering, generated from the public captions YouTube serves with the video. The transcript has 9,349 words across 1,274 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to choose a caption track available on the video.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, caption language selection, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.