YouTube2Text

Python Unit-1 Oneshot 🔥 Btech aktu 2nd year| with handwritten notes #btech #aktu #unit1 #python — Transcript

by Coreconcepts:engineering · 9,349 words · 1,274 segments · language en · Watch on YouTube

Full transcript

  1. 0:00So hello everyone, welcome back to my
  2. 0:02YouTube channel, Concepts Engineering.
  3. 0:05Today, we are going to start Unit One
  4. 0:07of Python. What are we going to cover
  5. 0:10in this? We will discuss our entire
  6. 0:13syllabus, and after that, we will solve
  7. 0:15the 12 important coding questions you
  8. 0:17have. Okay? So, let's start our Unit
  9. 0:21One. Our syllabus unit is named
  10. 0:25Introduction to Python, in which we
  11. 0:27need to cover Python variables, its
  12. 0:29operators, Python blocks, and data
  13. 0:31types in detail. So, let's start by
  14. 0:35covering our first topic, Python. First
  15. 0:37of all, if the unit name is
  16. 0:39Introduction to Python, you should know
  17. 0:41what Python is. This question can come
  18. 0:44for two marks. Okay? What is Python? It
  19. 0:47is a high-level, interpreted,
  20. 0:48object-oriented language. Interpreted,
  21. 0:51high-level, meaning we have three
  22. 0:53levels. High-level, middle-level, and
  23. 0:55low-level. Out of these three, Python
  24. 0:58is high-level. Interpreted means there
  25. 1:02is no need for compilation before
  26. 1:04execution. No compilation is required
  27. 1:08before execution, and it is an
  28. 1:10object-oriented language. Meaning it is
  29. 1:13a high-level, interpreted, and
  30. 1:15object-oriented programming language.
  31. 1:17You have three points right here. If
  32. 1:19asked what Python is? Python is
  33. 1:21high-level. Python is interpreted and
  34. 1:23an object-oriented programming language
  35. 1:25. Who developed it? It was developed by
  36. 1:28Guido van Rossum. When was it done? In
  37. 1:311991. It is easy to learn because its
  38. 1:34syntax is simple and similar to the
  39. 1:36English language. It is the easiest
  40. 1:38language. We can learn it easily. Why?
  41. 1:42Because its syntax is very simple and
  42. 1:44similar to our English language. Like
  43. 1:47if you want to run your first program,
  44. 1:49Hello World, in Python. Okay? Hello
  45. 1:52World program. So, you will directly
  46. 1:54write print and inside double quotes
  47. 1:56what will you write? Hello World. That
  48. 1:59is your Hello World program. Simple, if
  49. 2:02this were Java...if it were C, what
  50. 2:05would you do? You would write a header
  51. 2:08file #include, as you did in your first
  52. 2:10year. Then you would create a main
  53. 2:12function here, there is nothing like
  54. 2:13that in this. Then you would do your
  55. 2:16semicolon; in this, you just have to do
  56. 2:18it directly. It is like English syntax,
  57. 2:20it is the easiest. You just have to
  58. 2:22print it directly, okay. Now let's come
  59. 2:25to the features of Python, what are the
  60. 2:26features of Python? We just read that
  61. 2:28it is an interpreted language. Meaning
  62. 2:30there is no requirement for compilation
  63. 2:32before execution. It has a simple and
  64. 2:35readable syntax. Meaning it is the
  65. 2:37easiest and most readable. You can read
  66. 2:39it easily. It is platform independent.
  67. 2:43It is platform independent. Meaning we
  68. 2:46can run the same program on Windows,
  69. 2:48Linux, and Mac OS. So, what is this? It
  70. 2:52is platform independent. Okay? Meaning
  71. 2:55the same program can run on Windows,
  72. 2:57Linux, and Mac OS. It is free and open
  73. 3:01source. It is free and open source. It
  74. 3:04has a large standard library. It has a
  75. 3:07large standard library which contains
  76. 3:09many built-in modules. Okay? Now come
  77. 3:13its applications, what are the
  78. 3:15applications of Python? So, the first
  79. 3:17is web development. You can use it in
  80. 3:20web development, AI, and machine
  81. 3:21learning. In IoT, internet of things,
  82. 3:25game development, or cybersecurity, we
  83. 3:27can use it for all these. Next come the
  84. 3:30advantages. We just saw what the
  85. 3:32advantages are. It is easy to learn and
  86. 3:35also to write. It requires less code,
  87. 3:38has a large community that supports it,
  88. 3:41and is portable. Different OS support
  89. 3:45it. Okay? Now, what are the
  90. 3:47disadvantages? Its execution speed is
  91. 3:50slow. Compared to what? Compared to C
  92. 3:53and C ++, what is slow? The execution
  93. 3:56speed. The speed to execute your code
  94. 3:59is slow. Compared to C and C ++. It
  95. 4:02consumes more memory. Meaning it is
  96. 4:05fine and simple, but it uses more
  97. 4:07memory. And its execution speed is also
  98. 4:10? It became slow. Not commonly used for
  99. 4:12mobile application development. We do
  100. 4:15not commonly use it in mobile
  101. 4:17applications. It is less suitable for
  102. 4:21high-performance system programming.
  103. 4:24Okay? Now, our Python basics start from
  104. 4:27here. Meaning we just read its
  105. 4:29applications and advantages. Now, some
  106. 4:32coding tools start from here. For
  107. 4:33example, let's study the first topic.
  108. 4:35Identifier. What is an identifier? An
  109. 4:39identifier is a name used to identify
  110. 4:41variables, functions. Meaning whatever
  111. 4:46variable you write, function you write,
  112. 4:48class you create, object you create,
  113. 4:50whatever element you have, whether that
  114. 4:52element is a variable, function, class,
  115. 4:54or object, we provide a name to
  116. 4:56identify them. What do we call that
  117. 5:00name? An identifier. An identifier is a
  118. 5:03name used to identify something in a
  119. 5:05program. Just like our identity. We are
  120. 5:09provided with a unique name. Like
  121. 5:11Pratibha. So, what is this? This is my
  122. 5:13identity. So, this identity has been
  123. 5:16provided to me. Similarly, we provide
  124. 5:20names to variables, functions, classes,
  125. 5:22or objects—to all these elements. And
  126. 5:26what do we call that name? An
  127. 5:28identifier. Okay? For example, what is
  128. 5:32the name? It is Rahul. What is the age?
  129. 5:34It is 20. What did we do? We have to
  130. 5:36display it. Which means, what should we
  131. 5:38do? Print the name. So, what will
  132. 5:40happen here? Rahul—we have given
  133. 5:43Rahul what? We gave a name to whom? To
  134. 5:45'name'. So, what is this 'name'? It is
  135. 5:48an identifier that is defining Rahul.
  136. 5:50Similarly, 20—what is 20? It is the
  137. 5:53age. We assigned 20 to age, so what is
  138. 5:56this? This is also our identifier. What
  139. 5:58is display? This is also an identifier.
  140. 6:01Any variable name, class name, or
  141. 6:03object name—anything at all—is what
  142. 6:06for you? It is an identifier. Okay? Now
  143. 6:10let's move on. Now, how do we name an
  144. 6:12identifier? Why did we write just 'name
  145. 6:14'? Could we have written 'Rahul' equals
  146. 6:17'Rahul' and we want to put this into
  147. 6:19what? Suppose we want to put this not
  148. 6:21inside 'name'. We wrote this, we made
  149. 6:24this our identifier name. Is this valid
  150. 6:26? Can we write 'Rahul' inside this? So,
  151. 6:29there are some rules for this. You have
  152. 6:32to use 'name' as is. Is this valid? To
  153. 6:35check if it's a valid identifier or not
  154. 6:38, meaning does Python support that
  155. 6:39identifier or not? So, what are its
  156. 6:42rules? First point. First of all, your
  157. 6:45identifier can be anything. If it
  158. 6:49contains letters from A to Z, both
  159. 6:51capital and small, or 0 to 9, and an
  160. 6:53underscore. Meaning, it should contain
  161. 6:57these characters. Any alphabet from A
  162. 6:59to Z or any number. Okay? Now comes the
  163. 7:02second point: start with a digit. It
  164. 7:05cannot start with a digit. It can never
  165. 7:07start with a digit. Like here, if I
  166. 7:13want Rahul equals, and I write one and
  167. 7:15then name, it can never start with a
  168. 7:17digit. One can come after 'name', but '
  169. 7:22one-name' will not work. So it cannot
  170. 7:25start with a digit, and it cannot
  171. 7:27contain spaces. We cannot write "Name
  172. 7:32Little" and then write Rahul; spaces
  173. 7:34are not allowed inside it. Okay, it
  174. 7:39cannot use special symbols. It cannot
  175. 7:42use special symbols either. Like @Rahul
  176. 7:45, it cannot use this either. Any
  177. 7:49special symbols at all. Python keywords
  178. 7:51cannot be used as identifiers. We will
  179. 7:54study keywords soon as well. But what
  180. 7:56is the point? If you have Python
  181. 7:58keywords, you cannot use them as
  182. 8:00identifiers. Because what are they?
  183. 8:02They are reserved words. They are
  184. 8:04keywords. We cannot use them for
  185. 8:06identifiers. Let's look at the next one
  186. 8:08. Python identifiers are case-sensitive
  187. 8:11. Case-sensitive means it treats
  188. 8:14uppercase and lowercase differently.
  189. 8:18Suppose I wrote RAHUL, this one. Now I
  190. 8:21wrote the whole thing here in capitals,
  191. 8:23RAHUL. So it will treat both of them
  192. 8:25differently. For it, this will be one
  193. 8:28identifier and this will be another
  194. 8:30identifier. Now, why is that? Because
  195. 8:32how is Python? It is case-sensitive. It
  196. 8:35treats uppercase and lowercase
  197. 8:37differently. Right? These are our
  198. 8:41identifiers and we saw the rules. Right
  199. 8:43? Like I explained case-sensitivity
  200. 8:46here with an example. Python is
  201. 8:48case-sensitive. Why? Because we just
  202. 8:51saw we wrote Name and here the 'n' was
  203. 8:53...Small here and capital here. So it
  204. 8:56is case-sensitive. It will take both
  205. 8:58differently. Name equals to, this is
  206. 8:59also an identifier. This is also an
  207. 9:01identifier. Why? Because we gave a name
  208. 9:04to this A. We gave a name to this B. If
  209. 9:06we provide a name to something, then
  210. 9:08what is it? An identifier. Now comes
  211. 9:10your keywords. What are keywords? We
  212. 9:13just studied identifiers. Identifiers
  213. 9:16are what we build ourselves. You must
  214. 9:18have seen whatever we wrote. We wrote
  215. 9:20Pratibha. So we were providing a name
  216. 9:23to Pratibha. Right? We did what from
  217. 9:26here? Identify. We identified this
  218. 9:28Pratibha. But what are keywords?
  219. 9:31Keywords are reserved words that have
  220. 9:33their own special meaning. Meaning,
  221. 9:36Python predefines them beforehand that
  222. 9:38these words are reserved. These are
  223. 9:41reserved for Python. It has predefined
  224. 9:43them. When will they be used? When some
  225. 9:45specific task needs to be done, we can
  226. 9:47use them. Otherwise, we cannot use them
  227. 9:50. Okay? So, what are keywords? They are
  228. 9:53reserved words or special words. For
  229. 9:55example, if you are writing 'if' and
  230. 9:57then providing a condition, then what
  231. 9:59is that? That 'if' is a reserved word.
  232. 10:03You cannot write it like this. if
  233. 10:05equals to Rahul. No, can you make the
  234. 10:08identifier and that the same? No. An
  235. 10:10identifier was supposed to go here,
  236. 10:13whereas 'if' is what? A keyword. So, we
  237. 10:18learned in our point that Python
  238. 10:19keywords cannot be used as identifiers.
  239. 10:25Python keywords cannot be used as
  240. 10:27identifiers. So, what is this 'if'? It
  241. 10:30is a reserved word. Meaning, it is a
  242. 10:32keyword. else, for, while, break,
  243. 10:34continue, what are these? These are
  244. 10:36reserved words. For example, we defined
  245. 10:39age as 20. So, what is this 20? This '
  246. 10:43age' is an identifier because we gave a
  247. 10:46name to the number 20. We provided a
  248. 10:49name that this is now 'age'. So, this
  249. 10:51became an identifier. But let's see
  250. 10:53what keywords are. Now we gave a
  251. 10:55condition, the value of age is 20. If,
  252. 10:58now we applied a condition: if age is
  253. 11:00greater than 18, check if age is
  254. 11:02greater than 18? So, what is the age?
  255. 11:0620, so is 20 greater than or equal to
  256. 11:0918? Yes, it is, so what will print?
  257. 11:12Adult. If it wasn't, what would print?
  258. 11:15Not adult. So the 'if' we used here,
  259. 11:17what is it? This 'if' is a keyword for
  260. 11:20us. And the 'else' used here is also a
  261. 11:23keyword for us. But what is age? It is
  262. 11:26an identifier. Python already knows the
  263. 11:30meaning of if and else. Python already
  264. 11:33knows the meaning of both 'if' and '
  265. 11:35else'. Okay? Now, there are comments in
  266. 11:38Python. Comments mean, suppose I wrote
  267. 11:41that I want to store any line as...in
  268. 11:43the form of notes. Like I wrote
  269. 11:47Pratibha Pursuing M.Tech. Okay? I wrote
  270. 11:58this: "Pratibha is pursuing M.Tech."
  271. 12:00Now, I want this as a note, meaning I
  272. 12:02don't want to print it. I just want to
  273. 12:05note it down. It should just be a note.
  274. 12:08It should have no effect on the example
  275. 12:10or code we are writing. So, what did
  276. 12:13this become for us? It became a note in
  277. 12:15a way. Okay? It is not part of your
  278. 12:17program. Meaning, it is not part of the
  279. 12:19execution. It is part of the Python
  280. 12:21program. But it is not part of the
  281. 12:23execution. So, what is this? We call
  282. 12:25this a comment. If this is two, then
  283. 12:27what is it now? Currently, it is one
  284. 12:29line, so it is a single-line comment,
  285. 12:31and we represent single-line comments
  286. 12:33with a hashtag. If I put a hashtag
  287. 12:35before it, it will not print. Suppose I
  288. 12:38wrote print Hello World. Okay? This is
  289. 12:42your code. I wrote Hello. Now, what do
  290. 12:44I need to do? Now, I don't want to
  291. 12:46print this. I just want to keep it as a
  292. 12:48note. So, what will I put in front of
  293. 12:49it? A hashtag. So, what has it become
  294. 12:51now? It has become a comment. Now it
  295. 12:53will have no effect on execution.
  296. 12:55Neither will it execute, nor will it
  297. 12:57give any output. It will just be
  298. 12:59treated as a note. Okay? So, a comment
  299. 13:01is a part of a Python program. What is
  300. 13:04a comment? It is a part of a Python
  301. 13:05program. That is not executed by Python
  302. 13:08. Which is not executed by Python. It
  303. 13:12is just what? It is part of the program
  304. 13:14. Comments are notes written inside the
  305. 13:16program. What are these? These are
  306. 13:19notes written inside the code, inside
  307. 13:21the program, for humans so they can
  308. 13:23understand it easily. It is for the
  309. 13:26computer; the computer understands it,
  310. 13:28but who is this for? It is for humans
  311. 13:30so they can understand it easily. How
  312. 13:32many types are there? There are two
  313. 13:34types. Single-line and multi-line.
  314. 13:36Meaning, if you are writing a note in
  315. 13:38one line, then what is it? Single-line.
  316. 13:40If you wrote something from here to
  317. 13:42here, then it is multi-line. What do we
  318. 13:44use for single-line? A hashtag. Okay?
  319. 13:47What does it start with? A hashtag.
  320. 13:50Like print Hello World, this program
  321. 13:52prints a message; I wrote this and put
  322. 13:54what before it? A hashtag. So now what
  323. 13:57is this? This is a comment. Okay? This
  324. 14:00will have no effect on this code. It
  325. 14:02will still run. But if there is a
  326. 14:05reader, someone reading it, they will
  327. 14:07see that this program is...nobody knows
  328. 14:09. So, they will see that this program
  329. 14:11is printing a message. This comment is
  330. 14:14not generating any output. It will just
  331. 14:17run for the user so they can understand
  332. 14:19it easily. Then comes multi-line.
  333. 14:24Python doesn't have a separate
  334. 14:26multi-line comment symbol, but triple
  335. 14:28quotes. You have to use triple quotes,
  336. 14:30either these ones or those ones. Can be
  337. 14:33used for multi-line text that is not
  338. 14:35assigned to a variable. Like, what did
  339. 14:37I put? I put three quotes. Triple
  340. 14:39quotes. And wrote that this is
  341. 14:41multiline. That there will be two or
  342. 14:43three extra lines. Okay? Or maybe
  343. 14:45closed it. There is no need to close
  344. 14:47this. It needs to be closed. And what
  345. 14:49will it print? Hello. So these are your
  346. 14:52comments. Let's see the next one. The
  347. 14:57next topic is lines and indentation.
  348. 15:00What is this? There are two topics
  349. 15:01within it. We will study lines and we
  350. 15:03will study indentation. So what is a
  351. 15:06line? A line. A line is a single
  352. 15:08instruction. What is a line? It is a
  353. 15:10single instruction. It is a single
  354. 15:12statement written inside a Python
  355. 15:13program. Like this is one line, line
  356. 15:16one. This is the second line. Second
  357. 15:19line, this is the third line and this
  358. 15:21is the fourth. So how many are these?
  359. 15:23They are four lines. So these are lines
  360. 15:25. Meaning a single instruction. This is
  361. 15:27a single instruction. These are single
  362. 15:30instructions or statements. So what are
  363. 15:32they? Lines. But here comes indentation
  364. 15:34. What is indentation? The spaces or
  365. 15:38tabs you give at the start of any line.
  366. 15:41Like it is starting from here. Suppose
  367. 15:43this. So what are you doing here? Now
  368. 15:45you wrote here, let's see with an
  369. 15:47example. We wrote name equals Pratibha.
  370. 15:54Okay? Then wrote class = 9 here. So the
  371. 16:01amount of indentation, how many tabs or
  372. 16:04spaces I gave here, what is that? That
  373. 16:08is your indentation. Okay? Now look at
  374. 16:14the example. If age is greater than or
  375. 16:17equal to 18. If the age is what?
  376. 16:19Greater than or equal to 18. Then we
  377. 16:22don't put curly braces here. What do we
  378. 16:24put here? We put a colon. Okay? So what
  379. 16:27happened? Inside Python. If this were
  380. 16:30Java, what would we use? Curly braces.
  381. 16:33If age is greater than or equal to 18,
  382. 16:35then print that you are an adult. So
  383. 16:38look, after 'if', you must have seen
  384. 16:40that when it is an if-else, brackets
  385. 16:42come here like this. Similarly,
  386. 16:44brackets after else. So this tab is
  387. 16:47provided to you automatically. Meaning
  388. 16:49you are given indentation here. So it
  389. 16:52is the same inside Python. If age is
  390. 16:54greater than or equal to 18. So here,
  391. 16:57instead of curly braces, a colon is
  392. 16:59placed, and it will automatically
  393. 17:01provide indentation. Meaning the print
  394. 17:03line will start after some spaces or
  395. 17:05tabs. Print "You are an adult." So what
  396. 17:08is happening here? Here, the second
  397. 17:10line has a space before "print". What
  398. 17:12is before "print"? There is some space.
  399. 17:14This is called indentation. What do we
  400. 17:16call this space? We call it indentation
  401. 17:18. Python understands that "print"
  402. 17:21belongs to the if-elif statement
  403. 17:23because it is indented. Now Python will
  404. 17:29automatically understand that this "
  405. 17:30print" line belongs to it because we
  406. 17:32have indented it here. Okay? So it will
  407. 17:37automatically understand that this is
  408. 17:39its own......statement. Okay? This is
  409. 17:42what your lines and indentation are.
  410. 17:45Let's look at our next topic. Your next
  411. 17:48topic is variables. What are variables?
  412. 17:51What did we study before this? You
  413. 17:54studied identifiers. We covered that.
  414. 17:57After that, we covered...After
  415. 17:59identifiers, we covered our variables.
  416. 18:03We studied variables, what variables
  417. 18:05are. Then after that, we studied lines
  418. 18:09and indentation. The most important
  419. 18:11ones were variables and......
  420. 18:13identifiers. Now comes your variables.
  421. 18:15Okay? Let's look at variables. What are
  422. 18:18variables? So, what are variables? A
  423. 18:21variable is a name given to a value or
  424. 18:23data. What is a variable? It is a name
  425. 18:27that we provide to a value or data.
  426. 18:30What is this? That is your variable. It
  427. 18:34is used to store data in the computer's
  428. 18:36memory so that we can use or change it
  429. 18:38later. We use it to insert data into it
  430. 18:43, to store data so that we can change
  431. 18:45it later or use it later. Okay? In
  432. 18:49simple words, a variable is like a
  433. 18:51container that holds a value. If you
  434. 18:54don't understand anything, you can just
  435. 18:56write this definition: a variable is
  436. 18:58like a container that holds a value.
  437. 19:01Like, what is Rahul? A value. So who is
  438. 19:05holding it? Name, this "name" is
  439. 19:08holding it. Similarly, age is a value.
  440. 19:1120 is a value. And who is holding it? "
  441. 19:14Age" is holding it. Just like we
  442. 19:17studied that we have identifiers to
  443. 19:18provide a name to something, so what
  444. 19:20was that? That was an identifier.
  445. 19:23Similarly, we have our variables. So
  446. 19:26what are variables? They are something
  447. 19:28that holds any value of ours. So what
  448. 19:31do we call that? Variables. Like name,
  449. 19:33age, marks, these are all......
  450. 19:35variables. We can use these to print
  451. 19:38them later on. Like if we write print
  452. 19:41name, then it will print Rahul. Print
  453. 19:43age, then it will print age; print
  454. 19:44marks, then it will print marks. We
  455. 19:47create Python variables when we assign
  456. 19:49a value to them. When we need to assign
  457. 19:52a value, like the value Rahul, we need
  458. 19:54to assign it, so what do we do? We
  459. 19:56create it. We don't need to declare the
  460. 19:59data type separately. It's not like we
  461. 20:01have to declare the data type of Rahul
  462. 20:03here. Like if it's 20, we don't have to
  463. 20:06write int to declare it or write float
  464. 20:08to declare it. We don't even have a
  465. 20:10need to do that. To write its data type
  466. 20:13. A variable can store different types
  467. 20:16of data. A variable can store different
  468. 20:18types of data. Alright? What are these?
  469. 20:21These are your variables. Now this is a
  470. 20:23most, most important topic, that what
  471. 20:26are operators? Basic operators. We have
  472. 20:29to study operators. How many operators
  473. 20:30are there in your Python? I have
  474. 20:32covered all the operators in detail for
  475. 20:34you. So what are operators? They are
  476. 20:37special symbols or keywords that we use
  477. 20:39to perform our operations. Like, what
  478. 20:43is the value of a? It is 10. The value
  479. 20:45of b is five. Print a + b. Alright? So
  480. 20:50this plus, what is it? We must have
  481. 20:52studied this normally too. This is an
  482. 20:54operator. Here, plus is an operator
  483. 20:57which we use to add a and b. So
  484. 21:00similarly, we have multiple operators.
  485. 21:02Which ones? Arithmetic, comparison,
  486. 21:05assignment, logical, and bitwise are
  487. 21:07all our operators. Now, inside this
  488. 21:10arithmetic, there are many operators as
  489. 21:12well. Like the plus ones, plus, minus,
  490. 21:14multiply, which are our BODMAS ones.
  491. 21:17Alright? These all come under what?
  492. 21:19They come under arithmetic operators.
  493. 21:21Alright? Like plus. What does this plus
  494. 21:24do? It adds. What does minus do?
  495. 21:26Subtract, multiplication. This division
  496. 21:28, this modulus. This addition, like in
  497. 21:31the example 10 + 5, so what result will
  498. 21:33it give? 15; in subtraction, 10-5, what
  499. 21:36result will it give? 5; 10*5 is 50. Now
  500. 21:39what will this give? Like you divided
  501. 21:4210 by five, 5*2 = 10, right? Now this
  502. 21:47two is given by your division operator.
  503. 21:51What does this give? The modulus one
  504. 21:53gives the remainder. Like you divided
  505. 21:5610 by three. 3*3 = 9, so 1 remains.
  506. 22:00This remainder is given by the modulo
  507. 22:02operator, which provides the remainder,
  508. 22:04while division gives the quotient.
  509. 22:07Alright? In the output, these are your
  510. 22:09arithmetic operations. Next, as we just
  511. 22:11saw in the example, what does this do?
  512. 22:14For instance, the value of a is 10. b
  513. 22:16is 3. Now we want to perform arithmetic
  514. 22:18for addition. So, print a + b. It will
  515. 22:21give 13 as the answer. Similarly, do
  516. 22:24a-b for 7, a*b for 30, so this is your
  517. 22:27first one. Now comes the second,
  518. 22:30comparison operators. We use comparison
  519. 22:32operators to compare two values. You
  520. 22:35will have two values. You will compare
  521. 22:37them. Like checking if both values are
  522. 22:40equal. To check for equality, we use
  523. 22:42the double equals sign. So for equal to
  524. 22:45, is five double equal to 5? If it is
  525. 22:48true, it will show true. We use not
  526. 22:50equal to. Meaning, is 5 equal to 3? No.
  527. 22:53So it will return true for that. Then
  528. 22:56we compare two values, five and three,
  529. 22:58using greater than. Similarly for five
  530. 23:00and three, use less than and less than
  531. 23:02or equal to, and what do you need to
  532. 23:04remember? You just need to remember one
  533. 23:06equal to, one less than, and one
  534. 23:08greater than. This one is for equal.
  535. 23:10Its opposite is not equal to. Similarly
  536. 23:12, do the same for less than. Less than
  537. 23:14or equal to and greater than, you only
  538. 23:16need to remember these three. According
  539. 23:18to these, your others will be covered.
  540. 23:21For example, the value of a is 10 and b
  541. 23:24is 5, so is a > b, meaning is 10 > 5?
  542. 23:28Then it becomes true. Similarly, is 10
  543. 23:32= 5? Then false will be printed. Next
  544. 23:36comes your assignment operators. We use
  545. 23:39assignment operators to assign or
  546. 23:41update values. For example, what is the
  547. 23:45operator? Equal. x = 10, we assigned
  548. 23:48this value of 10 to what? To x. So now,
  549. 23:52what is the value of x? 10. Similarly,
  550. 23:55plus equals is an assignment operator.
  551. 23:57Now, what happens in plus equals? Write
  552. 24:00x + = 10, 5, or 15. So now, what does
  553. 24:04this mean? x = x + 15, meaning 15 is
  554. 24:09being added to this x and the value is
  555. 24:12being stored back into x. Like, now I
  556. 24:17wrote x-= 5, right? What does this mean
  557. 24:20? x-5 is happening. x and it is
  558. 24:24subtracting 5. But in what is that
  559. 24:26value being stored? It is coming out
  560. 24:28equal to x itself. It is denoted like
  561. 24:30this. Look, multiply = x*= 5 means x =
  562. 24:35x*5, that is what it implies. Like if x
  563. 24:41= 10 and we need to do x + = 5, then
  564. 24:43tell me what will be the value of x? So
  565. 24:47right now the value of x is 10. Then we
  566. 24:49did x = x + 5, so what will the answer
  567. 24:52be? 10 + 5, which is 15. Okay? Okay?
  568. 24:57These are your assignments. Next come
  569. 24:58your logical operators. Why do we use
  570. 25:01logical operators? To combine. There
  571. 25:03are multiple conditions. There are two
  572. 25:05conditions or multiple. What do you
  573. 25:07have to do to them? Combine them. So
  574. 25:09how many are there? There are three
  575. 25:11main logical operations. Which ones?
  576. 25:13AND, OR, NOT. AND means both conditions
  577. 25:17must be true. Like I wrote any true
  578. 25:20condition here. I wrote true here as
  579. 25:23well and put AND in the middle. This
  580. 25:26means this condition must also be true
  581. 25:28and when this condition is true, only
  582. 25:30then will your answer be true; if this
  583. 25:32is true and this is false and then you
  584. 25:34used AND, the answer will be false.
  585. 25:37Both your conditions must be true. Then
  586. 25:39your answer will be true. And for OR,
  587. 25:42if at least one condition is true, what
  588. 25:44will your answer be? It will be true.
  589. 25:48NOT means just reverse it. Suppose I
  590. 25:51wrote that x = 5, now we have to make
  591. 25:54it not equal. We have to negate it. So
  592. 25:57x is not equal to 5, then what happens?
  593. 26:00There are three logical ones: AND, OR,
  594. 26:02NOT. Both conditions are true. Even if
  595. 26:05one condition is true, it works, but in
  596. 26:07this one what will happen? It will be
  597. 26:09reversed. For example, age = 20, what
  598. 26:13is the value of age? Print 20. Age is >
  599. 26:1818, meaning print only when the age
  600. 26:20value is greater than 18. 18. So is age
  601. 26:24greater than 18? Is 20 greater than 18?
  602. 26:26Yes, this is true. Now check the next
  603. 26:29one. We used an AND operator here; age,
  604. 26:31meaning 20, is 20 less than 30? Yes,
  605. 26:34this is also true. This also came out
  606. 26:36true. This also came out true. We
  607. 26:38combined both with AND, so what will
  608. 26:39the answer be? It will be true. Here,
  609. 26:41both conditions are true. So what will
  610. 26:43your output be? It will be true. Next
  611. 26:47are bitwise operators. What are bitwise
  612. 26:49operators? What do they do? They work
  613. 26:52on the binary representation. Binary
  614. 26:55means they work on zero and one. Who?
  615. 26:58Your bitwise operators. They work on
  616. 27:00zero and one. For example, the value of
  617. 27:03a is five, and b is three. Now you have
  618. 27:06to print A and B. So, for binary, you
  619. 27:08need to convert five into binary. And
  620. 27:10after that, three as well. There is a
  621. 27:12short trick for this. Write it like
  622. 27:14this. 2 power 0, 2 power 1, 2 power 2,
  623. 27:172 power 3; this means if you want to
  624. 27:19convert to 0, 1, I am telling you how
  625. 27:22to do that. So, 2 power 0 means one, 2
  626. 27:26power 1 is 2, power 2 is 4, and 2 power
  627. 27:293 is 8. You get 8, 4, 2, 1, and the
  628. 27:33series continues: 16, 32, and so on.
  629. 27:36Now, what do you need to do? To make
  630. 27:40five, take any two or more numbers from
  631. 27:438, 4, 2, 1, and what do you do with
  632. 27:45them? Adding those numbers should give
  633. 27:50you five. Will adding eight and four
  634. 27:51give you five? No. Not four and two, no
  635. 27:54. Not two and one, no. But if you add
  636. 27:57four and one, you get five. So, adding
  637. 28:00four and one gives five. This means
  638. 28:02select these two numbers. Write one
  639. 28:03there. Select this number, write one
  640. 28:05here, and put zero in the other places.
  641. 28:07So, what does it become? 0 1 0 1, so
  642. 28:09five is equal to what? 0 1 0 1, that is
  643. 28:131 0 1, okay? Here, zero below 1 0 1,
  644. 28:17now do the same for three. Again, write
  645. 28:208 4 2 1, and pick any two or more
  646. 28:22numbers that add up to three. So, two
  647. 28:26and one, put 1 1 and 0 in the remaining
  648. 28:28places, which means 0 1 1. Now what to
  649. 28:31do? Perform the AND operation and solve
  650. 28:33. Okay? This is your bitwise operation.
  651. 28:36Next is your topic. Your operators are
  652. 28:39now complete. Now let's come to blocks:
  653. 28:42what are blocks in Python? So, what are
  654. 28:45blocks? They are a group of statements.
  655. 28:48Meaning these statements form a group,
  656. 28:49and we have made it into what? We made
  657. 28:52a block. Which we treat as a single
  658. 28:54unit. This becomes unit one. In Python,
  659. 28:57blocks are mainly identified using
  660. 28:59indentation. We studied indentation,
  661. 29:02right? Lines and indentation. We cover
  662. 29:05it by using that. Unlike languages such
  663. 29:08as C or Java, Python doesn't use them.
  664. 29:10What do C and Java use? They use curly
  665. 29:13braces. It does not use those for
  666. 29:15blocks. If we had some C code, what
  667. 29:18would we do? From these curly braces to
  668. 29:21here. We would know that this is a
  669. 29:23block. But in Python, it is not like
  670. 29:26that. So what do we do? In this, we
  671. 29:30define blocks as a single unit. For
  672. 29:33example, if age is greater than 18,
  673. 29:35then here: A colon, and it
  674. 29:37automatically tabs here. Print "You are
  675. 29:40an adult" and also print "You can vote.
  676. 29:42" Now here are two indented prints. One
  677. 29:47is this, and one is that. This if, this
  678. 29:49print, and this print too. Are from the
  679. 29:52if block. So what does this become?
  680. 29:54This if is a block. And what are its
  681. 29:56parts? This and this, meaning what does
  682. 29:58this become? It becomes a complete
  683. 30:00statement. If this condition is true,
  684. 30:02then this part will also execute. And
  685. 30:04this too, so this becomes block one.
  686. 30:06And what do we call this block? A
  687. 30:08Python block. Okay? Let's see the next
  688. 30:11one. A Python block generally starts
  689. 30:14after a statement. When does a Python
  690. 30:17block generally start? After a
  691. 30:19statement ending with a colon. After
  692. 30:22the colon, like an if condition or any
  693. 30:24condition, statement one and statement
  694. 30:26two follow. So this colon indicates
  695. 30:30that a new block is about to start. As
  696. 30:35we saw in the example, check this:
  697. 30:37marks = 75, if block runs, print "pass"
  698. 30:40, otherwise in else, print "fail". So
  699. 30:44you checked this colon. The print after
  700. 30:47this colon and the other print formed
  701. 30:49this. A new one, this tells you that
  702. 30:53the block starts here and your block
  703. 30:54one is formed. Similarly, you checked
  704. 30:57the else part. A block starts from this
  705. 31:00colon, and this became your block two.
  706. 31:03So this is your block. Next come your
  707. 31:06data types. What are data types? A data
  708. 31:09type tells Python what kind of data a
  709. 31:11variable contains and what operations
  710. 31:13can be performed on the data. What does
  711. 31:16a data type tell? It tells Python what
  712. 31:19kind of data a variable can contain.
  713. 31:25Suppose I wrote marks = 10, now it will
  714. 31:27tell what type this is, is marks an int
  715. 31:29or a float? Meaning, will the data
  716. 31:35stored here be decimal or integer? So
  717. 31:38what is that? That is your data type.
  718. 31:40Int, float, boolean, set, and tuple,
  719. 31:43what are these all? These are your data
  720. 31:46types. So let's look at the first one.
  721. 31:48The first one is your integer data type
  722. 31:50, int. An integer is a whole number
  723. 31:52without a decimal point. Integer means
  724. 31:54there is no decimal point. So like, a =
  725. 31:5720, marks = 10, now what used to happen
  726. 32:00here? We studied in C that if you want
  727. 32:03to write age and it is an int type, you
  728. 32:04had to write int here. You had to
  729. 32:07define its data type, that this age is
  730. 32:09of integer data type. Or that these
  731. 32:12marks are of float type. But what will
  732. 32:15Python do? It will automatically
  733. 32:17understand that if 20 is written here.
  734. 32:19Now there is no decimal in it, so it
  735. 32:21will automatically decide that it is an
  736. 32:23int type. If I write 10.5 here, now if
  737. 32:25I put five here. Then it will
  738. 32:27understand what its data type is. Its
  739. 32:29data type is float. So what did this
  740. 32:31become? It detects it automatically.
  741. 32:34Similarly, there is float. Float for
  742. 32:36decimal numbers, suppose you wrote this
  743. 32:39value 0.50 here, so it automatically
  744. 32:41detected it. It is a float data type.
  745. 32:43Alright? That's how it is. Now comes
  746. 32:45boolean. What is boolean? It has two
  747. 32:47values. Inside a boolean, it will
  748. 32:49either come as true or false. It is
  749. 32:51mainly used for conditions or
  750. 32:53decision-making. Like check if is_pass
  751. 32:55is true. Is_raining is false. So this
  752. 32:58is in boolean type. It works only on
  753. 33:00true/false. Next comes list. What is a
  754. 33:03list? It is an ordered and changeable
  755. 33:05collection of your values. Like you
  756. 33:08provide values inside marks. Changeable
  757. 33:11values like 80, 75, what does it mean?
  758. 33:13It became an ordered set. It became a
  759. 33:15set of values inside a list. It is not
  760. 33:17like that. You didn't just write 80.
  761. 33:19You have provided multiple values. Now
  762. 33:21it is not necessary that they are the
  763. 33:23same value. 80, 75, 90, same data type.
  764. 33:26It can be like this. You gave the first
  765. 33:28value as integer. Then you gave a
  766. 33:29string. Then you gave a float. So you
  767. 33:32can provide this inside a list too.
  768. 33:34Next comes your fifth, tuple. What is a
  769. 33:37tuple? A tuple is an ordered but
  770. 33:40unchangeable collection. Meaning it
  771. 33:42won't change later. Like numbers = 10,
  772. 33:4620, 30, or 40, what are all these?
  773. 33:49These are tuples. If it is created,
  774. 33:52then we cannot change it normally.
  775. 33:54Whereas we could change a list. We
  776. 33:57cannot change a tuple. It is
  777. 33:59unchangeable. Next comes your numeric
  778. 34:03data type. So, what are these numeric
  779. 34:05data types? We just studied them. Look,
  780. 34:07we just studied data types, I'll show
  781. 34:09you here. We just covered our data
  782. 34:12types. These are the data types. We
  783. 34:14studied five types. Int, float, bool,
  784. 34:17set, tuple. Okay? Similarly, what do we
  785. 34:20have? Numeric data types. Meaning,
  786. 34:23those that work on values. So look, int
  787. 34:25also has values. 1 2 3 4, same with
  788. 34:28float. And one more gets added to this,
  789. 34:31complex. These two will remain the same
  790. 34:33inside it. But one more will be added,
  791. 34:36your float. So these are your three
  792. 34:39types. Two, one is int, float, and one
  793. 34:41is complex. Just one extra is added,
  794. 34:44complex. Okay? Now, Python has several
  795. 34:48numeric data types to store data. But
  796. 34:51which ones are the main ones? Int,
  797. 34:53float, complex. Int contains integer
  798. 34:56data types. Float contains decimal ones
  799. 34:58. We have already covered these two.
  800. 35:00Complex contains complex numbers. Like
  801. 35:045i + 3j, so what are these? These are
  802. 35:08your complex numbers. These are also a
  803. 35:11type of what? Data type. Unlike
  804. 35:13languages, this is the most important
  805. 35:15point. Unlike languages such as C or
  806. 35:17Java, Python doesn't require it. Like
  807. 35:20what happens in C and Java? If you want
  808. 35:22to write age, you define its data type
  809. 35:24for 20. For this, float. In this, there
  810. 35:27is nothing like that. What do you have
  811. 35:29to write? Simply write age is 20 and
  812. 35:31price is 50. Python will automatically
  813. 35:34determine that this age is what? It is
  814. 35:37of integer type because it will check
  815. 35:39with 20, and what type is price? Its
  816. 35:42data type is float because it detects
  817. 35:44it automatically. Okay? This is your
  818. 35:47most important point. Let's see the
  819. 35:49next one. Next comes yours. We have
  820. 35:53already covered this. What is an
  821. 35:55integer? It is for storing. Age 20, all
  822. 35:57these. Here, age, marks, and temp are
  823. 36:00what? These are integer variables. We
  824. 36:02can check their data type. According to
  825. 36:05type, we will write age 20 and print
  826. 36:07type of age. So in output, it will show
  827. 36:10you int. Okay? Next comes your floating
  828. 36:14point. What do we use float for storing
  829. 36:16? Decimal points. Like price,
  830. 36:19percentage. We can also check this
  831. 36:21using type. You will write print and in
  832. 36:23type write to show the type of price.
  833. 36:25So it will tell you the answer, it will
  834. 36:27be float, that it is a float data type.
  835. 36:30Similarly, you have complex numbers
  836. 36:32which consist of. One real part and one
  837. 36:35imaginary part. There are two parts to
  838. 36:38a complex number. Okay? Python uses J
  839. 36:41for the imaginary part. Like 3 + 4j, so
  840. 36:45this three, what is it? It is your real
  841. 36:49part and this four j is your imaginary
  842. 36:51part. So what did we conclude from this
  843. 36:54, that there are two parts. One real
  844. 36:56and one imaginary. The real part is
  845. 36:59this three and the j is what represents
  846. 37:01your imaginary part. We can also check
  847. 37:04its type. The same way we have been
  848. 37:06doing. Suppose this is your equation.
  849. 37:10Now you want to check what data type
  850. 37:12this Z is? So what will you write?
  851. 37:14Print, and print what? Its type, that
  852. 37:16is type of Z, so what will the output
  853. 37:18be? Which one is it? Complex. Okay? The
  854. 37:21output will appear. So these were your
  855. 37:24three data types. Now let's come to
  856. 37:27type conversion of numeric data. You
  857. 37:29need to change them. Meaning, which
  858. 37:31ones were the numeric ones? There were
  859. 37:33three: int, float, and complex, so how
  860. 37:35will you convert from int to float or
  861. 37:38float to complex. So how will you
  862. 37:40convert them? Suppose your data type is
  863. 37:42integer. But what do you want to do?
  864. 37:44You want to convert it into float, so
  865. 37:46you will put the value directly. Like,
  866. 37:48what is your x? 10, now y, what do you
  867. 37:51want to convert it into? You want to
  868. 37:55convert this into float, so you will
  869. 37:57take a separate variable y, inside it
  870. 37:59you will write float of x, and print y.
  871. 38:02Now, similarly, if you want to convert
  872. 38:04from float to int, what will you do?
  873. 38:06Suppose this is a float and you want to
  874. 38:08convert it into what? Int, so you will
  875. 38:11take the same variable and whatever you
  876. 38:13want to convert it into (int), you will
  877. 38:15write int (x) and print y. Now, if you
  878. 38:19had to convert from integer to complex?
  879. 38:21This x is an integer. Now what do you
  880. 38:23want to convert it into? Into complex.
  881. 38:25So, take y or take z. You took this,
  882. 38:28put x into the complex, and printed z.
  883. 38:31Then your output will appear. Okay? Now
  884. 38:34, here come your most important coding
  885. 38:36questions. You must not skip these 12
  886. 38:39to 14 questions. These 12 questions are
  887. 38:42your most, most important questions.
  888. 38:45These have appeared in PYQs or there
  889. 38:46are chances they might come this time.
  890. 38:49So, this is basic. What is this for you
  891. 38:51? This is basic. When you write any
  892. 38:53code, it is the first program. You have
  893. 38:56to write a Python program in which you
  894. 38:57will print Hello World. Okay? So, the
  895. 39:00first code is your basic one. You will
  896. 39:02write print. Directly Hello World. What
  897. 39:04will the output be? Hello World. It's
  898. 39:06the most basic, simple, and easiest.
  899. 39:08Now, we will gradually increase the
  900. 39:10level from basic. Now comes the second,
  901. 39:12you have to add two numbers. When do
  902. 39:14you add two numbers? When you have
  903. 39:16those two numbers, five and three. You
  904. 39:18have to add them. So, first of all, you
  905. 39:20must have five and three. So, you will
  906. 39:22ask the user for any two numbers, "give
  907. 39:24me any two numbers." They will type it
  908. 39:26with the help of the keyboard. Like you
  909. 39:27see, when you write code, it says "
  910. 39:29enter two numbers." So, what does the
  911. 39:32user do? They provide those two numbers
  912. 39:34. Then they press five and three on the
  913. 39:36keyboard, and then your answer comes.
  914. 39:37So, you will take those two numbers
  915. 39:39from the user. So, how do you take
  916. 39:41those numbers? A is a number. B is a
  917. 39:43number. This number is A. The user will
  918. 39:45provide it. This is B. You will write
  919. 39:47int because what type is it? Of int
  920. 39:49type. You are taking input from the
  921. 39:51user. So input, and it should say "
  922. 39:53enter first number." Similarly for B,
  923. 39:55write int. Input "enter second number."
  924. 39:57Now what to do? You have to add both
  925. 40:00and store them in another variable, c
  926. 40:03or 'sum', in these... 'a' +...Sum =, a
  927. 40:06+ b, so sum = a + b. You will add both
  928. 40:10and put them into 'c' or 'sum'. Print
  929. 40:13the 'sum', whatever the answer is. This
  930. 40:16'sum' that came, print it, and how to
  931. 40:19print it so it says 'sum = 8'. So, 'sum
  932. 40:23equals to' should appear in the text.
  933. 40:25Whatever should appear as it is, write
  934. 40:27it inside curly braces or double quotes
  935. 40:29. This is also easy. Take a number 'a'
  936. 40:32from the user, take 'b', and make the
  937. 40:34sum 'a + b'. All right? And print the
  938. 40:37sum. What will be displayed now? First,
  939. 40:39this will be displayed on the screen. "
  940. 40:40Enter first number," then "Enter second
  941. 40:42number" will be displayed. And then it
  942. 40:45will be solved, and "Sum = 30" will
  943. 40:47appear. All right? Now comes the third.
  944. 40:52Third is to find the square and cube of
  945. 40:54any number. So, first you take a number
  946. 40:56, like if you want to do it for five,
  947. 40:58you take five from the user. So, same
  948. 41:00as this, n = int input "Enter a number"
  949. 41:03. Now the user has entered five. Now
  950. 41:05what is the formula for a square? Look,
  951. 41:08if you want the square of five, or any
  952. 41:10number, you multiply that five by five?
  953. 41:13You multiply five by five, right? You
  954. 41:16do it like this to find the square of
  955. 41:18five, and how do we write this square?
  956. 41:20Whatever the square of someone is, it
  957. 41:22means 5 If 2 is written like this, it
  958. 41:27means 5 squared. So? Multiply n by two.
  959. 41:31If you want to find the square, you do
  960. 41:33it by two, right? If you want to find
  961. 41:35the square, but if you had to find the
  962. 41:36cube, how would you write the cube of 5
  963. 41:38? 5 3. So to find the cube, this is
  964. 41:43basically once multiplied, so n would
  965. 41:45be multiplied by three. But this is not
  966. 41:48multiplication, this is power; meaning,
  967. 41:50print that number's power of two as the
  968. 41:52square and print that number's power of
  969. 41:54three as the cube. So what will the
  970. 41:57output be? It will say "Enter a number,
  971. 42:00" you will enter the number five, the
  972. 42:02answer will come: square = 25 and cube
  973. 42:05= 125. The fourth question is, you have
  974. 42:07to check if it is an even number or an
  975. 42:10odd number. Take any number from the
  976. 42:13user and then check whether it is even
  977. 42:15or odd. So, n equals, took the number
  978. 42:18from the user, now how to know if it is
  979. 42:20even or odd? You divide that number by
  980. 42:22two; if the remainder, this is the sign
  981. 42:24for the remainder. If your remainder
  982. 42:27comes out to be zero, then what kind of
  983. 42:29number is it? Even. If it doesn't come
  984. 42:32out to be zero, then it's odd. So what
  985. 42:34do you do? If you divide it by two.
  986. 42:37Equals, equals, if it comes out to be
  987. 42:39zero, then print even number. If it
  988. 42:41doesn't come out to be zero, then print
  989. 42:43odd number. Now you have to find the
  990. 42:45greatest number. You have three numbers
  991. 42:49, A, B, and C. Check which of the three
  992. 42:51numbers is the greatest. So, what will
  993. 42:55you do? First of all, you need to do
  994. 42:58what with those three numbers? You need
  995. 43:00to enter them. A number A, B, and C.
  996. 43:03You entered all three numbers from the
  997. 43:05user, as input. Now, check A and B
  998. 43:09together to see if A is greater than B?
  999. 43:13Check it. A should be greater than B
  1000. 43:15and also greater than C. If A is
  1001. 43:17greater than B and also C. Then
  1002. 43:18directly write that A is the greatest.
  1003. 43:20Suppose you have an eight, a five, and
  1004. 43:23a six. You checked this is A. You
  1005. 43:25checked it, it is greater than five. It
  1006. 43:27is also greater than six. If it is
  1007. 43:29greater, then what is your eight? It
  1008. 43:30became the greatest. So, the same
  1009. 43:32condition is applied. Check A. Is A
  1010. 43:34greater than both B and C? If it is
  1011. 43:37greater, then print it. A is greater.
  1012. 43:39Now, if it is not, then what do you
  1013. 43:41check? Take B. Check B. Is B greater
  1014. 43:44than A and C, all of them? You took B.
  1015. 43:49This is A, this is B, and this is C.
  1016. 43:51Here is 8, here is five, here is six.
  1017. 43:54Now, check B. Is it greater than five,
  1018. 43:57eight, five, and six? If it is greater,
  1019. 44:00then print B. Okay? Greatest is B. But
  1020. 44:03if neither A nor B is greater, then
  1021. 44:05which one will be the greatest? Without
  1022. 44:07a condition, C becomes the greatest.
  1023. 44:10Okay? Look, let's see with an example.
  1024. 44:16Here we have 5, 3, 8; you checked
  1025. 44:18according to the first condition, is 5
  1026. 44:20greater than both of these? No. It went
  1027. 44:24to the second elif. Now you checked, is
  1028. 44:273 greater than both A and C? No. In
  1029. 44:30else, without checking the condition,
  1030. 44:32just say C is the greatest. Eight is
  1031. 44:34the greatest. So, that's how we check.
  1032. 44:37Next, check this. Whether the number is
  1033. 44:40positive, negative, or zero. So first,
  1034. 44:42you will take that number from the user
  1035. 44:44. If a number is greater than zero,
  1036. 44:45then if that number is greater than
  1037. 44:47zero, then what is that number? It is a
  1038. 44:50positive number. So if that number is
  1039. 44:53compared to what? Smaller than zero, if
  1040. 44:55that number is greater than zero, then
  1041. 44:57we know it's positive. But if a number
  1042. 44:59is what compared to zero? If it is
  1043. 45:01smaller, then we know it is negative.
  1044. 45:03If it is zero, then print zero. Next
  1045. 45:06comes checking for a leap year. So,
  1046. 45:08which one is a leap year? If a number
  1047. 45:11is divisible by 400, or here the
  1048. 45:13condition of 'or' comes in. If a number
  1049. 45:16is divisible by 400, and it is
  1050. 45:18divisible by four. It is divisible by
  1051. 45:21four but not divisible by 100. Then
  1052. 45:24what should it be? The year should be
  1053. 45:25what with respect to 400? Completely
  1054. 45:29divisible, or it should be divisible by
  1055. 45:31four but not by 100. So that is your
  1056. 45:35leap year condition. Divisible by 400,
  1057. 45:37divisible by four. It should be
  1058. 45:40divisible by either one of these, or
  1059. 45:42four, but it must not be divisible by
  1060. 45:44100. If this is the case, it is a leap
  1061. 45:47year, otherwise, it is not. Next, you
  1062. 45:52have to print a multiplication table,
  1063. 45:54like 5*1 = 5, so you print a table for
  1064. 45:56any number. Suppose for 12, 5, or 13,
  1065. 46:00you take the number for the table from
  1066. 46:03the user. Then check using 'for i in
  1067. 46:05range', we will use a for loop. From
  1068. 46:08one to 11, meaning it starts from one
  1069. 46:10and ends at 10. Now what will you do?
  1070. 46:13Print the number taken, which is n.
  1071. 46:15This will print, so it becomes n. Into
  1072. 46:18cross multiply, n into, then i should
  1073. 46:21come. Meaning the value should keep
  1074. 46:22increasing. 1, 2, 3, 4, i, then equals
  1075. 46:26comes. And what is this? What is being
  1076. 46:28multiplied? n and i. n*i Right? So this
  1077. 46:33is how your multiplication table works.
  1078. 46:36Next comes finding the factorial. Find
  1079. 46:38the factorial of a number. So let's see
  1080. 46:41how we do that. So let's look at the
  1081. 46:43factorial. What happens in a factorial?
  1082. 46:45If you want to find the factorial of
  1083. 46:47any number, suppose you want the
  1084. 46:48factorial of six, what do you do? You
  1085. 46:50write six as it is. *5*4*3*2*1, how
  1086. 46:53long do you keep doing this? Until one,
  1087. 46:58until the end. Exactly. Right? Meaning
  1088. 47:00you keep multiplying from one to that
  1089. 47:02number. First of all, what will you
  1090. 47:04take? You will take n. Meaning you will
  1091. 47:06take that number as input. You will
  1092. 47:08create a variable 'fact' and insert the
  1093. 47:10value one into it. Now you will apply
  1094. 47:14the same for loop from one up to n + 1.
  1095. 47:17Now look here, we applied the loop up
  1096. 47:19to n + 1. Meaning, we applied a loop up
  1097. 47:22to the value we took. Right? And what
  1098. 47:25did we do after that? fact = fact*i.
  1099. 47:28What is the value of fact right now?
  1100. 47:30One. And what is the value of this one?
  1101. 47:33One. Okay? How much will this also be?
  1102. 47:36One. That is how you will do it. After
  1103. 47:38that, you will print the factorial. And
  1104. 47:40how long will this loop run? It will
  1105. 47:41run until it becomes n + 1. For example
  1106. 47:44, you took the number six, to find the
  1107. 47:46factorial of six. So, what will you do?
  1108. 47:49You will run the loop from one, and 6 +
  1109. 47:511 becomes how much? Seven. So it will
  1110. 47:53run up to seven. Meaning the loop will
  1111. 47:55run from one to six. And it will print
  1112. 47:57the value up to six. Now, how will it
  1113. 47:59do that? What is the value of fact? It
  1114. 48:01was one in the beginning, and what is
  1115. 48:03the value of i in the beginning? It is
  1116. 48:05one. So 1*1, how much did you get? One.
  1117. 48:08This last one has arrived. After that,
  1118. 48:10what is the value of i now? Two. Now 2*
  1119. 48:13, what is the value of fact right now?
  1120. 48:15Its value has become one. Now how much
  1121. 48:17did it come to? Two. Now in the next
  1122. 48:19turn, 3*1, 3; in this way, the value of
  1123. 48:21fact will keep increasing and you will
  1124. 48:24keep multiplying 5*4. Likewise, we have
  1125. 48:27reverse. You have to do a reverse.
  1126. 48:28Suppose you have any number. Your
  1127. 48:32number is 1 2 3, this is your number.
  1128. 48:34Now you have to reverse it. You want to
  1129. 48:37make it 3 2 1, so you need this number.
  1130. 48:39You need this number and you need this
  1131. 48:41number. So what will you do? First of
  1132. 48:43all, you took input from the user. They
  1133. 48:45wrote 1 2 3, that is 123. Now you took
  1134. 48:48a reverse variable. Inside that, we
  1135. 48:50inserted a zero value. Now check n. Is
  1136. 48:53n greater than zero? If it is greater
  1137. 48:55than zero, that means it is a positive
  1138. 48:57number. Then what should you do with 10
  1139. 48:59? Divide it, and how should you divide
  1140. 49:01it? Using the modulo operator. Look, I
  1141. 49:04told you that you also have to keep
  1142. 49:06checking why you need to do the modulo.
  1143. 49:09Look, this is the part where the
  1144. 49:10remainder is left. It writes down the
  1145. 49:13remainder that is left. So what will we
  1146. 49:15do? It is 1 2 3. Dividing it by what?
  1147. 49:19By 10. So we divided by 10. 10*1 = 10,
  1148. 49:22two remained. Then after that, three.
  1149. 49:2510*2 = 20. Now what is left here? The
  1150. 49:27remainder is three. So this three,
  1151. 49:30which is the starting number at the end
  1152. 49:31, will be extracted. This three is out,
  1153. 49:35which you have written down. Look, this
  1154. 49:37number is being extracted using this
  1155. 49:39modulo. In 1 2 3, the last number three
  1156. 49:41is extracted. It arrived at the first
  1157. 49:43one. Now what to do? Do reverse equals
  1158. 49:46to reverse*10 plus digit. Now reverse
  1159. 49:49was zero. What is in your reverse? Zero
  1160. 49:52. Now you need to store this reverse
  1161. 49:55into reverse equals reverse. So what is
  1162. 49:58your reverse? 0, so 0*10 plus what was
  1163. 50:02your digit? It was three. The remainder
  1164. 50:06that came was three, so reverse = 0*10
  1165. 50:09makes 0 + 3, three you got from here.
  1166. 50:13Okay? Your first number came as three.
  1167. 50:15Now what to do? Do n = n/10. Meaning,
  1168. 50:18what to extract from this? Just your
  1169. 50:21this number, meaning from 1 2 3, now
  1170. 50:23what do you extract after dividing? 10*
  1171. 50:261 = 10, this was coming, right, 12? So
  1172. 50:29this 12 is left. From here 12 is left,
  1173. 50:32just 12 is left. Now you went back,
  1174. 50:35divided this 12 again by 10. When you
  1175. 50:37divide 12 again by 10, then 10*1 = 10,
  1176. 50:40again what is left? Two. Earlier three
  1177. 50:43was left, now two is left. So your two
  1178. 50:45numbers came as 32, now this two is
  1179. 50:47here, now you solved this equation/
  1180. 50:49question. After that, came back again.
  1181. 50:51Now you divided this 12 by what? By 10.
  1182. 50:54So what is remaining? One. Now went to
  1183. 50:56one, so 3 2 1 is left for you. What
  1184. 50:58does this mean? What do you have to do?
  1185. 51:01You have to divide 1 2 3 by 10 once for
  1186. 51:03the remainder, whatever that number is.
  1187. 51:06Okay? Here you will be left with 10 2 3
  1188. 51:0920 and 3, suppose this is left. Now you
  1189. 51:14have to take this number once. Take
  1190. 51:16this one once. Okay? When you take this
  1191. 51:20, you have to store that number in
  1192. 51:21reverse, and with this, you keep making
  1193. 51:23that number smaller. So this is your
  1194. 51:27reverse. Now comes palindrome. Which is
  1195. 51:32a palindrome number, the one that
  1196. 51:33remains the same even after being
  1197. 51:35reversed; you reversed it here, but if
  1198. 51:37it stays the same, then what is it?
  1199. 51:40Palindrome. So you will write the same
  1200. 51:42code, this reverse one. Okay? Wrote the
  1201. 51:44same reverse code. Reverse = 0, n
  1202. 51:46should be greater than zero. Divide by
  1203. 51:4910. Reverse*10 and this n is the same.
  1204. 51:52Now check if this answer you got in
  1205. 51:54reverse is equal to the original? The
  1206. 51:56one that was your first number 1 2 3,
  1207. 51:58are both the same? If both are same,
  1208. 52:01then print palindrome. If not, then
  1209. 52:03print not a palindrome. So, this is how
  1210. 52:06it's done. All right? For instance,
  1211. 52:09take 121. If we reverse it, it will
  1212. 52:11return 121. So, this is a palindrome
  1213. 52:13number. You need to write the reverse
  1214. 52:15code. Just add one if condition. Check
  1215. 52:18if your original number is equal to the
  1216. 52:19reverse. If it is, then it's a
  1217. 52:21palindrome; otherwise, it's not. Next
  1218. 52:25up is your Armstrong number. What is an
  1219. 52:27Armstrong number? If there is a
  1220. 52:29three-digit number, suppose 153. Now,
  1221. 52:33what do you do with it? Since it has
  1222. 52:35three digits, cube them. 1 cubed, 5
  1223. 52:37cubed, and 3 cubed. 1 cubed is one. 5
  1224. 52:41cubed is 125 and 3 cubed is 27; add all
  1225. 52:44three. If it becomes the same number
  1226. 52:48again, it is an Armstrong number. When
  1227. 52:51we add 1 + 125 + 27, it becomes 153.
  1228. 52:55And that was our original number too.
  1229. 52:57So, what is it? It is an Armstrong
  1230. 52:59number. For instance, if it were 196,
  1231. 53:03what would you do? You would cube 1,
  1232. 53:06cube 9, and cube 6; get the results,
  1233. 53:08add them, and if you get the same 196,
  1234. 53:11then what would it be? Not palindrome,
  1235. 53:14sorry, Armstrong. If not, then what
  1236. 53:16would it not be? It would not be an
  1237. 53:17Armstrong number. So, how will you
  1238. 53:19write the code? You will take a number
  1239. 53:21from the user, store n in an original
  1240. 53:23variable, and zero in sum. The same
  1241. 53:25code you had, which one? The palindrome
  1242. 53:27one; you have to write that same code,
  1243. 53:29but what do you do? Take a sum variable
  1244. 53:31instead of reverse, and here you need
  1245. 53:33to perform what on the digit? Power of
  1246. 53:35three. Look, sum plus, sum has come as
  1247. 53:37zero. Keep it that way. Now, what are
  1248. 53:39you doing? You are cubing whatever the
  1249. 53:41digit is, right? So this is how you
  1250. 53:43cube. If there were only one star, it
  1251. 53:45would mean multiply. But I told you, if
  1252. 53:48there are double stars, it means the
  1253. 53:49digit's power; it’s like digit raised
  1254. 53:51to power three. So, you will divide in
  1255. 53:54the sum exactly the same way. Like you
  1256. 53:56do in this one. Look, the code for all
  1257. 53:58three is exactly the same. What will
  1258. 53:59you do first for this one too? You will
  1259. 54:02do modulo and then divide. Similarly,
  1260. 54:04here you do modulo and divide; in the
  1261. 54:06middle line, reverse*10 plus digit
  1262. 54:08happens, and here sum plus digit to the
  1263. 54:10power of 3; I have explained the logic
  1264. 54:12for this as well. Now it's solved. Then
  1265. 54:14after that, you check if the original
  1266. 54:16and sum are the same. If they are the
  1267. 54:18same, it is an Armstrong number. If
  1268. 54:19they are not the same, then it is not
  1269. 54:21an Armstrong number. So, these are your
  1270. 54:25...These were your 12 important coding
  1271. 54:27questions that appear in PYQs or have a
  1272. 54:29high chance of appearing. So, we have
  1273. 54:33solved those. And with that, our unit
  1274. 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.