These excerpts provide a comprehensive introduction to Python programming concepts. They cover fundamental data types like numbers, strings, tuples, lists, dictionaries, and sets, explaining their properties and operations. The text also explores essential programming structures such as variables, operators, conditional statements, loops, functions (including predefined, user-defined, anonymous, and recursive), modules, packages, and exception handling. Finally, it touches upon file handling for various data formats and introduces the basics of object-oriented programming, including classes, objects, methods, inheritance, and polymorphism.
Python Basics and Data Structures Study Guide
Quiz
- Explain the concept of a variable in Python. How does Python handle data types for variables?
- What are the key differences between the core numeric data types in Python: integer, float, and complex?
- Describe the characteristics of a string in Python. What does it mean for a string to be immutable?
- Explain the concept of indexing and slicing in Python sequences (like strings, lists, and tuples). Provide a brief example.
- What are the primary differences between a list and a tuple in Python? When might you choose to use one over the other?
- Describe the structure of a dictionary in Python. How are elements accessed in a dictionary?
- What is a set in Python, and what are its key properties? How does it differ from a list?
- Explain the purpose of the if, elif, and else statements in Python. How do they control the flow of execution?
- Describe the functionality of a for loop in Python. How is it used to iterate over sequences?
- What is a function in Python? How do you define and call a function?
Quiz Answer Key
- A variable in Python is a named storage location that holds a value. Python is dynamically typed, meaning you don’t need to explicitly declare the data type of a variable; the interpreter infers the type based on the value assigned to it.
- Integers (int) are whole numbers without a decimal point. Floats (float) are numbers with a decimal point. Complex numbers (complex) have a real and an imaginary part, represented in the form a+bj.
- A string in Python is an ordered sequence of characters enclosed in quotes (single or double). Immutability means that once a string is created, its individual characters cannot be changed directly. Any operation that appears to modify a string actually creates a new string.
- Indexing allows you to access individual elements in a sequence using their position (starting from 0). Slicing allows you to extract a subsequence of elements using a start index, an end index (exclusive), and an optional step. Example: my_list = [10, 20, 30, 40]; print(my_list[1]) (output: 20), print(my_list[1:3]) (output: [20, 30]).
- A list is a mutable, ordered sequence enclosed in square brackets, allowing for element modification, addition, and removal. A tuple is an immutable, ordered sequence enclosed in parentheses, meaning its elements cannot be changed after creation. Tuples are often used for fixed collections of items.
- A dictionary in Python is an unordered collection of key-value pairs enclosed in curly braces. Each key must be unique and immutable, and it is used to access its corresponding value. Elements are accessed using their keys within square brackets, e.g., my_dict[‘key’].
- A set in Python is an unordered collection of unique elements enclosed in curly braces. Sets automatically remove duplicate entries and support mathematical set operations like union, intersection, and difference. Unlike lists, sets do not maintain the order of elements and cannot be indexed directly.
- The if statement executes a block of code if a specified condition is true. The elif (else if) statement checks an additional condition only if the preceding if or elif condition was false. The else statement executes a block of code if none of the preceding if or elif conditions were true.
- A for loop in Python is used to iterate over each item in a sequence (such as a list, tuple, string, or range) or other iterable object. It executes a block of code for each item in the sequence. Example: for item in my_list: print(item).
- A function in Python is a block of reusable code that performs a specific task. It is defined using the def keyword followed by the function name, parentheses for parameters (optional), and a colon. A function is called by using its name followed by parentheses, potentially passing arguments.
Essay Format Questions
- Discuss the importance of data structures in Python. Compare and contrast the use cases for lists, tuples, dictionaries, and sets, providing specific examples where each would be most appropriate.
- Explain the concepts of mutability and immutability in Python, focusing on how these properties affect the behavior and usage of different data types like strings, lists, and tuples.
- Describe the role of control flow statements (conditional statements and loops) in Python programming. Illustrate with examples how if/elif/else and for loops can be used to solve common programming problems.
- Discuss the benefits of using functions in Python. Explain the process of defining and calling functions, and elaborate on the concepts of function parameters and return values.
- Imagine you are developing a program to manage a small library. Describe how you might use various Python data structures (lists, dictionaries, sets, tuples) to store and manipulate information about books and borrowers.
Glossary of Key Terms
- Variable: A named storage location that holds a value in memory.
- Data Type: The classification of data that specifies which type of value a variable can hold and what types of operations can be performed on it (e.g., integer, string, list).
- Integer (int): A whole number without a decimal point.
- Float (float): A number with a decimal point.
- String (str): An ordered sequence of characters.
- Immutable: A property of an object whose state cannot be modified after it is created.
- Mutable: A property of an object whose state can be modified after it is created.
- Index: The position of an element within a sequence, starting from 0.
- Slicing: A way to extract a subsequence of elements from a sequence using a range of indices.
- List (list): A mutable, ordered sequence of items enclosed in square brackets.
- Tuple (tuple): An immutable, ordered sequence of items enclosed in parentheses.
- Dictionary (dict): A mutable, unordered collection of key-value pairs enclosed in curly braces.
- Set (set): A mutable, unordered collection of unique elements enclosed in curly braces.
- Conditional Statement: A statement that executes a block of code based on whether a condition is true or false (if, elif, else).
- Loop: A control flow statement that allows code to be executed repeatedly (for, while).
- Function: A block of organized, reusable code that performs a specific task.
- Parameter: A variable listed inside the parentheses in the function definition.
- Argument: The actual value that is passed to a function when it is called.
- Return Value: The value that a function sends back to the caller after it has executed.
- Module: A file containing Python definitions and statements (with a .py extension).
- Package: A directory that contains multiple Python modules and an __init__.py file, used to organize modules.
- Identifier: A name used to identify a variable, function, class, module, or other object.
- Keyword: A reserved word that has a special meaning in Python and cannot be used as an identifier.
- Indentation: The spaces or tabs used at the beginning of a code line to define blocks of code in Python.
- Operator: A symbol that performs an operation on one or more operands (e.g., +, -, *, /, ==, >).
- Operand: The value or variable on which an operator acts.
- Expression: A combination of variables, operators, and values that evaluates to a single result.
- Statement: A complete line of code that performs an action.
- String Formatting: The process of embedding expressions inside string literals.
- Escape Sequence: A sequence of characters that represents a special character (e.g., \n for newline, \t for tab).
- Raw String: A string literal prefixed with r or R, where backslashes are treated as literal characters.
- Concatenation: The operation of joining two or more strings or other sequences together.
- Repetition: The operation of repeating a string or other sequence multiple times.
- Method: A function that is associated with an object of a particular class.
- Class: A blueprint for creating objects, defining their attributes (data) and methods (behavior).
- Object: An instance of a class.
- Recursion: A programming technique where a function calls itself.
- Anonymous Function (Lambda): A small, unnamed function defined using the lambda keyword.
- Exception Handling: A mechanism to deal with runtime errors gracefully using try, except, else, and finally blocks.
- File Handling: The process of reading from and writing to files.
- Mode (File Handling): A string indicating how a file is opened (e.g., ‘r’ for read, ‘w’ for write, ‘a’ for append).
- Pickle: A Python module used for serializing and de-serializing Python object structures.
- JSON: A lightweight data-interchange format.
- CSV: Comma Separated Values, a file format for storing tabular data.
- OS Module: A built-in Python module that provides a way of using operating system dependent functionality.
- Path (File System): A string that specifies the location of a file or directory in a file system.
Briefing Document: Review of Python Basics and Data Types
This briefing document summarizes the main themes and important ideas discussed in the provided source “01.pdf,” which covers fundamental concepts in Python programming, including variables, data types, operators, control flow (conditional statements and loops), functions, modules and packages, exception handling, file handling, and the OS module.
1. Variables and Data Types:
- Variables as Memory Allocation: A variable in Python is essentially a named memory location used to store data. Each variable has an identification number (obtained using the id() function) that represents its memory address.
- “variable is nothing but a memory allocation if it’s a memory allocation which store the data that means it release some identification number as well so we can easily find it out like a ID there is the ID function where find it out the identification number when I pass ID of a so you can see here this is the ident identification number”
- Data Type Dependency on Memory ID: The identification number (memory address) allocated to a variable can depend on its data type. Variables with different data types are likely to have significantly different ID numbers.
- “reason we change the data type so it release the memory allocation memory uh ID depend on their data type if I’m taking the different data type the that will also be number D is equal to 19 + 19.8 and check the ID of D that will be the uh different identification number it’s not only the few digit is change so lots of values change also reason we change the data type because the D is a floating data type”
- Main Categories of Data Types: Python has several built-in data types categorized as:
- Numeric: Integer (int), Complex, Float (float).
- “numeric dictionary Boolean set and sequence type where we have the main data type is a integer complex and Float integer complex and Float”
- Dictionary: Key-value pairs.
- “if I Define the same value with key value pair is equal to key value pair like 5 colon 4 uh 4 colon 7 and 9 colon 8 so if you define like this that will be considered as a dictionary”
- Boolean: True or False.
- “dictionary bullan set is also there”
- Set: Unordered collection of unique elements.
- “if I Define with the curly brasses curly brasses directly passing the values that is considered as a set”
- Sequence Type: Ordered collections:
- String (str): Sequence of characters enclosed in single or double quotes.
- “if I’m defining with a double quotes so like hello here so that’s a string data type”
- List (list): Ordered, mutable sequence of items enclosed in square brackets.
- “you define B is equal to in square bracket that will consider as a that will consider as a list”
- Tuple (tuple): Ordered, immutable sequence of items enclosed in round brackets.
- “if I Define with a round bracket that will be considered as a tle”
- Comments: The hash symbol (#) is used to denote comments in Python code, which are ignored by the interpreter.
- “what exactly the mean of this hash this hash symbol is nothing but a comment we are defining as a comment”
2. Keywords:
- Reserved Words: Keywords are reserved words in Python that have specific meanings and cannot be used as identifiers (variable names, function names, class names).
- “keyword is reserve word which used for one specific purpose fake purpose cannot be used as a identifier cannot be used as a identifier now the question is what exactly the mean of identifier let me make as a uh markdown so that markdown in the sense it will taking one statement it will not consider as a code okay normal statements so cannot be used as a identifier so what is the identifier identifier so identifier in the sense any variable name any um you know uh function name okay any variable name any function name any class name that will be consider as a identifier class name that will be considered as a identifier”
- Checking Keywords: The keyword module provides access to the list of Python keywords. keyword.kwlist returns a list of all keywords.
- “there is one module is called as keyword module keyword module keyword module and when you pass it here keyword do KW list then you’ll find it out how many keyword is available for false none true the lots of keyword is available is Lambda lots of keyword is there which is stored with a square bracket one container and that container we are calling list”
- Number of Keywords: The number of keywords can vary between Python versions. In the described context (likely Python 3.9), there are 35 keywords.
- “when I run it will showing you 30 five keyword is available okay so whenever you using any uh ideally right now I’m using the Jupiter notebook ideally so that time you can easily check it”
- Identifier Restrictions: Attempting to use a keyword as an identifier will result in a syntax error.
- “can I use uh any keyword like uh if I’m using if Okay small i f if we are using IF is equal to 8 can I define it like this no it will giving the error because because this if is reserved for only the conditional statement you can’t use as a identifier you can’t use as a normal variable”
3. Indentation:
- Block Definition: Indentation (using whitespace, typically four spaces in Jupiter Notebook and PyCharm) is crucial in Python to define code blocks, such as the body of conditional statements (if, elif, else) and loops.
- “indentation in the sense is Define the block I have some program uh like if program uh conditional statement program if a is greater than let me first Define it a is equal to 9 and B is equal to 8 and I have a program is if a is greater than b okay so in other programming language we are using the curly brasses and put inside a statements so here curly brasses is not acceptable so we have a indentation we have to use a colon after the colon it automatically taking the four space okay automatically taking the four space”
- Block Scope: Statements within the same indented block are considered part of that block. Changes in indentation signify the beginning or end of a block.
- “if I’m writing here the hello okay so if you want to Define anything like hello if I’m writing here and hi if I’m writing here and he if I’m writing here print he okay this hello hi hey yeah we can say line number 5 six 7 that’s comes in if block so defining the block we are using if uh colon and automatically taking the for space if you’re using the back space and write it down here print by so that line number nine will consider as a uh outside of the block so that bu is not in if condition okay by is not in if condition”
4. Input and Output:
- input() Function: The input() function is used to obtain user input from the console. It always returns the input as a string.
- “we have another function is input function input function will always take the input as a string”
- Type Conversion: To treat the input as a different data type (e.g., integer), type conversion functions like int(), float(), etc., must be used.
- “so cannot be multiplied with string and integer so we have another function is int so likewise other data type like int float complex we have a function as well I’m using int open the bracket and close it here when I run it it asking the question enter the value of x I’m passing here five then it will be calculate and showing the answer is five”
- print() Function: The print() function is used to display output to the console. Multiple items can be printed in a single print() statement by separating them with commas.
- “result is is nothing but your double uh statements or string and is your number so we have to separate it with a comma when I run it asking the question enter the value of x 6 so um sorry not to display uh X we have to display y let me run it again enter the value of X4 and accordingly is getting the answer is 17”
5. Operators:
- Definition: Operators are symbols that perform operations on operands (values or variables).
- “operator is nothing but the symbol which is responsible to do any operations for example I have a five + 7 so the plus is a responsible to do addition operation so this one we can say it’s operator this one is operator and five and seven is called as a operant operants”
- Categories of Operators: Python supports various categories of operators:
- Arithmetic Operators: + (addition), – (subtraction), * (multiplication), / (division), ** (exponentiation), % (modulo), // (floor division).
- “the first one is arithmetic operator as I said that the symbol are available plus minus the star so I think you guys is already aware about that so the meaning of the plus is nothing but using for addition minus is for subtraction so we can directly use this kind of symbol so only this double star uh modulo that percentage symbol and double slash is something new for you”
- Assignment Operators: Used to assign values to variables (e.g., =, +=, -=, *=, /=, etc.).
- “assignment operator”
- Relational (Comparison) Operators: Used to compare values and return a Boolean result (>, <, >=, <=, == (equal to), != (not equal to)). Also referred to as comparison or conditional operators.
- “third operator is a relation relational operator somebody is also calling the comparison operator because you are comparing a isal to 5 is there b is equal to 7 is there if you’re writing a greater than b you can also write B is less than a that means you are comparing the answer is always The Logical format what is a logical logical format can be true can be false true or false answer right your answer will always be the true and false concept you comparing like a is less than b a is greater than or equal to B this is the symbol for not equal to this symbol for not equal to this is symbol for equal to equal to in the sense a is equal to 5 is already assigned”
- Logical Operators: Used to combine or negate Boolean expressions (and, or, not). Always result in a Boolean value.
- “the next operator is a uh logical operator this concept will be clear okay so a equal to equal to B A is less than greater than when you just run it you will get the either true or false answer why it’s a is H so A and B is not the same that’s why it’s giving the answer is false a is greater than b so the answer is giving the true a is not greater than b okay maybe I didn’t run the this command that’s why yeah it’s taking the previous A and B values you can see here a is not equal to equal to B I wrote it that getting the answer is false where a is greater than b so a is five and B is a 7 that giving the answer is false because five is not greater than 7 okay if is not equal to you can also write the concept like if uh uh a equal to equal to 5 actually the a is a five I assign the values and I’m also writing the five when you just run it you’ll getting the answer is true okay the next operator which I discuss in this uh uh operator as well let me just remove it the next operator is uh yeah okay so next operator is logical operator as I said that this is always giving TheLogical format we can say the value is a bullion true and false is a bullion okay logical operator is and or not”
- Identity Operators: Used to check if two variables refer to the same object in memory (is, is not). Work similarly to == and != for values within the range of -5 to 255 due to Python’s object interning.
- “identity operator is very similar to the equal to and uh uh is not is very similar to not equal to so it identify the values like a is equal to 5 and B is equal to 7 and C is equal to a five again so a is C so it very similar to the equal to equal to it also giving the bullan answer okay G given the bullan answer which is a true and false bullan is nothing but a true and false values that we are calling bullan values”
- Membership Operators: Used to check if a value is present in a sequence (in, not in).
- “membership operator membership operator is in not in okay the value is a particular member variable or not suppose I have one variable which have a list is a 5 7 8 9 so five in a or not like this practically you can easily understand”
- Bitwise Operators: Mentioned as less frequently required for general programming but important in specific fields. Symbols like &, |, ^, ~, <<, >>.
- “one operator is also there is a bewise opor which is not much required for um for pro as a programming perspective if you belong to the any edic field so that time is really important but still I’ll give you the resource where the bewise operator is also available so you just run it you will also understand the beat wise as well but this main operator list try to understand it in a theoretically and practically both the way”
6. String Data Type:
- Immutable and Ordered: Strings in Python are immutable (cannot be changed after creation) and ordered sequences of characters, allowing access to individual characters using indexing (positive and negative).
- “so let’s discuss about the next topic which is a string so string is one of the very important data type in Python programming language so first thing is that it’s a immutable data type immutable in the sense once you define you cannot change it and second thing is that it’s a ordered data type ordered in the sense it have a index position starting with zero and goes till the length of the string minus one and we also have a negative indexing as well starting from minus one till the beginning of the string”
- Slicing: Substrings can be extracted using slicing with the syntax [start:stop:step].
- “we discuss about this slicing I disclose the concatenation and we have also one more thing is a repetition okay we can also repeat it with star symbol slicing we are using the square bracket”
- Concatenation: Strings can be joined together using the + operator.
- “concatenation we are using this uh Plus operation is used for concatenation plus operation is used for concatenation”
- Repetition: Strings can be repeated multiple times using the * operator.
- “reputation we can use the star so for example I have the value is uh variable is a I want to multiply with a five then you’ll getting India India India five times so that is a reputation”
- Methods and Functions: Strings have numerous built-in methods (accessed using dot notation, e.g., string.upper(), string.lower(), string.capitalize(), string.count(), string.index(), string.title()) and functions (e.g., len(), type()) for various operations.
- “let’s go to discuss about uh method and function in a string uh string data type so let me just conclude what I discussed okay so I discussed this slicing I disclose the concatenation and we have also one more thing is a repetition okay we can also repeat it with star symbol slicing we are using the square bracket concatenation we are using this uh Plus and reputation we can use the star so for example I have the value is uh variable is a I want to multiply with a five then you’ll getting India India India five times so that is a reputation okay a small small thing is there to go in a very details way again you can go to the data type if you already aware about these things so you can skip or you can just make this video is a 2X or 1.x faster and just complete it and go through this uh Jupiter notebook and run this file you’ll get a better idea but don’t forget to run this uh uh jupter notebook file okay so here I already explained okay so you can just run it just shift enter shift enter run it you’ll and you’ll understand each and everything but again in case if you make any doubts if you not understand anything you can just put your question on a comment definitely I’ll reply you okay so let’s discuss about uh okay I need a space all right I need a space keep because I don’t want to remove it okay so let’s discuss about the next thing is a function and method which is very very important every data type have a different different method and function okay let me first write a method and some function so actually the method and function both are a same there is no any difference this have a very small differences there if function is always defining like a def here I’m not explaining you the details of the function whatever in build function whatever in build method is available in a string that I will discuss it here okay so why the both are a difference see method is always calling with a DOT like I have suppose a is a variable a is a variable which is the India okay so method is always using like a Dot Upper a do lower a do capitalize okay a DOT count a do index small I there is no Capital index so other uh method is also available but when you’re talking about um function so function is like a len and we are passing the values a len means length we have um uh mean we have a mix okay so these are and we have a type so actually this uh uh function is a very common for for all the data type so when you just enter in the list tole dictionary so you’ll also find it out the same type of function that will not change but the method will always change the difference between the uh function and method is that if function is always defining like this and then function name f n if I’m writing defining like this if the function is separately available we are calling function simple but if the function is available inside a class we are calling the method class class name is a okay if it’s available inside a class we are calling method so when I start the objectoriented programming I’ll go in a very details way just now you can just understand like this the method is always using with a DOT and a function we directly call it and to know that which one is a function you can directly understand like if you find it out any statement after this bracket that is a function that can be either function or method if you’re using dot method not using function okay so few method I will discuss it here and uh after that I’ll stop okay because uh no need to explain each and every method when you just run this uter notebook you can easily understand okay so as I uh Define all two variables a which is India B which is a country and I want to make it a Dot Upper so that will make it is a upper case okay it will be make as a upper case a do lower that will make it a lower case small I and uh currently the a variable is already the capitalized capitalize in the sense first letter is a capital the second letter uh remaining letter is a small one let me make one variable is equal to I’m using Python programming language okay so let me just use small I when you just use a c do capitalize okay sometimes uh when you just forget your uh you know that method spell when you make it spellings little bit wrong so it will giving you the error so the best practice is that after this variable put a dot put a tab you’ll getting a different different suggestions I’ll make a capitalize I don’t need to write everything capitalize is already there okay when I just run it you’ll get the values I’m using Python programming language so the first L make it as a capital the rest of the later will make as a small one so C do title there is one more valuable uh”
- String Formatting: Methods like f-strings (formatted string literals) can be used to embed expressions within string literals for formatted output.
- “so string formatting is also very important which we already discuss in the input output so this F string is nothing but a string formatting”
- Escape Sequences: Special character sequences (e.g., \n for newline, \t for tab, \\ for backslash) are used to represent characters that are difficult to type directly.
- “skip sequence in the sense suppose if you are uh writing some statement and the value will not be print in the place of that uh uh that symbol it will be showing the meaningful result let’s say for example I’m writing here I um working in Python programming language okay which is uh dynamically type language okay I just want some statement after the uh High I want to print in next line I’ll use the slash n so sln is basically going to the next line right it’s not like that it will be print the slash okay and after the statement again I want to in this next line it will be in the next line I want to uh dynamically typed language have some uh space as well SLB B for backspace okay B for back I’ll make the t t for a tab okay so when you just run it you’ll get the values is because of the sln is giving the next line because of this sln is giving the again next line because of this SLT is giving the again some spaces here so that’s why it’s giving the uh uh that meaningful result not exactly is the printing the values right so this one we are calling the skep sequence so I just uh Define it here a different different type of skip sequence like slash n for next line/ t for tab SLB for back space SLR for reserved and uh Slash a for alert so different different skip sequences there sorry it’s a skip sequence okay skip sequence”
- Raw Strings: Raw strings (prefixed with r) treat all characters literally, without interpreting escape sequences. Useful for file paths and regular expressions.
- “what is a raw string so raw string in the sense sorry draw string in the sense if if uh you want all the statements as it is I don’t want to print the meaningful result I want as it is values so just before you have to write r that will consider everything as a raw string so the value is not displaying it here sometimes it’s very useful whenever you’re reading some particular files from local machine or in particular server okay suppose if you are reading and uh somewhere the double slash is available single slash is available so python is giving some meaningful result but you don’t want you want as it is uh path so that time we are using the r especially for uh reading the CSV file in the data science we mostly using the r to avoiding the errors”
7. Tuple Data Type:
- Immutable and Ordered: Tuples are immutable and ordered sequences, similar to strings but can contain items of different data types. Defined using round brackets ().
- “so let’s discuss about the next topic which is a tle so tle is one of the smallest data type like uh uh like a number number is very small that was only uh you know uh the integer float and complex but the tle have some values but it’s not as much of uh big topic so let me just cover it in this video only okay so again the tle so first we have to clear that what is the definition the Supple is again it’s a immutable and ordered data type ordered data type okay when you’re talking about the how the tle is defining the tle is defining in a round bracket suppose I have a value is a five a 8 7.0 and high okay so that I store in the variable T so uh uh first of all this tle is a comes under the sequence sequence means is a particularly order and that collecting the data right so the five is a integer 7.0 is a float high is a string so that is a that’s why the tole is become a uh sequence which store the different different data type even inside a tle you can also store the list as well dictionary as well anything so the tle list dictionary in the set that working as a container so the container is nothing but a sequence okay so here as I said it’s the ordered data type so again have a positive and negative indexing is there okay sorry uh oh why it’s showing like this okay have a positive and negative indexing so 0 1 2 3 have a positive indexing and as well as we have a negative indexing as well -1 – 2 – 3 – 4 so like the tle we can also apply the uh slicing order like uh the T slice with uh uh two you’ll get some values obviously you’ll get the value is 7.0 right you’ll get the value is 7.0 in in case if you pass the T of three you’ll get the high but in case if you pass the minus 3 then the value will change that will be 8 right so we can also apply the concatenation here we can also apply the multiplication here so this symbol is used for concatenation and this symbol is used for repetion okay so and uh the likewise the uh string we have also the method and function are available so the best part of this uh tle is that not a best part but uh yeah uh the tle have a very less method when you’re talking about a method have very less and a function okay so method have very less just we have a count count method like T do count and T do index that’s it we don’t have other method is here so again is a tle uh again is a immutable so that means we can’t change the values in between and uh the function when you’re talking about so it will be the same as the which we discussed in the string that like U uh what is the max values what is the mean values what is the um a type okay there is also one more function is available which is a tle which will be responsible to convert any data type into tle okay okay so mean Max is there yeah and we have a len which is very very important Len which will show you how much uh data is available inside a tuple so let me just clear it in the practical way it’s very uh small data type we can see so again you have to refer the data type Jupiter notebook you’ll find it out the practice uh um notes there okay so tole I can Define it here in the round bracket I’ll make this the T1 be Define in the round bracket 47 7.9 and um uh high is here we can Define it and he we can Define it okay so let me also Define one more variable is a T2 where I can Define it 4 5 6 2 there is”
- Indexing and Slicing: Supports positive and negative indexing to access elements and slicing to extract subsequences.
- Operations: Supports concatenation (+) and repetition (*) similar to strings.
- Methods and Functions: Has limited built-in methods (count(), index()) but works with common functions like len(), min(), max(), type(), and the tuple() constructor for type conversion.
- Immutability: Key characteristic, meaning elements within a tuple cannot be changed after the tuple is created. This provides data integrity.
8. List Data Type:
- Mutable and Ordered: Lists are mutable (elements can be changed) and ordered sequences of items, defined using square brackets []. Can contain elements of different data types.
- “now let’s discuss about the next topic is a list that is the fourth data type list so list basically a a mutable data type so whatever we discussed the previous one is a tle string and numeric that was a immutable data type but this one is a mutable data type mutable and ordered data type again so mutable means changeable ordered means have a positive and negative indexing so list is always defining with this is LS is a variable defining with a square bracket that can be the any data type you can just write it like integer 5.8 is a float High okay and uh 7 five so you can Define like this so it’s a square bracket all right so have a positive and negative indexing as well because of it order so we have a 0 1 2 sorry three and four I have a NE negative indexing as well minus1 -2 – 3 -4 – 5”
- Indexing and Slicing: Supports indexing and slicing like strings and tuples.
- Operations: Supports concatenation (+) and repetition (*).
- Methods and Functions: Has a rich set of built-in methods due to its mutability, including append(), insert(), remove(), pop(), clear(), count(), index(), sort(), reverse(), and functions like len(), min(), max(), type(), list() (for type conversion).
- “so same as the tle we have also this method and function are available but because of this mutability because of the changeability we can change the values so we have so many method and functions are available so here I will discuss a few method and function and later you can just run the Jupiter notebook file you’ll understand easily so method and function our function is the same that will be Len that will be mean that will be Max that will be uh list list also the function okay and uh that will be the type okay this function very common we we we are using in uh every data type so only this one like for a list we have a list function for tle we have a tle function string we have a s Str function okay so method when you’re talking about so method is um uh we have uh like U we have a DOT count okay we have a um we have a index that that is a common it’s there for a tle and uh in string as well and we have also the other method is like append which is very famous append insert okay so many method are available so again when you just run the jupyter notebook you’ll find it out all the methods there so few method I will discuss here and I’ll discuss in some practical implementation here okay you’ll find it out in the Jupiter notebook each and everything okay as I implemented almost every method here but still if you’ll get any confusion I’m there so let me create one uh heading is a list okay so LS is a variable I’m making some values here 6 comma 3 comma 8 comma 4.7 comma uh H comma K okay so if I want to change the value is H to hello so what is the position of H which is the 0 uh 0 1 2 3 4 that is the fourth position so fourth I want to which is nothing but a h i want to make as a hello hello and later when I just check the values is LS so yes I can see the value is hello so it’s very simple we can just do it right we can just up change the values because of it’s a mutable data type we can easily change the values which is defined inside that right so here H is changed so whatever index is defining for H so in the place of H is showing the hello but you can’t do it in a tle okay”
- Mutability: Allows modification of elements after the list is created. Elements can be added, removed, or their values changed.
- Nested Lists: Lists can contain other lists, creating multi-dimensional data structures.
- “like I want to create one list inside a list that is also possible list inside a list so that is called as a nested list”
- List Comprehension: A concise way to create lists based on existing iterables.
- “one more important topic is a list comprehension list comprehension is nothing but a very short way to define a list based on some conditions”
9. Dictionary Data Type:
- Mutable and Unordered: Dictionaries are mutable collections of key-value pairs, enclosed in curly braces {}. They are unordered, meaning the order of items is not guaranteed.
- “now we reach till fifth data type which is a dictionary so dictionary is a little bit different with tle and list what is the different different is that there is no any positive and negative indexing is there in the dictionary that means dictionary is unordered data type but it’s a mutable data type if it’s a mutable let me just write it first it’s a mutable and ordered data type sorry unordered data type unordered data type okay so there is no any positive indexing for a dictionary no any positive and negative indexing so dictionary is a defining like key value pair with curly brasses key colon values okay Curly brasses close”
- Key-Value Pairs: Each item in a dictionary consists of a unique key and a corresponding value. Keys must be immutable data types (e.g., strings, numbers, tuples).
- Accessing Values: Values are accessed using their keys within square brackets (e.g., dictionary[‘key’]).
- “if I want to access the value is a 15 so I will write D of a okay we’ll write a d of a then you’ll get the value is a 15 if I accessing the value is a d of Z so you can get the value is 19 this way we are accessing the values”
- Operations: Does not support direct concatenation or multiplication like sequences.
- Methods and Functions: Offers various methods like keys(), values(), items(), get(), pop(), popitem(), update(), clear(), and functions like len(), type(), dict() (constructor).
- “when I just perform some operation methods here like a D1 do Keys you’ll get the all the keys here okay so r k T5 these are keys and what is the values E1 dot uh values you will get the values here again if you uh if you already aware about that you just the run this file which is I shared with you the dictionary run this file and run this video in a 2X or 1.5x you don’t require to listen each and everything right these are very basic basic things is there and just when you run you’ll understand so I’ll just give you the complete overview here okay so suppose if I want to add some values so there is no any upend option is there right there is no any upend I want to add some values how can I add it so the D1 pass any keys I’ll passing the keys here like uh U I’m assigning the values here 1,000 so when I just run it and get the values here D1 you’ll get the U in the last values okay so like way we can also assign the values so dictionary have some um you know applications so I’ll discuss about that again I will not each I will not write each and every line code so I’m taking the help from here suppose if I’m defining the values here okay here this is the list okay so question is why I’m creating a list here why not sorry this is the tle uh why I’m creating the tle here why not a list the reason behind that tle is very much”
- Applications: Useful for representing structured data with labels (keys). Can be used to simulate tables when combined with lists.
- “when you just enter in the data science so everything you are dealing with a table and the table we are reading in the data frame format then you’ll start the operations so if you start the operation if you already aware about that yes this table is nothing but a collection of the keys and values right”
- Dictionary Comprehension: A concise way to create dictionaries.
- “likewise the list comprehension we have a dictionary comprehension as well so dictionary comprehension is also the same syntax for variable in sequence you can also put the condition as well but the only changes is that you have to define the key and values that’s it”
10. Set Data Type:
- Mutable and Unordered: Sets are mutable, unordered collections of unique elements, enclosed in curly braces {} or created using the set() constructor. Duplicate elements are automatically removed.
- “now the last data type is a set so set is again a mutable data type but it’s a unordered data type and it always store the unique elements unique in the sense duplicate values is not acceptable and it’s defining with a curly bras but the only difference with dictionary is that dictionary is a key value pair but here directly you are passing the values”
- Uniqueness: Sets only store unique elements. If duplicates are added, they are ignored.
- Unordered: Elements in a set have no specific order, and indexing is not supported.
- Operations: Supports various set operations like union (|), intersection (&), difference (-), symmetric difference (^), and methods like add(), remove(), discard(), pop(), clear().
- “so sets support so many operation like Union intersection difference symmetric difference and all the Venn diagram concept you can apply it here so Union means combining the two set but again it will store only the unique element intersection means common values difference means the values is there in a but not in b or values is there in b but not in a symmetric difference means except the common values rest of the values will be displayed”
- Methods and Functions: Includes methods for adding (add()), removing (remove(), discard(), pop()), and updating sets, as well as set operations. Functions like len(), min(), max(), type(), set() are also applicable.
- Set Comprehension: A concise way to create sets.
- “there is one more application one application is there in a set which is the uh set comprehension likewise the dictionary comprehension we had we had a uh list comprehension so set comprehension is also there comprehension okay set comprehension so set comprehension the syntax will be the same like the and list so whatever for we have to use for that particular variable in sequence sequence can be any range any uh other sequence like a list or tle or or list or tle mainly so here just you have to write variable and curly bres is mandatory for a set”
11. Data Type Summary (Mutable/Immutable, Ordered/Unordered, Container/Sequence):
- Mutable: List, Dictionary, Set
- Immutable: Numeric (int, float, complex), String, Tuple
- Ordered: String, Tuple, List
- Unordered: Dictionary, Set
- Container (holds multiple items): String, Tuple, List, Dictionary, Set
- Sequence (ordered container with indexing): String, Tuple, List
12. Conditional Statements (if, elif, else):
- Flow Control: Used to execute different blocks of code based on whether certain conditions are true or false.
- if Statement: The starting point of a conditional block. The code within the if block is executed only if the condition is true.
- “the condition is always start with if we are writing if take a space and write it down a is greater than b okay that uh your condition after the colon it automatically taking the four space that we are calling indentation and we consider as a block if I write the statement as a print hello and when you just run it and it will be check the condition is satisfied or not”
- elif Statement: Used for additional conditions to check if the preceding if or elif conditions were false. Multiple elif blocks can be used.
- “but I want to write one more condition so obviously I have to go back and write one more condition which is the L if L if C is greater than b colon let’s write some statement statement is hey and if I want to one more uh uh if I want one more condition I’ll write it the L if is a is greater than C there is a three condition I mentioned there and simultaneously you can just write a many condition is here okay hello hey hi”
- else Statement: An optional block that is executed if none of the preceding if or elif conditions were true.
- “and after that we always using the ls this is the good practice in case if you’re not using it will not show you any error so likewise here it’s not showing any error so same wise here it will not show any error if you’re not using else just write down here else colon and your statement print hello uh just buy else is always execute if any block is not executed previously if any block is not executed that time is working”
- Top-to-Bottom Evaluation: Python evaluates the conditions in order from the if statement downwards. Once a condition is true, the corresponding block is executed, and the rest of the conditional block is skipped.
- “python is always working the top to bottom okay it always check that line number one is um um satisfied or not satisfied a is greater than b the meaning is that a is greater than b B that is false Okay C is greater than b which is true a is greater than C which is also false and else is always is a default one in case previous one is not executed that time it will run okay so here the block number two here the third one line number three is execute it when you run it it giving the answer is he but what happened is all the condition is satisfied all the condition is true like a is greater than b okay A a is less than b uh and C is greater than b and uh a is also less than C that all the condition is satisfied so what will be the answer the answer will be the first one because according to the rules here which we discussed if the first condition is satisfied is giving the statement and terminate the Block it’s not entering the next block because l l if will check if the first condition is dissatisfied right if the first condition is satisfied is giving the statement and terminate the block but here the L if is after the false of the first condition so here it giving the answer is hello one day again the last one if no any condition is satisfied that time the buy will execute which is the default one if nothing is there nothing no any condition is satisfied like uh I’ll just change it here uh greater than less than greater than so all the condition is false there is no any true condition and uh so when you just run it it giving the answer is by because nothing is satisfied here this is the way of conditional statement we are using”
13. Loop Statements (for, while):
- Iteration: Loops are used to repeatedly execute a block of code.
- for Loop: Iterates over a sequence (e.g., string, list, tuple, range).
- “basically the for Loop is used for the iterating of the process if anything is available in a uh you know in any container if you want to iterate it if you want to display the one by one we are using the for”
- range() Function: Generates a sequence of numbers, often used with for loops. range(start, stop, step). The stop value is exclusive.
- “sequence is uh scq limes right scq is equal to range so range is one of the function which provided the sequence from one number to another number with interval so if I’m passing the range is like 1 till 15 yeah 11 so python have a rules that it never end with last values it end always before one so if I’m I’m writing the 1 to 11 that means it’s a 1 2 3 4 5 6 7 8 9 it never goes till 11”
- Iterating Through Sequences: for loops can directly iterate over elements of lists, tuples, strings, etc.
- “the same thing is applicable for any list as well so in the list I have a multiple values for V in list print V so it will print the one by one”
- Nested Loops: Loops can be nested within other loops to iterate over multi-dimensional data structures.
- “if you have a list inside a list inside a list that is a 3D so you have to apply the three for Loop to read each and every element”
- while Loop: Executes a block of code as long as a specified condition is true. Requires careful management of the loop condition to avoid infinite loops.
- “while loop is also for the iterative purpose but it will be continue the process until the condition become false so we have to initialize one variable and provide the condition here and inside a block we have to either increment or decrement that variable so that particular condition will be false otherwise it will be run infinite time so we have to take care about the while loop”
- break Statement: Used to immediately exit a loop.
- “if any condition is satisfied in between I want to just stop the loop I can use the break statement”
- continue Statement: Skips the rest of the current iteration of a loop and proceeds to the next iteration.
- “if any condition is satisfied I just want to skip it I don’t want to stop the loop I just want to skip and continue the next iteration I can use the continue statement”
- else Clause in Loops: Can be used with for and while loops. The else block is executed if the loop completes normally (without being terminated by a break statement).
- “there is one more interesting thing is that the else block is also available with the for Loop and while loop but it will be execute only if the loop is completely executed if the loop is break in between the else block will not be executed”
- Real-life Example (Login Attempt): The source provides an example of using a while loop for login attempts with a counter and the possibility of pausing the process using the time.sleep() function after a certain number of failed attempts.
- “I’ll just use the while count is greater than zero I’ll ask the username input enter your username and password input enter your password okay and uh if my condition is username is equal to equal to hurry and password is equal to equal to hurry 1 2 3 my login will be successful print login successful and I’ll break it I don’t want to continue the process anymore but in case if my username and password is wrong is more than three times then the process should stop for particular duration I’ll just make it minus okay then it will showing that uh it only three times is remaining only two times is remaining this kind of you’ll get only three attempts okay the same statement I’ll apply for if the username is wrong my username is wrong and I’ll make it comma uh this particular attempt is remaining all right so okay this okay so if my usern is wrong uh all right I forgot to write F this is string formatting if my usern is wrong two attempt is remaining one attempt is remaining zero attempt is remaining in the sense is the last one it should be stop it here so I have to put one more condition if the count become a zero I have to stop it what I can do it here uh so anywhere like uh the breaking the loop if my loging successful I can also write L if Al if we can write Al if the count is equal to equal to zero the time please wait for 10 second currently I’ll just write in the 10 second okay 10 second and after that process should start again all right so I’ll do the same process for uh this is for password I’ll do the same thing for username as well I do it username as well but the your process should stop for 10 second so how can we do that so there is a like library is called as a Time import time okay so you can directly write the time do slip your process will stop for particular duration so I’ll do it here time do slip for 10 second so automatically it’s a second how can we know that you can just write time. slip and bracket you can just check it what exactly is there it’s a second I click on here inside and click shift tab this option is available in the Jupiter notebook only and if you have any other ideally you can find it out other options okay let me just remove so the process will stop for 10 second and after that it will again start so it’s on you if you want to put the timing you can okay so currently it will be stopped for 10 second process will yeah only two attempts is remaining one attempt is remaining I’ll write hurry password I’ll make it wrong this is the last attempt zero attempt is remaining that means there is no any attempt this is the last one I’ll write it here uh hurry password is hurry wrong let me just write it just wait for 10 second the process is still running it’s not like that your process is totally end up it’s running for 10 second it hold for 10 second you can increase it now it’s ask asking the password again hurry I will write it and again it’s waiting for 10 second because it’s already been uh uh already been you know um is a kind of uh uh already your count was Zero that that’s why it’s waiting for 10 second but it should not be it should not be after 10 second it give the three times option right but here I’m passing the wrong password still is waiting for 10 second so that one glitch is there there I have to just change it uh it should be make it zero again uh it should make it uh three again all right so I use it hurry 1 2 3 and let’s make it yes”
14. Functions:
- Code Reusability: Functions are blocks of organized, reusable code that perform a specific task. They help in modularizing code and making it more readable and maintainable.
- “function is nothing but a block of code which perform a specific task and it is reusable”
- Types of Functions:Predefined (Built-in) Functions: Functions that are already available in Python (e.g., print(), len(), type(), int(), range()).
- “predefined which is system is already given the function we are just using it right mean Max int print whatever you you already use it that is a predefined function you just just call and pass the values you’ll get the answer”
- User-Defined Functions: Functions created by the programmer using the def keyword.
- “we can also make the function which is we are calling user defined function that means we are defining the function the third one is anonymous function we’ll discuss in um practical manner a function without name so here you can see the uh you can see the def and function name”
- Anonymous (Lambda) Functions: Small, unnamed functions defined using the lambda keyword. Often used for simple operations where a full function definition is unnecessary.
- “the third one is anonymous function which is also called as a Lambda function we can define the function without name with Lambda keyword with Lambda keyword”
- Recursion Functions: Functions that call themselves during their execution. Requires a base case to prevent infinite recursion.
- “the last one is a recursion function that things we’ll also discuss”
- Defining Functions: Use the def keyword followed by the function name, parentheses for parameters (optional), and a colon. The function body is indented.
- “let’s make a block is a depth EF and function name is a equation equation okay as I told you bracket is very very important parameter it’s on you if you want to Define you can otherwise you can leave it and uh like equation is the equation is y equal x squ plus 2X you required X as a input so I’ll just pass it here parameters now your block is ready I’ll just print it y okay I’ll just print it Y and I just run it you’ll not get any answer function have a rules without calling the function function will never execute okay so here I can see this is defining the function defining the function”
- Calling Functions: Functions are called by using their name followed by parentheses, passing arguments if required.
- “I want to call it so what I’ll do I have to define the values X is equal to some some something or else you can directly uh pass the values equation I’ll pass the value is five so you’ll get the answer accordingly so this one we are calling the function this section calling the function okay this SE is calling the function”
- Parameters and Arguments: Functions can accept input values through parameters defined in the function signature. When calling a function, the actual values passed are called arguments.
- Return Statement: The return statement is used to send a value back from the function to the caller. After a return statement is executed, the function terminates.
- “the dev hello there is a function and if my number number is a = to 4 and B is = 8 and return is equal to a + and before return let me just use the print print A+ B and when you just call it hello you’ll get the answer is 12 and after the print statement uh my statement is there um um hello world okay this normal statement hello world after 12 is showing that hello world but in case if you use the written statement for a plus b return statement for a plus b hello world where hello world will never display the reason behind that because after the print after the written statement whatever things is there will never be execute”
- Lambda Function Syntax: lambda arguments: expression.
- “we are writing the Lambda Lambda and we’re passing the arguments like uh a sorry a comma B and then you uh doing some operations let’s understand it here so syntax is not much important but you should know that how we are writing so just we have to write Lambda what operation you want to perform I want to perform the operation of um a cube of any numbers yeah we can say U addition of XY Z so I have to Define it X comma y comma Z colon colon what operation you want to perform I want to perform is the 2 into x + y + z that equation I want to perform when you just run it we’ll find it out the function is created”
- Use Cases for Lambda Functions: Often used with functions like filter() and map() for concise, inline operations.
- “Lambda keyboard is using if your function is very small and you are it iteratively calling it the time we are using you don’t need to Define it separately you in that function itself in that predefined function itself you can use the Lambda”
- Recursion Function Example (Factorial): The source demonstrates a recursion function to calculate the factorial of a number, where the function calls itself with a decremented value until a base case is reached.
- “suppose I have a number is n and uh here I pass the value is a five and every time when you call this process when you call this function I’ll make it n minus one at the same time I can also print that n as well so that I can track it how much value is there so when I just run it you can see here the 5 4 3 2 1 and and it’s going till down there is there is a limit is a 3,000 so it will be going down and run it again and again right so what I can do hit here so when you scroll down down down down it’s a 7,000 it’s going to more than 7,000 the reason behind that I increase the limit which is the 8,000 right I increase the limit that’s why it’s going till here after uh 7,000 7,000 something and is going this statement is maximum recursion depth exced while calling the python object my target is that I want to stop in after five steps so I can use it here the condition if my n become a zero that time I will return return just um uh recursion done okay the statement is is a recursion done that’s it so because you know that after the return statement any statement is written there it will never accept okay so when I just run it it will going till uh 1 only what exact what is the meaning is that it’s not acceptable after the return statement like I think I already discussed but again I’ll tell you in the short way the dev hello there is a function and if my number number is a = to 4 and B is = 8 and return is equal to a + and before return let me just use the print print A+ B and when you just call it hello you’ll get the answer is 12 and after the print statement uh my statement is there um um hello world okay this normal statement hello world after 12 is showing that hello world but in case if you use the written statement for a plus b return statement for a plus b hello world where hello world will never display the reason behind that because after the print after the written statement whatever things is there will never be execute”
15. Modules and Packages:
- Modules: A Python file with a .py extension. Contains Python code (functions, classes, variables). Used for organizing code and reusability.
- “module is nothing but uh any python file which have a py extension is called as a module so you have so many python file you create but sometime we creating the Jupiter notebook file that Jupiter notebook extension is i p y and B so that is not a module so python file should be in the py extension that will consider as a module and the module can consist of function classes variable anything because that is the file inside a file so many things we can write it”
- Packages: A directory containing multiple modules and a special file named __init__.py. Used for structuring larger Python projects and preventing naming conflicts between modules. Sub-packages are packages nested within other packages.
- “package is nothing but one uh directory we can say where consist of the multiple modules but there is one special file is called as init so that name is init it should be available there that we are calling packages so for example I have a file which is the uh a which is the file name is a. py B do py c. py so these are all a modules but make sure that there is one more file should be underscore uncore init uncore uncore py if this one is also present and it’s available in the particular folder uh suppose the folder name is okay yeah suppose the folder name is main so main is nothing but a package which consist of the multiple modules”
- Libraries: Often used as a general term for a collection of related modules and packages that provide a set of functionalities.
- “someone is also calling this one is a library someone is also calling this one is a library so library is nothing but is a collection of the packages”
- Importing Modules: Use the import keyword to bring modules into your current script. Specific names can be imported using from module import name.
- “so I want to call it this function with different file so calling is a file both load and calling is available in the same location I want to call the load module so how to call any module we are using the import keyword import load”
- Finding Module Location: The sys module and sys.path list can be used to determine the directories where Python looks for modules.
- “there is one um library is in build Library which is a CIS CIS is a system so let me just open the python here directly sorry here anywhere you can open it I can write it here okay so import CIS system sis. paath so it will showing you the path where exactly all the libraries and all the python packages are available”
- Installing Packages with Pip: pip is the package installer for Python. Used to install and manage third-party libraries from the Python Package Index (PyPI). Command: pip install package_name.
- “p is working as a package manager which is responsible to install any kinds of packages or libraries so if you’re using the python more than uh 3.4 version so that means PP is already there you have to just use it so if you want to install a package like pandas so you can write it you can write it like pip install pandas that’s it”
- __name__ Attribute: A built-in variable that holds the name of the current module. When a script is run directly, __name__ is set to “__main__”. If a module is imported into another script, its __name__ is set to the module’s name. This is often used to include test code or main execution logic within a module that should only run when the module is executed directly.
- “there is one more topic is a name attribute I think you saw this name attribute in a Python programming language is many places so let’s understand it how we can use this name attribute so suppose if you have vs code okay if you have a vs code and uh yeah and I have one file which is a um load file load. py so the variable is 55 and DEP is equal to info and uh pass the statement is this is this is uh load module okay and one more function is available def add and pass to parameter a comma B simple and just um you know perform some operation result is equal to a + b and later return the values return the result okay now it’s done but I want if if I if my target is to create the complete a module which will be the load module but I want to test it that whatever function I wrote it that is perfectly fine or not okay so here uh I just want to um you know test it this add function is properly running or not so what I’ll do I’ll just call the function 5 comma 8 and when I run it so hopefully we will not get any answer because I return the values but when I just print the statement like uh print the statement directly so we will get the answer is 1 so which um I was expecting 13 now the answer is also 13 everything is perfect but here I just want to call the load module let me just call it import load okay and when you just import load let’s see what will happen so import load I just load the I just uh you know load the load module that name is the same I just imported the load module but here I was not expecting that answer should be the 13 because I didn’t call the add function here I didn’t call the add function let me just call the add function uh print load do add I’ll pass the values is 5 comma 12 so I’m expecting the answer is 17 so here I got the 17 but the same time I also got the answer is 13 as well which is wrong not wrong but uh I have to see that where exactly this 13 so 13 is basically I just printed here in the load module just”
16. Exception Handling (try, except):
- Handling Errors: Exception handling is a mechanism to gracefully manage runtime errors (exceptions) that can occur during program execution, preventing the program from crashing.
- “exception handling is basically used for to handle the unexpected event during the program execution”
- try Block: The code that might raise an exception is placed within the try block.
- “I’ll just use a try try means I’ll just normally try the normal flow of the program so normal flow of the program I’ll right okay so in case any exception occurred except”
- except Block: If an exception occurs within the try block, the code within the corresponding except block is executed. You can specify the type of exception to catch.
- “except exception accept exception uh the time I can I can write it here print Infinity okay I can I can write it anything so if I pass 6 IDE 0 you’ll get the answer is infinity whatever you write it here you’ll get the answer accordingly”
- Real-life Analogy: Likens exception handling to a car’s fuel indicator: it doesn’t solve the problem of an empty fuel tank but alerts the driver to take appropriate action.
- “if the petrol is finished the fuel indicator is giving the answer you’re giving the uh instruction that yes your petrol is finished find it out some nearby petrol pump so the fuel indicator is not solving the problem but is giving the instruction that this is the exact instruction you can handle via petrol so this is one of the example”
17. File Handling:
- Opening Files: The open() function is used to open files for reading or writing. It takes the file path and the mode (‘r’ for read, ‘w’ for write, ‘a’ for append, ‘r+’ for read and write, etc.) as arguments.
- “file handling is basically we have to perform the operation with the file like a reading the file writing the file updating the file and deleting the file so these are the four basic fundamental operation we can perform it and to perform this operation we have a inbuild function is called as open function”
- File Modes: Different modes determine the operations that can be performed on the file. ‘w’ overwrites existing files or creates a new one, ‘a’ adds to the end of an existing file.
- “your mode should be w w means writing the files and then line by line I’m just writing the file this is my first program this is my second program I’m writing there so make sure that you have to close it otherwise it will be impact to the another files if you opening in a new section so yes I close it that means file is properly written sometimes we are not closing the files so what happened ke if you write the program uh if you apply the uh writing some uh you know lines in a text but you forget to close it so that time the file exactly not writing in the text file okay so now file is a properly written”
- Closing Files: It’s important to close files using the close() method to release system resources and ensure data is written to the file.
- “make sure that you have to close it otherwise it will be impact to the another files”
- with open() Statement: Provides a convenient way to work with files. It automatically closes the file even if errors occur. Recommended practice.
- “one more option is also available which is a with open we have to use a with open it and if you using the withth open you don’t need to close it the reason because you’re writing entire section inside the block if you’re coming out the block that means file is already closed so this is also one of the good practice”
- Reading Files: Methods like read() (reads the entire file), readline() (reads one line at a time), and iterating over the file object (reads line by line) are used to read file content.
- “so if I want to use the reading okay so make sure that I should have some files okay uh so python. txt I create I have one files is a big file so you can also find it out files on um GitHub okay before going to the python. txt let’s also read something okay you can also read the my my text.txt as well let me show you how we can read it so with Way open you can also use it with open I’m just opening the file which name is my txt do my text.txt my my text.txt and mode is equal to it’s r r for reading okay and then uh uh we have to define the Define the you know as a variable as F3 I’m just defining it okay F uh F50 I’m just defining maybe it will be impact the next one because 3 four I just use it there so I’m just use the F50 F50 dot read line and then read line that’s it so it will be uh store somewhere let me store in the where one okay so we can also check that is the first line which will be printed where one so this is my first program so whatever I write it I can also read it as well”
- Writing to Files: The write() method is used to write strings to a file.
- Appending to Files: The ‘a’ mode allows adding content to the end of a file without overwriting existing data.
- seek() Method: Allows changing the file pointer position to a specific offset, enabling reading or writing from different locations within the file.
- “here we have a a method is a seek method seek method is exactly we can just Define the positions from where you want to start it like I I I decided that I want to start some particular position which is the python is interpreted objectoriented high level programming language suppose I want to start from there so how we can start it like we our cursor is always starting from here but I want to start here so seek will Define the position in a python yeah we can say here in this location and then it will”
18. OS Module:
- Operating System Interaction: The os module provides functions for interacting with the operating system, such as working with file paths, directories, environment variables, and running system commands.
- “OS module is also one of the very important module which will be interact with your operating system like creating the folder deleting the folder and uh checking your current directory changing the directory so so many operation we can perform it”
- Common Functions: Includes functions like os.getcwd() (get current working directory), os.chdir() (change directory), os.mkdir() (make directory), os.makedirs() (make multiple nested directories), os.rmdir() (remove directory), os.rename() (rename file or directory), os.path.join() (join path components), os.path.exists() (check if a path exists), os.cpu_count() (get the number of CPUs).
- “OS module is also one of the very important module which will be interact with your operating system like creating the folder deleting the folder and uh checking your current directory changing the directory so so many operation we can perform it let me just show you a few practical examples so currently my current directory is this so if I want to check it OS module first you have to import OS and OS do get CWD so you’ll get your current working directory if you want to change your directory OS do chdir and pass the path wherever you want to go your path will change and next time when you just check it os. getet CWD so you will get it the current location which is the recurrent learning video on python tutorials and some operation we can also perform is like um I want to make some directory I want to make some uh you know some folders directory is a folder so how we can create it uh current location is this this in the sense here nothing in no any folder is available I want to create any folder how we can create it mkd sorry OS do mkd and pass the values you can you can write anything uh I’m just writing temp directory temp di so when you just run it so temp directory will generate yeah temp directory is generated so with the help of os module you can perform some operation with your computer so that python is providing that kind of facilities other programming language is also there just I’m telling you the python have the OS moduel and uh in case if you have the multiple directory for example my current location my current directory is this and I want to create the multiple directory inside a directory like path is equal to I want to create um you know new dir inside the new di I want to create one more directory is a okay analysis okay inside analysis and then um uh we can say Titanic okay this folder I want to create it but if you’re using the. M KD let’s see it will work or not so os. mkdir path let’s see it will showing throw the error the system cannot specify the path because your current directory is this and inside that you want to create the multiple directories so which is not possible with a mkdir so different method is available which is a Mech DS Mech directories so when you just using the me directories so you can create a folder inside a folder inside a folder like that so let me show you yeah new di inside that analysis inside that Titanic so this way we can create it okay so in case I don’t want any directory suppose I don’t want a temp directory still there so OS Dot .rm and provide the path which is the temp Dr so that directory will delete RM di sorry rmd so that directory will delete as well so this kind of option is also available to you can also delete it okay there is one only one directory which is the new d new dir there is no any temp di because I deleted I want to change this name I don’t want you know this new IR I want to rename it so OS dot rename it okay so rename it so what is the file name new di I want to change it as a new only okay rename n a m e rename sorry so new di I just change it is a new so change it here so that kind of option is available so let me just do the last two method and after that I’ll I’ll show you the list you can easily explore it suppose my current directory uh my current directory is this current di let me just do it o.get CWD okay this is my current Di okay I want to perform some operation uh so like uh I want to add it like new Di and with all the locations right so how we can do it like inside a DI there is analysis folder is available so we can also join the path as well so OS do os. paath do join so my current directory current Di with whatever path you want to join it suppose I want to join with a new so it will be joined like this okay so you can perform the analysis and based on that so. path. jooin you can joining with the two One Directory with any other directory in case I want to create One Directory which name is a new which is already exist let me R OS do mkd which is name is new let’s see what will happen so it will throw the error and saying that cannot create a file when that file is already exist so there is a condition we can also apply it okay if os. paath do exist and you can write it that new in case if new is exist the time in case if new a exist if os. path. exist the time will not create okay okay okay let me just try uh okay so it’s kind of if path the the different path is exist then you can create it like I want to uh this one is just tell you like the path is exist or not like I want to check that yes or no so it will show yes that path is exist so in case the new is exist inside that I want to create one uh location like here like here inside a new I want to create it inside new folder I want to create one more folder which name is uh data science okay inside a new I want to create it in a data science likewise okay let me tell you new okay temp Dr and then data science okay so like this live it let me make it the very simple I want to create new directory os. mkd which is name is new I want to create it but it’s already exist so it throw the error so what I can do if not os. path. exist new if it’s not there then it’s create otherwise don’t create so it will not throw the error in case new is not available so currently new is available it’s not enter inside the location but in case if it’s not available I delete it when you run it here so it will be create but inside nothing is there because just now it created okay so when you just apply this kind of condition if not os. path that exist then it’s created otherwise don’t create so in OS module lots of method is available so I just provided the link in a Jupiter notebook W3 schools you can also explore it like anything like I want to know that CPU count okay with a CPU count you can also use it how many CPU is there and you can also perform the operation there is a four CPU kind so likewise I want to also check that in my PC how many CPU count is there so OS do CPU count okay it’s not counts think yeah there is a 12 CPU count is there in their system is a four so likewise you can also explore it other method which is available here”
19. File Handling (Pickle, JSON, CSV):
- Pickle: A module for serializing and de-serializing Python object structures (pickling and unpickling). Allows saving complex data structures to a file and loading them back. Pickle files are binary format.
- “pickle is used for preserving the data so like if you save this kind of data into any format like a Json format or normally the text format you can see easily right if you double click with a notepad you can uh see that kind of files but pickle is always store”
- JSON: JavaScript Object Notation, a lightweight data interchange format. Python’s json module allows encoding and decoding JSON data. Commonly used for web applications and data transfer. JSON files are human-readable text format.
- “Json is also for the same purpose if you want to transfer the data from one application to another application so Json is mostly used in web application”
- CSV: Comma Separated Values, a simple text format for storing tabular data. Python’s csv module provides functionality to read and write CSV files.
- “CSV is also one of the very famous file format if you want to store the tabular data in a very simple way like in Excel format so CSV is very useful”
This briefing document provides a comprehensive overview of the fundamental Python concepts covered in the source. Further exploration and practical exercises, as suggested by the source’s reference to a Jupyter Notebook, are crucial for solidifying understanding.
Python Fundamentals: Variables, Data Types, and Operators
1. What is a variable in Python, and how does it relate to data types and memory allocation?
In Python, a variable is essentially a name that refers to a location in the computer’s memory where data is stored. When you assign a value to a variable (e.g., a = “hello” or b = 15), Python allocates a portion of memory to hold that data. The data type of the value (like string, integer, float) determines how this memory is allocated and interpreted. Each variable, being a memory location, also has a unique identification number, which can be retrieved using the id() function. The amount of memory allocated and the identification number can differ based on the data type of the value stored in the variable. For instance, a string might require more memory than an integer, leading to a larger gap between their identification numbers when created.
2. What are the main built-in data types in Python, and can you provide examples of each?
Python offers several built-in data types, categorized mainly as:
- Numeric:Integer (int): Whole numbers without decimal points (e.g., 15, -3).
- Float (float): Numbers with decimal points (e.g., 19.8, -2.5).
- Complex (complex): Numbers with a real and an imaginary part (e.g., 3 + 5j).
- Dictionary (dict): Unordered collections of key-value pairs (e.g., my_dict = {5: 4, 4: 7, 9: 8}).
- Boolean (bool): Represents truth values, either True or False.
- Set (set): Unordered collections of unique elements (e.g., my_set = {1, 2, 3}).
- Sequence Types: Ordered collections of items.
- String (str): Sequences of characters enclosed in quotes (e.g., “hello”).
- List (list): Ordered, mutable sequences of items enclosed in square brackets (e.g., my_list = [1, “hello”, 3.14]).
- Tuple (tuple): Ordered, immutable sequences of items enclosed in parentheses (e.g., my_tuple = (1, “hello”, 3.14)).
3. What are keywords in Python, and what are the rules for using them?
Keywords in Python are reserved words that have specific meanings and purposes within the language. They cannot be used as identifiers, such as variable names, function names, or class names. Python has a predefined set of keywords (e.g., if, else, for, while, def, class, True, False, None). You can see a list of Python keywords using the keyword module and keyword.kwlist. Attempting to use a keyword as an identifier will result in a syntax error.
4. What is indentation in Python, and why is it important?
Indentation in Python refers to the spaces or tabs used at the beginning of a line of code to define code blocks. Unlike many other programming languages that use curly braces {} to delimit blocks, Python relies solely on indentation. Consistent indentation is crucial because it determines the structure and execution flow of the program, especially within control flow statements like if, for, and while, as well as in function and class definitions. Incorrect indentation will lead to IndentationError and will change the logical grouping of statements. The standard convention in Python is to use 4 spaces for each level of indentation.
5. How do you take input from the user and display output in Python?
In Python, you can take input from the user using the input() function. This function prompts the user with an optional message and returns the user’s input as a string. If you need the input to be of a specific data type (like an integer or float), you need to explicitly convert it using functions like int() or float(). For example:
name = input(“Enter your name: “)
age = int(input(“Enter your age: “))
To display output in Python, you use the print() function. You can print strings, variables, and the results of expressions. You can also format the output using f-strings or the .format() method to include variables within strings. For example:
print(“Hello,”, name)
print(f”You are {age} years old.”)
result = 10 + 5
print(“The result is”, result)
6. What are operators in Python, and what are the main categories of operators?
Operators in Python are symbols that perform operations on values (operands). Python supports various types of operators, including:
- Arithmetic Operators: Used for mathematical calculations (e.g., + for addition, – for subtraction, * for multiplication, / for division, ** for exponentiation, // for floor division, % for modulo).
- Assignment Operators: Used to assign values to variables (e.g., =, +=, -=, *=, /=, %=).
- Relational (Comparison) Operators: Used to compare values (e.g., == for equal to, != for not equal to, > for greater than, < for less than, >= for greater than or equal to, <= for less than or equal to). These operators return Boolean values (True or False).
- Logical Operators: Used to combine or modify Boolean values (e.g., and, or, not).
- Identity Operators: Used to check if two variables refer to the same object in memory (is, is not). Note that for small integers (-5 to 255), Python might reuse the same object ID.
- Membership Operators: Used to test if a value or variable is found in a sequence (in, not in).
- Bitwise Operators: Used to perform bit-level operations on integers (&, |, ^, ~, <<, >>).
7. Can you explain the concept of immutability and mutability in Python data types and provide examples?
Immutability: An immutable data type is one whose value cannot be changed after it is created. If you perform an operation that seems to modify an immutable object, you are actually creating a new object with the modified value. Examples of immutable data types in Python include:
- Numbers (int, float, complex): When you add two numbers, you get a new number object.
- Strings (str): String operations like concatenation or slicing create new string objects. You cannot change individual characters of a string in place.
- Tuples (tuple): Once a tuple is created, you cannot add, remove, or modify its elements.
Mutability: A mutable data type is one whose value can be changed in place after it is created, without creating a new object. Examples of mutable data types in Python include:
- Lists (list): You can add, remove, or modify elements of a list directly using methods like append(), insert(), remove(), or by assigning to specific indices.
- Dictionaries (dict): You can add, remove, or modify key-value pairs in a dictionary after its creation.
- Sets (set): You can add or remove elements from a set using methods like add() and remove().
The distinction between mutable and immutable types is important for understanding how data is handled and how variables behave in Python, especially when passing objects to functions or assigning them to multiple variables.
8. What are the key characteristics and operations associated with Python’s sequence data types (strings, lists, tuples)?
Strings (str):
- Ordered: Characters in a string have a specific order, and you can access them using positive and negative indexing.
- Immutable: Once a string is created, its characters cannot be changed.
- Operations:Slicing: Extracting a portion of a string using index ranges (e.g., s[1:5]).
- Concatenation: Combining strings using the + operator (e.g., “hello” + ” world”).
- Repetition: Repeating a string using the * operator (e.g., “abc” * 3).
- Methods: Numerous built-in methods for string manipulation like upper(), lower(), capitalize(), count(), find(), replace(), split(), join().
- String Formatting: Using f-strings or the .format() method to embed variables in strings.
- Escape Sequences: Special character combinations like \n for newline, \t for tab.
Lists (list):
- Ordered: Items in a list have a specific order, accessible by index.
- Mutable: You can change the elements of a list after it’s created.
- Operations:Slicing: Similar to strings, but returns a new list.
- Concatenation: Using the + operator to combine lists.
- Repetition: Using the * operator to repeat list elements.
- Methods: Many methods for modifying lists: append(), insert(), remove(), pop(), sort(), reverse(), extend(), count(), index().
- List Comprehension: A concise way to create lists based on existing iterables.
- Supports nested lists (lists within lists).
Tuples (tuple):
- Ordered: Elements in a tuple have a specific order, accessible by index.
- Immutable: Once a tuple is created, its elements cannot be changed.
- Operations:Slicing: Returns a new tuple.
- Concatenation: Using the + operator to combine tuples (creates a new tuple).
- Repetition: Using the * operator to repeat tuple elements (creates a new tuple).
- Methods: Fewer methods compared to lists: count(), index().
- Tuples are often used for fixed collections of items and can be more memory-efficient than lists in some cases. They can also be used as keys in dictionaries (unlike lists).
Jupyter Notebook and Python Fundamentals Illustrated
Based on the provided source, here are some basics of Jupyter Notebook:
Installation and Launching:
- Jupyter Notebook can be installed in several ways, including using Anaconda or Miniconda, or directly via the command prompt using pip.
- The source recommends using Anaconda for data science as it conveniently installs Jupyter Notebook, along with other useful tools like Spyder, and comes with many pre-installed libraries such as pandas, NumPy, Matplotlib, and Plotly.
- To install Anaconda, you can go to the official website and download the free version. The installation process involves a simple double-click and following the on-screen instructions.
- After installing Anaconda, you can find the Anaconda Navigator in your applications (e.g., under the “Anaconda3” folder in Windows). From the Navigator, you can launch Jupyter Notebook.
- Alternatively, you can directly search for “Jupyter Notebook” in your operating system’s search bar to open it.
- When launched, Jupyter Notebook typically opens in your default web browser.
Interface and Usage:
- Jupyter Notebook opens in a specific local directory on your computer (e.g., your C drive user directory).
- The interface allows you to navigate through your files and folders and create new notebooks.
- To start writing Python code, you can create a new Python 3 notebook.
- Code is written and executed in cells. You can write Python code in a cell and run it by clicking the “run” button or by using the shortcut Shift+Enter.
- Jupyter Notebook files have the extension .ipynb.
Key Features and Concepts Illustrated in the Source:
- Basic Python Concepts: The source uses Jupyter Notebook extensively to demonstrate fundamental Python concepts such as:
- Variables and how they store data according to their data types.
- Data types, including numeric (integer, float, complex), string, list, tuple, dictionary, and set, with examples of how to define and check their types using the type() function.
- Memory allocation for variables and how to check their identification numbers using the id() function.
- Keywords and how to list them using the keyword module.
- Indentation as a way to define code blocks in Python.
- Comments using the hash symbol #.
- Operators: Jupyter Notebook is used to practically demonstrate different types of operators:
- Arithmetic operators (+, -, *, /, %, //, **).
- Assignment operators (=, +=, -=, *=, /=, etc.).
- Relational (Comparison) operators (>, <, >=, <=, ==, !=) which always return a Boolean value (True or False). These are also referred to as conditional operators.
- Logical operators (and, or, not) which work with Boolean values.
- Identity operators (is, is not) which compare object identity (memory location).
- Membership operators (in, not in) which check if a value is present in a sequence.
- Data Structures: The source provides examples in Jupyter Notebook to illustrate the properties and operations of various data structures:
- Strings: Including slicing, concatenation using the + operator, repetition using the * operator, and various built-in methods (e.g., .upper(), .lower(), .capitalize(), .count(), .index()) and functions (e.g., len(), min(), max()). It also covers string formatting, skip sequences (e.g., \n, \t), and raw strings (using r’…’).
- Tuples: Showing how to define them using round brackets, their ordered and immutable nature, positive and negative indexing, slicing, concatenation, repetition, and the available methods (.count(), .index()) and functions (len(), min(), max(), tuple(), type()).
- Lists: Demonstrating their definition using square brackets, their mutable and ordered nature, indexing, slicing, concatenation, repetition, and numerous methods (e.g., .append(), .insert(), .remove(), .pop(), .sort(), .reverse(), .clear()) and functions (e.g., len(), min(), max(), list(), type()). The source also introduces list comprehension as a way to optimize code.
- Dictionaries: Illustrating their definition using curly braces with key-value pairs, their mutable and unordered nature, accessing values using keys, and various methods (e.g., .keys(), .values(), .items(), .pop(), .clear(), .get(), .update()) and functions (e.g., len(), type(), dict()). The source also touches upon how dictionaries can be used to represent tabular data and introduces the pandas library in this context.
- Sets: Showing their definition using curly braces (for non-empty sets; a blank set is created using set()), their mutable and unordered nature, the property of storing only unique values, and various operations (union, intersection, difference) and methods (e.g., .add(), .remove(), .update(), .intersection(), .union(), .difference()). The source also mentions set comprehension and frozensets (immutable sets).
- Control Flow: Although not a primary focus of the initial overview, the source implicitly uses conditional statements (if, elif, else) and loops (for) in the Jupyter Notebook examples to demonstrate various Python concepts.
- Functions: The source explains different types of functions (user-defined, built-in, recursive, anonymous/lambda, return statements) and mentions their coverage in the video tutorial. It also differentiates between functions (like len(), type()) and methods (called on an object using dot notation, like string.upper(), list.append()).
- Modules and Packages: The source introduces the concept of modules and packages as Python’s way of providing strong standard libraries. It mentions using the keyword module to explore Python keywords and briefly introduces the pandas library for data manipulation.
- File Handling: The source demonstrates basic file operations (opening, reading, writing, closing) for text files in Jupyter Notebook, along with functions like open(), close(), read(), readline(), write(), writelines(), seek(), and tell(). It also introduces different file modes (e.g., ‘r’, ‘w’, ‘a’). Furthermore, it covers working with pickle (for preserving Python objects in binary format), JSON (a common data exchange format), and CSV (Comma Separated Values) files within Jupyter Notebook.
- Exception Handling: The try and except blocks for handling errors are introduced with a practical example in Jupyter Notebook.
- Object-Oriented Programming (OOP): The source begins to cover OOP concepts with examples in Jupyter Notebook, including defining classes and creating objects, defining methods (including the special __init__ constructor), inheritance (single and hybrid), inner classes, and different types of variables (instance, class, static) and methods.
- Recursion: The concept of recursion (a function calling itself) and the recursion limit in Python are explored with examples in Jupyter Notebook.
In summary, Jupyter Notebook is presented as an interactive environment that is highly suitable for learning and experimenting with Python programming concepts, especially in the context of data science, due to its ease of use, immediate feedback through cell execution, and integration with essential libraries. The source uses Jupyter Notebook as the primary tool for demonstrating a wide range of Python topics, from basic syntax and data types to more advanced concepts like file handling, exception handling, and object-oriented programming.
Python Data Types Explained
Based on the information in the source “01.pdf” and our previous discussion about Jupyter Notebook [Me], here’s a discussion of Python data types:
Python has several built-in data types that are fundamental to the language. The source categorizes these mainly into numeric, dictionary, boolean, set, and sequence types. It further elaborates on these categories, highlighting their key characteristics.
Main Categories of Python Data Types:
- Numeric Data Types: These represent numerical values.
- Integer (int): Whole numbers without any decimal point (e.g., -2, -1, 0, 1, 2). The source mentions that when you check the data type of a whole number in Python, it is shown as int.
- Float (float): Numbers with decimal points (e.g., -1.02, 1.5, 5.86). If a number is defined with a decimal, Python considers it a float.
- Complex (complex): Numbers with a real and an imaginary part, represented in the form a + bj (where j denotes the imaginary unit) (e.g., 5 + 7j). In Python, the imaginary part is denoted by j, unlike the mathematical convention of i.
- Sequence Types: These represent ordered collections of items.
- String (str): Immutable and ordered sequences of characters. Strings are defined using single quotes (e.g., ‘hello’), double quotes (e.g., “India”), or triple quotes for multi-line strings. They support positive and negative indexing starting from 0 and -1 respectively, allowing for slicing. Operations like concatenation using + and repetition using * are also supported. The source discusses various string methods (e.g., .upper(), .lower(), .capitalize(), .count(), .index()) and functions (e.g., len()). String formatting, skip sequences (e.g., \n, \t), and raw strings (using r’…’) are also mentioned.
- List (list): Mutable and ordered sequences of items. Lists are defined using square brackets [] and can contain items of different data types. They support indexing, slicing, concatenation, and repetition. Due to their mutability, lists have numerous methods for modification, such as .append(), .insert(), .remove(), .pop(), .sort(), .reverse(), and .clear(). The source also introduces list comprehension as a concise way to create lists.
- Tuple (tuple): Immutable and ordered sequences of items. Tuples are defined using round brackets (). They support indexing, slicing, concatenation, and repetition. Compared to lists, tuples have fewer built-in methods, mainly .count() and .index(). Tuples are often used for security purposes when the data should not be changed.
- Mapping Type:
- Dictionary (dict): Mutable and unordered collections of key-value pairs. Dictionaries are defined using curly braces {} with keys and their corresponding values separated by a colon : (e.g., {‘a’: 15, ‘b’: 18}). Keys in a dictionary must be unique, but values can be of any data type. You access values in a dictionary using their keys (e.g., D[‘a’]). Dictionaries do not support direct concatenation or multiplication like sequences. They have various methods like .keys(), .values(), .items(), .pop(), .clear(), .get(), and .update(). The source also mentions dictionary comprehension and how dictionaries can represent tabular data, leading to the introduction of the pandas library.
- Set Types: These represent unordered collections of unique items.
- Set (set): Mutable and unordered collections of unique elements. Sets are defined using curly braces {} (e.g., {5, 8, 7.9}). A blank set is created using the set() function, as {} creates an empty dictionary. Sets automatically remove duplicate values. They support operations like union, intersection, and difference, and methods like .add(), .remove(), and .update(). The source also discusses set comprehension.
- Frozen Set (frozenset): Immutable and unordered versions of sets. Once created, you cannot add or remove elements from a frozenset. They support the same operations as regular sets but without modification methods.
Mutability and Order:
The source emphasizes the concepts of mutability (whether the object’s state can be changed after creation) and order (whether the elements have a specific sequence).
- Mutable Data Types: Lists, dictionaries, and sets are mutable, meaning their contents can be modified after they are created.
- Immutable Data Types: Numeric types (integer, float, complex), strings, and tuples are immutable, meaning their contents cannot be changed after they are created. Any operation that appears to modify an immutable object actually creates a new object.
- Ordered Data Types: Strings, lists, and tuples are ordered, meaning the items in the collection have a specific sequence, and you can access them using index positions.
- Unordered Data Types: Dictionaries and sets are unordered, meaning the elements do not have a specific sequence, and you cannot access them using numerical indices. In dictionaries, you access elements using keys.
Checking Data Types:
The built-in type() function is used to determine the data type of a variable. As shown in the Jupyter Notebook examples discussed previously, you can use type(variable_name) to see whether a variable holds an integer (int), a float (float), a string (str), a list (list), a tuple (tuple), a dictionary (dict), or a set (set) [Me, 6, 12].
The source highlights that understanding data types is crucial as it affects how data can be stored, manipulated, and the operations that can be performed on it. The practical examples in Jupyter Notebook, which we discussed earlier, effectively illustrate the creation, properties, and operations associated with each of these fundamental Python data types [Me].
Python Variable Identification Numbers in Memory
Based on the information in the source “01.pdf” and our previous discussion about Python data types [Me], here’s a discussion of variable identification numbers in Python:
In Python, when you create a variable and assign it a value, that value is stored in the computer’s memory. To keep track of where each piece of data is stored, Python assigns a unique identification number to each object in memory, including the values held by variables. You can think of this identification number as the memory address of the data.
The source explicitly mentions the id() function as a way to find out the identification number of an object (and thus, the value held by a variable). For example, if you have a variable a assigned the string “hello” and a variable b assigned the integer 5, you can use id(a) and id(b) to see their respective identification numbers.
Key points about variable identification numbers from the source:
- Memory Allocation: A variable acts as a temporary container that stores data. This storage occurs in memory allocation.
- Identification Number: Every piece of data stored in memory is assigned a unique identification number.
- id() Function: Python provides a built-in function called id() that allows you to retrieve the identification number of an object. You pass a variable (which holds a reference to the object) to the id() function to see its identification number (e.g., id(a)).
- Data Type Influence: The source demonstrates that the data type of a variable can influence its identification number. When comparing the identification numbers of a string variable (a = “hello”) and an integer variable (b = 15), a significant gap might be observed between their IDs. This suggests that different data types might be stored in different regions of memory.
- Memory Allocation and Data Type: The memory ID released depends on the data type. Different data types might lead to different patterns in memory allocation and thus potentially larger differences in their identification numbers.
- Small Integer Range: The source provides an interesting observation about the identity operator (is) and identification numbers for a specific range of small integers (-5 to 255). Within this range, Python might use the same memory location for variables with the same integer value. However, for values outside this range or for different data types (like strings and integers), different memory locations and thus different identification numbers are typically assigned. This behavior is related to Python’s internal optimizations for commonly used small integers.
In essence, variable identification numbers in Python provide a way to uniquely identify where the value of a variable is stored in memory. The id() function allows you to inspect these numbers, and you can observe how factors like data type can affect memory allocation and the resulting identification numbers.
Python Operators: An Overview
Based on the information in the source “01.pdf”, here’s an overview of Python operators:
The source introduces the topic of operators by defining them as symbols that are responsible for performing operations. It gives the example of 5 + 7, where + is the operator and 5 and 7 are the operands. The source categorizes Python operators into six main types:
- Arithmetic Operators: These operators are used to perform mathematical calculations. The source lists the following arithmetic operators:
- + (Addition): Adds two operands (e.g., 4 + 7 results in 11). It can also be used for string concatenation (e.g., “hi” + “hello”).
- – (Subtraction): Subtracts the second operand from the first.
- * (Multiplication): Multiplies two operands.
- / (Division): Divides the first operand by the second, resulting in a floating-point number.
- % (Modulo): Returns the remainder of the division of the first operand by the second. The source refers to this as the “modulo operator”.
- ** (Exponentiation): Raises the first operand to the power of the second. The source explicitly mentions this “double star” operator.
- // (Floor Division): Divides the first operand by the second and returns the integer part of the quotient, discarding any remainder. The source highlights this “double slash” operator.
- Assignment Operators: These operators are used to assign values to variables. The source provides the following examples:
- = (Assignment): Assigns the value of the right operand to the left operand (e.g., a = 7).
- += (Add and Assign): Adds the right operand to the left operand and assigns the result to the left operand (e.g., a += 5 is equivalent to a = a + 5).
- -= (Subtract and Assign): Subtracts the right operand from the left operand and assigns the result to the left operand (e.g., a -= 7 is equivalent to a = a – 7).
- *= (Multiply and Assign).
- /= (Divide and Assign).
- %= (Modulo and Assign).
- **= (Exponentiate and Assign).
- //= (Floor Divide and Assign).
- Relational Operators (Comparison Operators, Conditional Operators): These operators compare the values of two operands and return a boolean value (True or False). The source lists these operators:
- > (Greater than).
- < (Less than).
- >= (Greater than or equal to).
- <= (Less than or equal to).
- == (Equal to): Compares if two operands are equal. The source distinguishes this from the assignment operator =.
- != (Not equal to).
- Logical Operators: These operators perform logical operations and are often used to combine the results of relational operations. The source identifies the following logical operators:
- and: Returns True if both operands are True. The source notes the importance of using brackets when combining and with other logical operators to avoid ambiguity.
- or: Returns True if at least one of the operands is True.
- not: Returns True if the operand is False, and False if the operand is True.
- Identity Operators: These operators check if two operands refer to the same object in memory. The source mentions:
- is: Returns True if both operands refer to the same object. The source notes it is similar to == but works with memory allocation. It highlights that for integers in the range of -5 to 255, is might behave similarly to == due to Python’s memory optimization, but this might not hold for values outside this range or for different data types.
- is not: Returns True if both operands do not refer to the same object. It’s similar to != in that it checks for non-identity based on memory location.
- Membership Operators: These operators test if a value (operand) is found within a sequence (e.g., list, string, tuple). The source lists:
- in: Returns True if the value is present in the sequence. The source gives an example of checking if 5 is in a list.
- not in: Returns True if the value is not present in the sequence.
The source also briefly mentions a bitwise operator, noting it is not much required for general programming but can be important in specific fields like electronics. It provides a resource for further learning about bitwise operators.
In summary, the source provides a foundational understanding of various Python operators, categorizing them by their function and illustrating their basic usage with examples. It emphasizes that practical implementation in a Jupyter Notebook (available via a link in the video description) is crucial for a deeper understanding of these operators.
Python Indentation: Defining Code Blocks
Based on the information in the source “01.pdf”, here’s a discussion of indentation and blocks in Python:
Indentation is a fundamental concept in Python that is used to define code blocks. Unlike many other programming languages that use curly braces {} to delineate blocks of code, Python relies solely on whitespace (spaces or tabs) at the beginning of a line to indicate which statements belong to a particular block.
The source emphasizes that in Python, curly braces are not acceptable for defining blocks. Instead, after certain statements that introduce a block (such as if, elif, else, for, while, and function definitions), a colon : is used, and the subsequent lines of code that belong to that block must be indented.
Key points about indentation from the source:
- Defining Blocks: Indentation is how Python determines which statements are part of a specific block of code, such as the body of a conditional statement or a loop.
- Colon Precedes Indentation: Statements that begin a new block of code are always followed by a colon :.
- Four Spaces (Typically): The source notes that in environments like Jupyter Notebook and PyCharm, an indentation of four spaces is automatically taken after a colon. Other IDEs might default to two or eight spaces, but consistent use within a project is crucial.
- Block Delimitation: The level of indentation determines the scope of a block. Statements with the same level of indentation are considered part of the same block. If a line is not indented at the expected level, it is considered to be outside the current block.
- Example (from the source):a = 9
- b = 8
- if a > b: # Colon indicates the start of a block
- print(“hello”) # Indented – part of the if block
- print(“hi”) # Indented – part of the if block
- print(“hey”) # Indented – part of the if block
- print(“bye”) # Not indented to the same level – outside the if block
- In this example, the print(“hello”), print(“hi”), and print(“hey”) statements are inside the if block because they are indented. The print(“bye”) statement is outside the if block because it is not indented to the same level.
Blocks in Python are sequences of one or more statements that are treated as a single unit. They are defined by their indentation level. Blocks are typically associated with control flow structures (like conditional statements and loops) and function/class definitions.
Significance of Indentation:
- Readability: Python’s use of indentation makes code very readable and enforces a consistent visual structure, making it easier to understand the flow of control.
- Syntax: Indentation is not just for readability; it is a syntactic requirement in Python. Incorrect indentation will lead to IndentationError and will prevent the code from running.
In summary, indentation in Python is not merely a matter of style; it is a core part of the language’s syntax used to define code blocks. Consistent and correct indentation is essential for writing valid and understandable Python programs.
The Original Text
nowadays Python programming language is booming day by day and it’s required for every industry in Automation in data science in data analysis artificial intelligence and many I made this course for absolutely for beginner from basic to advanc level in easy way and you’ll find it out the complete resource on a GitHub that link is available on description let’s first discuss what topic we’ll cover in this video so for first we’ll start with the overview where we will discuss about history and why should we learn a python what their competitor why should we learn a python for data sign if the lots of programming language is available then we’ll install the required software like py Cham Jupiter notebook anac iser software will anac iser providing the Jupiter notebook and spider so initially we’ll start with a Jupiter notebook and after that we’ll also discuss somewhere pyam as well depend on the requirement and then we’ll discuss about their basics of pythons like uh we’ll discuss variables keyword indentation commands so these are a topic we’ll first discuss and after that we’ll enter the very very important topic which is the backbone of data science data types so numeric string tle dictionary set these are data type this is the primary data type we can say we’ll discuss then and after that conditional statement and loop okay so all the uh Topics in a condition statement and loop will cover and after that functions so user defined function inbuild function recursion function Anonymous function return statements so lots of topic is there in a function will cover each and everything and then package and modules so python become strong because of large standard libraries so library is made with packages and module so we’ll discuss that topic as well so user Define predefine and find search path and some names SP lots of topic is there we’ll discuss in this video tutorials so we can say these are a topic it’s a Basics and intermediate and advanced python is also there which one is file handling will discuss exception handling objectoriented programming and multi-threading let’s discuss about the complete overview of python so here in the market so many languages is available but why should we learn a python right so our entire tutorials is a focused on the data science I’ll take the example of the data science and uh in that direction we’ll discuss so basically machine learning and artificial intelligence obviously it comes under the data science will build on the mathematical principle like a calculus algebra probability statistics so we have to choose those programming language which is very much compartible with this mathematical concept because because nowadays the this Ai and automation concept is booming right so we have to choose those language so python obviously is the best for them but what is the reason before going to the python let’s understand the concept of the machine learning okay so machine learning basically a application of artificial intelligence when a machine can learn automatically from the previous experiences let’s say for example you meet a person after 5 year okay and suddenly you start predicting that the person can be the Priya Raju and moan any any name you are just start predicting and how we able to predict predict it the reason behind that because that kind of pattern is already store in your brain so accordingly you are predicting okay so in a real life so we have the large amount of data let’s take example of Instagram so Instagram the huge amount of data they are recognizing the pattern and accordingly is giving the suggestion to you right so in that algorithm in that pattern Rec in pattern calculation we required a those programming language which should be compatible with the mathematical concept so python is one of them but why python why only the python why not other like only the python can be used in the data science the answer is no we can use the any programming language language in a data science in a machine learning but we have to choose those which is comfortable with mathematical concept so let’s understand that so in a real life there is a two type of categories there of a programming language the first one is a static and the second one is a dynamic what is a static static in the sense so we’ll take example of java in a static and python as a dynamic okay Java is a static programming language and python is a dynamic programming language so basically we are writing uh Java like uh in this this is the script of a Java we’re writing the code but here when you’re assigning the value is 9 uh in a and four in a b so after the calculation a divide by B the answer should be the 2.25 but you’ll get the answer is two the reason I already defined the data type okay Define the data type which is a integer because of the integer it will print only the two so what is the concept behind that because it will take the values the 2.25 it will take the inputs but after translation after the translation it will start comparing the target values which is the C this is the target variable and value is a 2.25 comparing with the input values which is a in C after comparing whatever values we get it and that is showing as a result which is a two all right so the translator in a Java programming language we are calling the compiler okay so compiler is nothing but a translator not in a Java in every programming language compiler is exist but in a Java we normally calling compiler in a python we have a different name but the compiler is there a different name is is inter uh interpreter okay so we understand that the Java is a static programming language but how the python is working so python is a dynamic programming language it directly take the inputs translate it and getting the result how basically is working you can directly assign a is equal to 5 b is equal to 8 and C is equal to B / a and when you just divide it you’ll getting the proper decimal values I’ll I’ll show you some real example okay I’ll show you some real examples so that you can easily understand suppose I have a value is a is equal to 5 b is equal to 8 and C is equal to B / a and get the value C that will getting 1.6 that is the proper floating values but when you just take the data type of a you’ll get the values is integer when you check the data type of B you’ll get the uh data type of B which is a integer but when you check the data type of C which is a float automatically converting the data type so the conclusion is that in the static and dynamic in a static programming language we have to take care about the data type where the dynamic programming language we don’t need to take care about the data type but again so as I said that the every programming language have a compiler means the translator have also the compiler but why it’s not comparing you the input values the reason behind that so whatever source code you have so again the compiler will help you to convert your source code into bite code and there is a virtual machine is available in every programming language like in a Java we we have a jvm in a python we have a pvm python virtual machine so here the compiler and virtual machine is running together that’s why we are directly getting the answer and in a jvm jvm the translator and virtual machine is a running separately so that is the reason we are getting the result based on the input values so which one is a dynamic programming language which one is a static programming language we can say the python JavaScript JavaScript and Java is both are a different language script and Par language and Julia these are a dynamic programming language where is a Java C C++ these are a static programming language okay so these are all these all are a dynamic programming language are matlb Julia SAS JavaScript scalap python this all are a dynamic programming language then again why we choose a python right for a data sici why not we are choosing the r language why not a mat Li so again these all are good to choose uh um uh for data science but every programming language have a limitation python have also the limitation but it our label almost every field if I want to use a Python programming language in the web development via Jango and a flask we can you easily implement the web application if I want to go in a cloud infrastructure that python option is available the data analysis is there in a testing field is there so almost every sector python is available because when you go in a Technology field so it’s not like that you’re you’re doing the analysis on uh you know some uh some PP and dashboard you show in and finished no behind that the lots of pipeline is running so in the pipeline so python is also very good in a data engineering as well so that is the reason python is become very famous and most of the companies are using this python so let’s conclude it what exactly the python this this will be the definition of a python so python is nothing but whatever discuss we’ll just summarize it here so python is first of all high level programming language high level in the sense those language which requir the translator is a high level so almost every programming language is a high level there is two language is a low level and high level low level in the sense machine language which is a binary which computer understand but we are not writing the code in a binary format we writing the code in the normal format like A + B / by 2 so it is a high language source code for computer the high language is not for human not for a student it’s for a computer the computer is saying that hey I understand only the binary and you’re writing something so I need a translator so that is the reason the computer is saying that it’s a high level second one is interpreter language which we just discussed and uh uh for translator we are using this interpreter and uh dynamically type language okay just now we discussed and it have a large standard libraries almost every field the python is available just because of large standard libraries okay so for if I want to do anything just have to install and start implementation it’s not like like that easy but yes the option is available to work in any any uh domain with python so it’s a portable portable in the sense it’s comfortable with any operating system we can use with the uh Windows Linux and Mac so even in the Linux it’s by default the python is available the reason behind that I’ll discuss in a history of python okay but it’s a comfortable with uh all the three operating system a the main thing of the portable language is that suppose I wrote a program in uh Windows operating system and one of my friend is using uh Mac or uh Linux so they don’t need to change any kind of environment they can directly use it if they have a python okay so that is a meup portable it have EXT uh extensibility features in the sense inside uh python I can also write the r language I can write a Java language J python option is also there so we we can extend our Python programming language so python is also supporting the objectoriented concept which is very very important for a software development almost 99% of software is making with objectoriented Concept so that is the reason Java is become very very famous because of this oops concept and again the last concept uh last topic is a free and open source free means you don’t need to pay anything open source in the sense so that source code is available for us we can also check it okay so whenever you install the python that any if you have any libraries like if you install the pandas okay which is famous libraries for a data science if you install the pandas so behind the pandas uh whatever source code is there we can also check it so that is the meaning of source code so let’s discuss about the history of python so history of python is very interesting uh like U um the python is old language or a new language uh in nowadays the two languages are very very famous is Python and Java right so Java is is a versatile language like almost every field is available it’s capture the market um it but the people are thinking that uh the Java is old but answer is no Java is not old python is old those who made the python the name is a good when rasim goo van R so this guy is made started implementation in 1989 so he was a mathematician he was a very uh you know famous mathematician he got many medals in the mathematics uh he did a masters in uh mathematics and computer science so he start doing researching in the mathematics so his main focus was that to um you know solving the mathematical problem so when he started the uh python in 1989 when the Java comes in the market is the 19 1996 1996 okay so it started in the 1989 and uh and he released the first he released the first version is is python 0 .9 which supportable for one andux after that he released for everyone he released for everyone and uh uh you know that be supported for Windows Linux and uh uh Mac all the operating system and this um the Python programming language is start becoming famous after 2000 okay when he released the 2.x version so even nowadays we also confused that which one we have to use 2.x or 3.x that I’ll discuss uh after this after this history so here when he release the 2.x this Python programming language is properly enter in uh software development field before that he was this programming language was in research field in uh mathematical research you can say uh so before the Java is entered in a you know in um a software development field that’s why we think that the Java is very old but actually the python is old programming language actually this guy is working in a many famous companies like uh Google Microsoft Microsoft and Dropbox so these famous companies is worked on it so python has become famous when he was in Google he was in Google in a 2000 5 to 2012 2005 to 2012 he was doing half of the work to developing the python so when he released the 3.x version of 2008 so that time the python start booming in all over the world especially in the data sign and artificial intelligence field because the Google company already doing a lots of research in artificial intelligence so he got a very good opportunity and uh python we Implement python is become The Versatile programming language and the people I start using after 3.x version so sometime we confuse that what is the difference uh between the 2.x and 3.x actually when he released the uh 2.x version 2.x so he forget to implement the object Orient concept so later when he try to implementing the object oriented Concept in a 2.x so the P the programming become very unstable so that is the reason uh he started a 3.x version and even the many people already started the 2.x that’s why he didn’t deleted that uh version but we can say the 2.x is a kind of Legacy but if you are a new if you are a beginner it started the uh this Python programming language so obviously you have to use 3.x you don’t need to use 2.x okay because when you write the the syntax of the Python 2.x and 3.x is a little bit different so like if you want to write a p uh print statement for example uh print hello world hello world so in a threo x we are writing like this but if you want to write in a twoo x so you have to write print double quotes hello world so there is no any bracket so the syntax is also different because the 2.x is not completely supporting the objectoriented programming language installation of Jupiter notebook we have a multiple option is available you can choose anything so like we have a anaconda let me just change the color yeah we have Anaconda we have a minond okay so multiple option is there so uh even you can directly uh install the Jupiter notebook via the command prompt as well but we will choose the Anaconda okay because Anaconda is giving the three options uh for a data science which is really useful for us so you will find it out a jupyter notebook first okay you’ll find a jupter notebook and you also find it out the spider which is very helpful for uh data science even uh in Anaconda is a pre predefine the many libraries so which you don’t need to install it like a pandas naai M plotly this libraries is preinstalled you don’t need to install it separately so many uh option is there so you can use it so we’ll install here the Anaconda and after that we start the installation solution of spider and Jupiter notebook so let’s do that so you can directly go to the official website anakonda just go there you’ll find it out the free download option just click on download that’s it your downloading process will start when you just check it let me just cancel it this my my downloading is already um on I put on a run so it will taking a Max to Max 1 minute to complete it and after that I’ll start the installation so yeah downloading process uh is completed I think so I can also check it in a download no it’s still downloading I think it’s taking ah now it’s downloaded so you can go there it’s showing the uh this icon double click on it it’s very simple just double click on it okay so it’s verifying and just click next I agree just me next you don’t need to change anything just next install you can just add the uh anakonda 3 in your environment if you’re not adding it’s not creating any problem just click install that’s it now it’s completed I think just click next so you can see here the Anaconda Jupiter notebook logo is mentioned there just finish it okay it’s giving the for uh registration for free and so many option don’t do anything just close now back click on Windows you’ll F and all app whatever which one you are using Windows 10 Windows 11 you’ll find it out the Anaconda 3 folder so where we have a anaconda Navigator where in case if any jupter notebook or spider anything is not working properly go to the anakonda navigator that work like a setting and you can use it so anakonda prompt is a kind of command prompt okay so I think it start opening the anakonda Navigator even I I’ll show you as well so in this anakonda prompt you can install any libraries with Pip or k environment so this is like a uh prompt which we have a local machine as well so this Anaconda is provided their own prompt okay this one is the Navigator let me just close it this one yeah Navigator the so many option is showing in case if anything is not working you can launch it from here like py Cham or um yeah py Cham professional R studio so many option they are showing but you don’t need to do anything this one let me just close it okay back to that uh folder again Anaconda 3 yes so you’ll find it out a jupyter notebook and a spider you can just open on it so for Jupiter notebook you can open from here or else you can directly search Jupiter notebook okay will search Jupiter notebook in this location so automatically the Jupiter notebook is opening on the default location which is uh it’s showing the uh prompt here it will open the uh Jupiter notebook in this location C drive you can see the serving notebook from the local directory C user your PC name all right so you can check it so where is it store opening so always opening in this location so my jupyter notebook is open here you can just directly click on new Python 3 and start writing the code is here sometime your jupyter notebook is opening on a you know Chrome or sometime opening on a Internet Explorer so which one is your default um uh web browser okay so you can write here print hello world let me just type it here hello world and click on run you’ll get the answer here so now Jupiter notebook is a properly installed let’s discuss about the third module basics of python where we’ll discuss about variable keyword indentation data type commands and lots of things the very first one is a variable variable is nothing but a memory allocation which store the data according to their data type okay for example I have one one data I want to store somewhere so we need a container right so variable working as a temporary container which store the data and we need a data type to Define that so if you storing the data and is defined with a data type like hello stor in a five store in a b so hello is store according to string data type and it is storing in the variable a five is storing in a b according to integer data type so whenever we Define the data types it it release the identification number so every data is storing in memory allocation and Define the identification number let’s understand with the uh practical implementation so I already created the proper Jupiter notebook file you can easily find it out on a description in the link that Jupiter notebook file okay so hope you know that how to open the Jupiter notebook in particular location so I have created my proper folder so file is available Basics so when I click on there so I can easily open my basic file that’s i p ynb file we can say jupit notebook file let me create a new Cale and write it down here no normal variables like a is equal to hello so when I click this button I can easily run it and when I just check the data type so there is a function predefined function is a type so even the type this topic is there function so where we’ll discuss we’ll create a function as well to check that what exactly the data type we are using the type of a so that’s a string data type when I check that b is equal to 15 and check the type of B then you can find it out it’s a integer data type and python is showing as a int so now as I said variable is nothing but a memory allocation if it’s a memory allocation which store the data that means it release some identification number as well so we can easily find it out like a ID there is the ID function where find it out the identification number when I pass ID of a so you can see here this is the ident identification number okay when I just check the ID of ID of B that is a identification number of your B variable and a variable actually the when you see the differ between the Vari variable a and variable B so lots of Gap is there because a is a string data type whereas B is a integer data type suppose I have a variable um C is equal to 0 and check the DAT uh check the identification number so ID of C this is the ID of c and a simultan I’m also checking with idea B then you’ll find it out the lot Gap is not there Gap is there obviously because the number is a different so when I just check it here you can see the last few digit is only change okay last few digit is only change but when I check with this one the lots of Gap is there reason we change the data type so it release the memory allocation memory uh ID depend on their data type if I’m taking the different data type the that will also be number D is equal to 19 + 19.8 and check the ID of D that will be the uh different identification number it’s not only the few digit is change so lots of values change also reason we change the data type because the D is a floating data type when I just check the type of d That’s a float data type so these are a variable hope you understand how the variable is working but I as I said when I Define any variable like a b is equal to 15 and it store the data according to the data type so now what is a v uh what is a data type so in a Python programming language the lots of data type is there so here python have a main category of the data type numeric dictionary Boolean set and sequence type where we have the main data type is a integer complex and Float integer complex and Float okay so we have also the another data type like a dictionary bullan set is also there and set oh yeah set is there string list and tle that’s comes under the sequence type so these are nothing but just a category so in the coming videos we’ll discuss about very details with each and every data type dictionary set string taple each and every data type will discuss in a very details way but let me just show you how the list is look like how the uh you know uh tle is look like how the string is look like so as you already see that how the integer look like if any number which Define without any decimal that’s a integer so here so data type we have different different data type is available like uh we have a string like if I’m defining with a double quotes so like hello here so that’s a string data type you define B is equal to in square bracket that will consider as a that will consider as a list if I Define with a round bracket that will be considered as a tle if I Define with the curly brasses curly brasses directly passing the values that is considered as a set if I Define the same value with key value pair is equal to key value pair like 5 colon 4 uh 4 colon 7 and 9 colon 8 so if you define like this that will be considered as a dictionary okay so that’s a dictionary that’s a set okay so what exactly the mean of this hash this hash symbol hash symbol is nothing but a comment we are defining as a comment so that’s a set that’s a topple that’s a list okay so these are a different different data type and this one is nothing but a string so in the coming video we have to discuss in the very details of each and every data type now let’s discuss about the keyword what exactly the keyword so keyword is nothing but a reserved word which can be used for only specific purpose and cannot be used as a identifier let me just write it down keyword keyword is reserve word which used for one specific purpose fake purpose cannot be used as a identifier cannot be used as a identifier now the question is what exactly the mean of identifier let me make as a uh markdown so that markdown in the sense it will taking one statement it will not consider as a code okay normal statements so cannot be used as a identifier so what is the identifier identifier so identifier in the sense any variable name any um you know uh function name okay any variable name any function name any class name that will be consider as a identifier class name that will be considered as a identifier okay so now the question is how many Reserve word is available in Python programming language so here in the lots of Reserve word is available but U to check that how many Reserve word is there so there is one module is called as keyword module keyword module keyword module and when you pass it here keyword do KW list then you’ll find it out how many keyword is available for false none true the lots of keyword is available is Lambda lots of keyword is there which is stored with a square bracket one container and that container we are calling list okay so as I said keyword is a reserve word which is used for only specific purpose cannot be used as a identifier used as a identifier what exactly the mean cannot be used as identifier like if I’m creating any normal variable able okay let me create one normal variable my variable name is a equal to 8 so I can easily Define it to not create any problem we can easily Define it here a is equal to 8 can I use uh any keyword like uh if I’m using if Okay small i f if we are using IF is equal to 8 can I define it like this no it will giving the error because because this if is reserved for only the conditional statement you can’t use as a identifier you can’t use as a normal variable so if is used for one conditional statement like if L if else true false is used for one bullion purpose okay so uh class is used for only object oriented break is only for breaking the loop so these are a reserved word which cannot be used for a normal purpose now I want to see that how many Reserve word is there I want to check that how many values is available first thing is that you have to just calculate one by one so this is the uh not a right way so the better is we can use like this there is one function is called as alen length which which will be count each and every element and tell you how many element is available in that container so I’ll use the keyword KW list and when I run it will showing you 30 five keyword is available okay so whenever you using any uh ideally right now I’m using the Jupiter notebook ideally so that time you can easily check it and uh you know the future definitely the python will increase the keyword okay so right now I’m using Jupiter notebook which is considered a 3.9 version which have the 35 keyword is available hope you understand this keyword now let’s discuss about indentation what exactly the indentation indentation in the sense is Define the block I have some program uh like if program uh conditional statement program if a is greater than let me first Define it a is equal to 9 and B is equal to 8 and I have a program is if a is greater than b okay so in other programming language we are using the curly brasses and put inside a statements so here curly brasses is not acceptable so we have a indentation we have to use a colon after the colon it automatically taking the four space okay automatically taking the four space if I’m writing here if you’re going with any other ideally uh maybe it will taking a two space eight space but in a Jupiter notebook and a py Cham is taking the four space if I’m writing here the hello okay so if you want to Define anything like hello if I’m writing here and hi if I’m writing here and he if I’m writing here print he okay this hello hi hey yeah we can say line number 5 six 7 that’s comes in if block so defining the block we are using if uh colon and automatically taking the for space if you’re using the back space and write it down here print by so that line number nine will consider as a uh outside of the block so that bu is not in if condition okay by is not in if condition so here we can see we are using by outside of the block because I I’m not using this four spaces so that’s called as a indentation if you have a single line of commands so we normally using like uh I have a statement is a print hello world and just use the hash if you’re using the hash it will be considered as a single line command like if you run it here you’re getting the answer is hello world I’m using the hash it here so it will making as a comment so single line comment we are using hash and for a multi-line comments suppose if you have multi-line of statements uh I have a same thing yeah this one I want to make a comment so for that you have to use a triple codes 1 2 3 okay start with triple codes and end with 1 2 3 normally when you just run it without using this triple codes it will showing the answer perfectly showing the answer hello hi whatever the program is there accordingly showing the answer but if you’re using the triple codes one 23 and one two 3 run it you’re not getting the answer you’re not getting the answer here actually it’s showing the as it is statements uh this triple quotes is also used for string as well so in a string time we’ll discuss that okay but it is also used for a multi-line commands so this one is a single line commands and this one is multi-line commands we are also using the double triple codes like this one this one okay so we also using a double triple Cotes so it’s a multi-line commands we are using that’s the same thing but we mostly using this hash for a single line comments if you have the multiple lines we using the multiple lines as a single single line of comment with hash now input and output function so suppose if we have any normal uh function like Y is equal to 3 x + 5 so mathematically equation is there I want to apply some input and output function in this equation so where X will working as a input because when you are passing the different different input like 2 3 4 if I’m passing two so two 3 6 + 5 11 when I passing different different input accordingly you’ll get the output so here let’s take X as a input X I’m taking as a directly 8 Y is equal to 3x + 5 3 3 into x + 5 3 into X so Define the multiplication we are using star symbol x + 5 and I want to display it so for a display for output purpose we are using the print statement print function I’m writing here x so when you run it this one run button or else we have a shortcut is a shift enter when you click this cell you’ll find it out the shift enter run the cell and select below as well I’m using it here shift enter okay shift enter so it will showing the answer is eight now I want to this one as a user input so we can take is a input there is a input function and pass the statement is enter the value of x take a space so this one will taking the proper user input and pass it here 3 into x + 5 and accordingly generate the answer is 8 if I’m passing uh you know two isas here so let me just run it asking the question enter the value of x I’m passing the value is a five I’m expecting that three 5 15 + 5 is a 20 but it’s showing the error reason because this input function by default taking as a string so in saying that cannot can only concatenate with a string to string not to string with integer actually the X variable is taking as a string when I just Che it here type of X that taking as a string and X is taking as a string three is a integer so cannot be multiplied with string and integer so we have another function is int so likewise other data type like int float complex we have a function as well I’m using int open the bracket and close it here when I run it it asking the question enter the value of x I’m passing here five then it will be calculate and showing the answer is five now I want to Define it properly uh like result is five so the result is five is the statement I’ll Define in the double quotes result is and then five will display here so result is is nothing but your double uh statements or string and is your number so we have to separate it with a comma when I run it asking the question enter the value of x 6 so um sorry not to display uh X we have to display y let me run it again enter the value of X4 and accordingly is getting the answer is 17 now this time when I just check the type of X showing the answer is integer not to string okay so where X uh X is taking as a input we took the in function is input function so this is the input and this one is the output okay this one is output So based on this uh input output and uh variables so I Define the exercise so you can easily find it out description in this video and that uh exercise is also available you just run it then you’ll understand with a different different scenario of variables data type and input output function continuing the basics of python last topic operator is remaining let’s finish in and after that we’ll discuss about the next topic is a data type so operator is nothing but the symbol which is responsible to do any operations for example I have a five + 7 so the plus is a responsible to do addition operation so this one we can say it’s operator this one is operator and five and seven is called as a operant operants okay so there is so many symbols is available in the programming language so we categorize in many way so that categorize in such a way so that we can easily remember it so there is a six main operator is remaining the first one is arithmetic operator assignment operator relational operator logical entity and membership operator so one operator is also there is a bewise opor which is not much required for um for pro as a programming perspective if you belong to the any edic field so that time is really important but still I’ll give you the resource where the bewise operator is also available so you just run it you will also understand the beat wise as well but this main operator list try to understand it in a theoretically and practically both the way the first one is arithmetic operator as I said that the symbol are available plus minus the star so I think you guys is already aware about that so the meaning of the plus is nothing but using for addition minus is for subtraction so we can directly use this kind of symbol so only this double star uh modulo that percentage symbol and double slash is something new for you so let’s discuss about that and we’ll also discuss some um you know uh this basics of this operator as well in a very short way let’s jump on a practical implementation like if you’re writing here the 4 + 7 then you’ll get the answer when you just run it you’ll get the answer is 11 so plus is a responsible to do the adding two things adding two numbers right but if in case if you’re using this both the this operator Plus for a string like a hi plus hello which is responsible to do the concatenation that we’ll discuss in the very details in in string topic but plus is responsible to do some operations right I was discussing about you know the modulo operators and uh uh uh and flow division operator so I have created the complete uh you know Jupiter notebook file so you will find it Out Below um below this video you’ll find it out the link you can go through it and just run this file you can see here what is the mean of plus minus everything is there I properly created here you just click here and run it you’ll find it out the answer in case if you find it out any confusion anything you can just put the comment below okay so everything just you have to run it you’ll understand easily this how the symbol is working right so this is the arithmetic operator and uh when you go to the next operator so that we have assign assignment operator assignment in the S assigning the values right if I’m writing the a is equal to 7 the meaning is that 7 is assigning to the a right so but if you’re writing the a is equal to is equal to 7 that is meaning is totally different you are comparing a with seven so here the assignment operator is available like uh uh when you just use a equal to 7 at the same time if you’re using A+ is equal 7 the meaning is that plus is equal to 7 is that a + equal 5 is meaning is that a equal a + 5 so again you will understand very easy way if you’re doing the Practical okay so I’ve created the uh all the assignment here all the arithmetic operator if you’re using is equal to like minus is equal to Star is equal to SL equal you’ll get these values a minus equal 7 is equal to a = to a – 7 right it’s very simple way go back to the Practical so here you’ll find it out the assignment operator as well so like here a is equal to 5 and B is equal to 3 I have assigned it where is that here short shortcut key to run this U jupter notebook shell shift enter so a five is assigning to the A and three is assigning to the B A is equal to a plus b so you’ll getting the answer is a whatever values is of available five + 3 that 8 will be assigning to the a you can see here but B you’re not assigning anything so B will be the original values which is three right this all the values I have just created you can you can perform with all the operation all the combination you’ll find it out in confusion you put the comment you will find it on on a GitHub we will put the comment or uh uh YouTube itself you know comment you can put it I’ll reply you okay I consider that is very easy things because in our school days we already learn this kind of things addition subtraction multiplication so only this module and flow division is something new for you when you just run the jupyter notebook you can understand easily let’s talking about the third operation third operator sorry not operator operation third operator is a relation relational operator somebody is also calling the comparison operator because you are comparing a isal to 5 is there b is equal to 7 is there if you’re writing a greater than b you can also write B is less than a that means you are comparing the answer is always The Logical format what is a logical logical format can be true can be false true or false answer right your answer will always be the true and false concept you comparing like a is less than b a is greater than or equal to B this is the symbol for not equal to this symbol for not equal to this is symbol for equal to equal to in the sense a is equal to 5 is already assigned let me assign some other values uh C is equal to 18 and D is equal to again 7 okay so if I’m writing the C is not equal to a so obviously C is not equal to a right so you can see you’ll get the values is true because C is 18 and a is five which is really not equal to True uh not equal to uh both the values you’ll get the answer is true it’s really not equal okay so this kind of thing is mostly using in the conditional State this name have also one more name is a conditional operator yeah have this one have a three name relational operator comparing comparison operator and the third one is a conditional operator conditional operator okay so we can provide the condition and you’ll get the values is either true or false answer go back to the Jupiter notebook you can just perform the operation like here when I just run it uh result is always in the bullion bull this this value is a bullion okay this values is a bullion logical in the sense logical is a operator where true and false is the value is a bullan values again uh see the next operator is a uh logical operator this concept will be clear okay so a equal to equal to B A is less than greater than when you just run it you will get the either true or false answer why it’s a is H so A and B is not the same that’s why it’s giving the answer is false a is greater than b so the answer is giving the true a is not greater than b okay maybe I didn’t run the this command that’s why yeah it’s taking the previous A and B values you can see here a is not equal to equal to B I wrote it that getting the answer is false where a is greater than b so a is five and B is a 7 that giving the answer is false because five is not greater than 7 okay if is not equal to you can also write the concept like if uh uh a equal to equal to 5 actually the a is a five I assign the values and I’m also writing the five when you just run it you’ll getting the answer is true okay the next operator which I discuss in this uh uh operator as well let me just remove it the next operator is uh yeah okay so next operator is logical operator as I said that this is always giving The Logical format we can say the value is a bullion true and false is a bullion okay logical operator is and or not okay and or not so a b let’s consider as a variable and if your value is a true if a is a true B is a true so A and B become a true so this is the rules which you are following in The Logical operator it is there in uh physics and Mathematics everywhere in a programming language we are not changing anything whatever you learn in engineering or uh 12th so that is the same thing here so A and B if anything let me just remove if anything is a false that will be the false see here true false that value will be the false in case if the value is true and true and false the answer will be the false if any one values is a false and operator will give the values false here is a false that’s why it become false if everywhere is a false like here and here is become a false or operator is a totally opposite if anywhere is true giving the answer is true so here both are true that’s why is true one is true that’s why is it true one is a true that’s why is a true and false both the places have a false that obviously it become a false okay so where when you’re talking about the not operator is a totally opposite false to true true to false go back you can find it out the Practical as well so you can see here I performed the lots of operation here so here it’s uh uh something interesting so here I assigned the values a b c c and a both are a same values here I assigned a is greater than b so which is a buan values that can be true that can be false So currently a is greater than b which is uh obviously uh you know it’s a false because five is not greater than C and B is greater than C with seven is greater than five that is all that is true so false and true that become a false so likewise you can just run it you’ll find it out the values not operator is a totally opposite right so not operator like you getting a false this one become true okay so here sometimes a confusion is that uh we use the this symbol and sometime we use this symbol what is the confusion both are same or both are different okay let’s discuss that so to discuss that so we have to go a little bit in bewise operator as well so as I said that it’s not more important as a programming perspective but you should know about that you don’t need to go in a very details way because the beat wise operator is very very big concept okay so here um we have a two symbol we have a a and b and we have a this one as well we have a o r we have a this one as well we have a not we have this one as well so this one we can say it’s a logical values logical values and this one is a b binary values uh B twice values okay this one I can say logical and this one is say the beat wise values so if you write the values is like this let me just compare it suppose the a value a is uh you’re writing here we already have a ABC right so the a uh through okay a is greater than b which is uh false and B is greater than C which is true then getting the answer is a false but when I just go with that this uh different symbol and symbol this one you also become false I have to get some example where getting the opposite values then I can explain you in Easy Way ah I think this one is the best one 15 is greater than 16 which is a false 5 is less than 8 that’s it true so it here the giving the answer is false because this one is a uh this one is a false and this one is a true so answer become a false so when I just perform the operation is here here is the and symbol and here is the and is giving the different answer what is the reason it’s giving the two different answer as I said that is both are very similar not the same okay so so but if I’m just use the bracket here you’ll get the answer is false what is the difference here so don’t be confused anywhere you can use and anywhere you can use and symbol the only you have to take care about the brackets but why is Valu is changing first I’ll just explain you and after that I’ll go to the next operator okay the value is changed because so you can see here the and operation is directly apply The Logical right this one is taking a true uh this one is taking the false this one is taking the true this one is a true this one is a false but when you’re talking about this one so actually it will be in because of the order wise so preference of this uh uh relationship operator like less than or greater than is a below as compared to this so this one is a bwise operator the actual the 16 and five is uh apply the operation and getting some different number how it’s working I’ll show you okay why it’s not removing okay sorry so you can see here let me just remove first okay you can see here if I’m just perform the operation is a 16 and five you’ll get the different values right 16 and five and when you just perform the operation is a 16 and 5 you’ll get a zero why is it totally different the reason behind that when you just perform the operation the the 16 and five will converting in the binary format so uh there is a proper concept is there like uh the 16 if you want to convert in a binary so uh we have the binary format like uh uh Power of Two only so 2 to the^ 0 2 ^ 1 2 The Power 2 2 The Power 3 like this so this one become a 1 2 4 and uh this one become 8 so if you find it out the value of 16 okay and this one will be 2 to the power uh 4 that will be 2 2 4 2 8 2 16 so when you’re talking about the binary concept so you’ll get the value is somewhere around 1 0 0 0 0 that is a 16 and when you’re talking about a 5 so 4 + 1 become a 16 so 1 0 1 one then it perform the and operator so I’ll not go in a very details way the explanation of how the number is converting the binary and then performing the operation there is a lots of function is available not a lots of Function One function is available to explain this concept okay so when you just use the bin of 16 you’ll get this 1 0 0 0 and when you just use the bin of five you’ll get this and it will perform the operation and and operation 0 and one is become a zero right 0o and one become a zero so when you perform the operation here you’ll get a two different number that is the reason is giving the different values so avoiding this kind of confusion the conclusion is here avoiding this kind of problems we always use a bracket if you’re using this and symbol okay otherwise to understand in very details way I can make a separate video I’ll not go in a very details one here so you can just run is the bwise operator how the number is converting how the value is performing the add operation and or operation okay so here I just giving this some example you can use it I’ll go little bit details here you can just run and you can understand I wrote it just now 4 hours ago you can just use it let me discuss the last two operator which is uh identity operator and one more operator is there which is the membership Operator Let me just remove this one again if you want to know in the very details of uh dewise operator I can make a separate video for this but this is not much required for as a programmer because we already have a function Okay so identity operator is very similar to the equal to and uh uh is not is very similar to not equal to so it identify the values like a is equal to 5 and B is equal to 7 and C is equal to a five again so a is C so it very similar to the equal to equal to it also giving the bullan answer okay G given the bullan answer which is a true and false bullan is nothing but a true and false values that we are calling bullan values membership operator membership operator is in not in okay the value is a particular member variable or not suppose I have one variable which have a list is a 5 7 8 9 so five in a or not like this practically you can easily understand so identity operator is basically working with the memory allocation which is is or is not let’s say for example here I have some values when I just run it so a equal to equal to B which is a five and 7 is getting the answer is false but a is B is also giving the answer is false which is correct a is not equal to B we can also make it similar as a is not equal to B but again this operator is working for the minus5 to 255 range only if you have the values more than that that time this is and not is will be not be similar as uh not equal to and equal to I have this values you can get the values is true 7 and seven but again you have a two different values which is a uh 399 okay n and making equal to equal to You’ll getting the pro but n is M the answer is no the value is different so uh the last video I have explained about ID how the memory allocation is working in a variable concept when you just see the V uh the memory allocation of n will be the different as memory location of M so minus 5 to 55 the range the memory allocation is working the same where is this one is working not same okay same thing here so you can see if the value is this one a uh G is equal to the big statement if the memory location are same then it will be considered as equal to the whole conclusion of this identity operator is that this identity operator working with a memory allocation if the memory loation are same it will be say that is and if not same is not okay you can’t directly uh say that the is is nothing but equal to is not is nothing but a not equal to is and is not working with the memory basis and equal to not equal to working with a number basis value basis the last one is a membership operator as I disc as I said it’s uh the particular value is a part of the member or not so in and in not so here I have a big list and checking that a five the particular member or not so saying that yes it’s member but 77 no so but I wrote the statement is not in see the Python programming language is very similar to the English language right so the whatever operator whatever uh statement you writing is will be it’s uh you know the state have some sense it’s not like that whatever here is writing the in here is a not not like that it’s a proper statement in not uh sorry not in okay in not is not make sense but not in have a sense is it true and so likewise I also perform some operation like um the t u a i displayed in the you know the sequence wise here I will not explain that why is display in the sequence wise it’s a for Loop okay so the coming video you can easily find it out how the for Loop is working in the Practical and theoretical way with the flowchart I’ll go in a very very details way okay so I request you please run this all the operators uh all the operator I’ll share with you these files on a GitHub you just download it and run it we entered in a fourth module which is a data type so we already discussed the last uh we already discussed the data type in the last video so I think this PP you already aware about that because in last video the overview of python I already discussed right so what is integer what is a complex what is a float so the data so many data type is there especially in a python so you’ll find it out some some new word like the set set string list tle and dictionary is also there just not there in C+ plus Java and C language so which is something new for you so in this uh from from this uh modules so we will discuss in the very details of the data type right in the last video we just give the overview so here we have to enter in the depth of the data type and see the data type is very very important concept for a interview perspective because 99% probability that the interviewer will ask the question related to a data type actually this data type is using in almost every places if you are making any application with a Python programming language uh this data type like um uh it’s easy to implement it’s easy to understand but you can easily forget as well the reason because this small small topic is there okay it’s not much difficult we’ll learn it one by one and we’ll make the proper structured way because of the lots of data types so python is creating the data type uh with two different categor the first one is immutable data type the second one is a mutable data type so which one will consider as a immutable data type like a numeric numeric data type numeric data type will consider in a immutable string we also have and we have a tle okay and mutable we have a list we have a dictionary we have a set so mainly three is a main data type is there so numeric is also one of the category we are not saying that numeric is a data type so in a numeric we have uh mainly the integer float and complex so let’s understand it all the data type is one by way this completely a six data type is there three 4 5 five and six okay let’s understand the first one is a numeric data type so numeric data type you can understand is like a numbering concept which is learned in a 10th class or e8th class that’s normal numbering concept numeric data type data type I think you aware about the real number right so real let’s start with the real number a number which is really in exist in the real life we can we can say it’s a real number it’s a very simple definition of the real number right that number can be uh start with minus infinite to any number like uh uh minus 2 you can say uh – 1.01 – 1.005 like any number which is exist in the real life and zero is also considered that and one and 1.5 any number till infinite so inside a real number we have a different different uh subset is like a whole number integer number currently I’m in a you know numbering concept I didn’t enter in the programming concept okay let’s first understand with the numbering concept and after that we’ll relate with all the topic with the programming language so that we have a real number okay so inside a real number we have also the different different numbering concept is there the first one is integer okay so integer integer is basically there is no any decimal point is there like it start from minus infinite 2 it will take a minus 2 and after that minus one okay and after that zero then 1 2 till infinite there is no any decimal point and we have also the whole number is also there natural number let me just first Define natural number natural number is basically start with 1 2 3 4 till infinite that is a positive values is defined as a natural number why it’s saying that the positive values is defined as a natural number because uh you know in in a naturally we are using the only positive things right so you can relate like this this is is not a definition okay third one is a whole number whole number which is start from 0 to infinite this is the normal numbering concept I think you learn in e8th class or seventh class okay so and those number which is which cannot be defined in a real life we are calling the complex number the simple way we can say like if you have a number is like a root of five some values is there right 2.2 3 is there I don’t remember the exact number uh 2.2 something is there right you’ll get the some values but when you’re talking about uh uh the value of minus5 root of minus5 that cannot be Define so that we are defining is like root of minus1 into root of 5 so root of minus1 we are calling the Iota in a mathematics which is defined with the I and root of 5 whatever value is there so in suppose if I’m considering 2.2 something 2.23 so 2.23 I that will be the values so that we are calling is a complex number okay complex number so when you enter in the real life def uh this is the real life numbering concept we are using using but when you’re talking about the uh programming perspective so we have a only integer float and complex okay so we have int so whatever we learn in integer that is nothing but in uh that we defining here the in we have a float like if any values minus1 min-2 sorry min-2 will be the less – 2 -1 0 1 2 like this till infinite okay so floating point that can be any decimal points so like a minus U it is also start from uh you know infinite and if you have a minus two that will be considered as an integer but if you have- 2.0 that will be considered as a flow any value which we have some decimal point we are calling the floating Point number okay so minus 1.02 so kind of that values the complex number complex number how we are defining complex number like in a real life we are writing the a + I but here we are defining the any number 5 + 7 G we are not using the I okay uh that can be any number like 5 + 7 I so any number which is defining the uh Iota concept we are calling the complex number let’s try to understand with some practical implementation okay suppose if you have any number like a five if you have any number is like uh uh 5. 86 any number which have some decimal points we are calling the float if you have uh numbers like um uh 5 + 7 G which I which I said okay so when you just take the data type so we can just type here the type A you’ll get the values as integer I and T and A type of B and you just check it that is a float type of C which is a complex to understand the very details way uh so I already created one files the data type you can find it out um on a GitHub link okay so I’ll share with this file so you’ll find it out like which one is integer float and complex and as well as uh you’ll find it the type Cur one conversion as well like if I want to convert float to integer integer to float float to concept so how can we do that we Define it here okay so hope you understand the concept of uh uh in numeric data type where mainly we are using the three data type here in float and complex let’s jump on the next data type which is a which is a string data type okay so string data type is uh uh is mostly using in a data science perspective as well because let’s let me give you one example is a chat GPT I think you guys is already aware about that chat GPT so chat GPT is a totally based on the natural language processing concept it’s little bit a high level of a data science but let me just give you the um overview why the string is very very important see the chat GPT is always needed the string Command right statements you you’re writing some statement and accordingly it will be finding the pattern and giving the result to you and if I’m talking with you so that is The Voice command the voice command first is converting in a text and after that you’ll perform some operations so wherever the text is available we are apply the string command so that is the reason string become very very important because it can be easily connected with real life because the real data uh text is also there so let’s discuss the string data type okay string so first of of all string is a immutable data type immutable data type and ordered data type so like in um interview perspective the interviewer is asking that what is a string string is immutable and ordered data type which is very very important to say that this order data type okay some data type is unordered as well so I’ll discuss that like U dictionary and set that is the unordered so here what is the mean of uh immutable immutable in the sense we can’t change anything if you define the value is like I give I take the variable a is equal to India first first of all let me discuss that how to define the string string is always defined with the single quotes like I’m writing here the end single quotes we can also Define with double quotes as well make sure that if you started with a single quotes end with a single quotes if you started with a double quotes end with a double codes and uh if you have a multi-line of statement and string is there so we can also Define that with uh triple codes one line two line three line wherever ever you end 1 2 3 so same as for uh single quotes as well 1 2 3 one line two line three line so you can increase the line two three okay so that we are defining the string and string have uh uh as I said that it’s immutable that means you can’t change the values in between why I’m saying this word because of the ordering concept so this end if I Define it here if I Define it here i n d i a so where we have a positive and negative indexes available so index is always start with a zero in a Python programming language this uh concept is not for one string everywhere in the python the value is always start with a zero so the value started here here 0 1 2 3 4 so that is the index and when you’re talking about the negative index that is always start with a minus one because there is no minus 0 right so minus one that is starting with the right hand side min-1 -2 – 3 – 4 – 5 it’s five okay so you can access the values as well so those data type have the positive and negative indexes there that we are calling the ordered data type okay so string have the positive and negative Index right so here because of the this ordering concept we have a different different operations as well so we can easily slice it so in case if I’m just printing let’s do it in a practical way okay so string I have one string which is the India okay so because of this uh ordering concept so we can also slice it as well so a square bracket to using up slice always using the square bracket as I said that the index is always start with a zero so if I’m writing the zero in between the square bracket you’ll get the Valu is I right if I’m writing the a of uh uh three a of three so let me just write here a of three so which is the small i 0 1 2 3 okay so in case if I’m writing the minus two so min-1 -2 so you’ll also get the values the same minus one uh sorry min-2 that you’ll get the same values min-2 right so the index of U the value of index 3 is I the value of index minus – 2 is also I right the same values because we have a positive and negative index as well so in case if I want to assign some values if in a of two which is a B I want to make it a capital letter can I do that capital D it will giving you the error so if it Define the particular order you can’t change it if you can change it that’s become the mutable if I change the order if I change the values in between that become IM mutable so obviously um in Python everything is possible if you want to change it it’s possible in a different way but the string is not giving you any kinds of method to change the values directly you can’t assign directly here okay that is the reason is a immutable immutable inmutable means in the sense non-changeable mutable means changeable all right okay so based on that we have a different different operation is available we have a concatenation suppose India and uh I have a um B statement which is the country country okay so the a plus b if I’m performing the operation I’ll get the Valu is India country okay India country in in the in case if you want to Define some space in between so a plus you can provide the space the plus operation is used for concatenation plus operation is used for concatenation if I’m using so India space country perform the operation like this so let’s go to discuss about uh method and function in a string uh string data type so let me just conclude what I discussed okay so I discussed this slicing I disclose the concatenation and we have also one more thing is a repetition okay we can also repeat it with star symbol slicing we are using the square bracket concatenation we are using this uh Plus and reputation we can use the star so for example I have the value is uh variable is a I want to multiply with a five then you’ll getting India India India five times so that is a reputation okay a small small thing is there to go in a very details way again you can go to the data type if you already aware about these things so you can skip or you can just make this video is a 2X or 1.x faster and just complete it and go through this uh Jupiter notebook and run this file you’ll get a better idea but don’t forget to run this uh uh jupter notebook file okay so here I already explained okay so you can just run it just shift enter shift enter run it you’ll and you’ll understand each and everything but again in case if you make any doubts if you not understand anything you can just put your question on a comment definitely I’ll reply you okay so let’s discuss about uh okay I need a space all right I need a space keep because I don’t want to remove it okay so let’s discuss about the next thing is a function and method which is very very important every data type have a different different method and function okay let me first write a method and some function so actually the method and function both are a same there is no any difference this have a very small differences there if function is always defining like a def here I’m not explaining you the details of the function whatever in build function whatever in build method is available in a string that I will discuss it here okay so why the both are a difference see method is always calling with a DOT like I have suppose a is a variable a is a variable which is the India okay so method is always using like a Dot Upper a do lower a do capitalize okay a DOT count a do index small I there is no Capital index so other uh method is also available but when you’re talking about um function so function is like a len and we are passing the values a len means length we have um uh mean we have a mix okay so these are and we have a type so actually this uh uh function is a very common for for all the data type so when you just enter in the list tole dictionary so you’ll also find it out the same type of function that will not change but the method will always change the difference between the uh function and method is that if function is always defining like this and then function name f n if I’m writing defining like this if the function is separately available we are calling function simple but if the function is available inside a class we are calling the method class class name is a okay if it’s available inside a class we are calling method so when I start the objectoriented programming I’ll go in a very details way just now you can just understand like this the method is always using with a DOT and a function we directly call it and to know that which one is a function you can directly understand like if you find it out any statement after this bracket that is a function that can be either function or method if you’re using dot method not using function okay so few method I will discuss it here and uh after that I’ll stop okay because uh no need to explain each and every method when you just run this uter notebook you can easily understand okay so as I uh Define all two variables a which is India B which is a country and I want to make it a Dot Upper so that will make it is a upper case okay it will be make as a upper case a do lower that will make it a lower case small I and uh currently the a variable is already the capitalized capitalize in the sense first letter is a capital the second letter uh remaining letter is a small one let me make one variable is equal to I’m using Python programming language okay so let me just use small I when you just use a c do capitalize okay sometimes uh when you just forget your uh you know that method spell when you make it spellings little bit wrong so it will giving you the error so the best practice is that after this variable put a dot put a tab you’ll getting a different different suggestions I’ll make a capitalize I don’t need to write everything capitalize is already there okay when I just run it you’ll get the values I’m using Python programming language so the first L make it as a capital the rest of the later will make as a small one so C do title there is one more valuable uh one more method is a title everything makees a first uh letter is a the capital of the particular word okay so again to go in a details way so you have this one string data type which is immutable and ordered so you can find out here all the different different uh method and description is also there it’s very understandable way so when you just run it shift tab shift um shift T shift enter when you just run it you can easily understand so again I’m also there in case if if you face any problem okay so these all the options are available till here okay so suppose I have a statement um Rahul got 78% marks in mathematics exam okay so this is the one statement I want to make this statement and dynamic way like uh the name which is a Rahul okay and marks I’ll make a m variable which is 78 78 which is the integer and U subject which nothing but a mathematics okay this three variables I want to make a statement in the dynamic way so making the statement Dynamic may we have a three way to define it let’s discuss the first one string formatting uh the first one is we can print here so the first one is Rahul so Rahul is a subject so I’ll make the name is a string so I’ll make percentage of s okay that percentage of s I’ll make the dynamic way uh Rahul got 78% marks so percentage of s percentage of I I for integer marks in mathematics exam which is the percentage of s s for a string and I for integer percentage of s exam okay and after that after a double quotes you have to use a percentage and in a bracket you have to pass the values 1 by one the first one is a percentage of s which is nothing but a name I’ll pass it the name is here second one is a m which is nothing but a marks third one is a subject I’ll pass the subject here the name will be passed in the percentage of s m will percentage of I which is a integer and subject is uh that mathematics so here showing the 78 so the best part of is that in case if you have some decimal uh numbers is here like let’s say for example you have a 78.6 7 um when you just run it till you’ll get the answer is let me just run it here again still you’ll get the answer is 78 the reason behind that because I pass the values is the integer right so in case if you want the proper decimal point you have to make is a float you have to make as a float so by default that floating point is giving the uh till of five decimal point yeah six decimal points so it’s on you you can easily U you know dynamically you can just change it I can pass it here only the two decimal point so 0.2 when you just pass it you’ll get the values is uh 78.6 7 in case if you’re passing the one decimal point so 67 it will be convert into seven because after six the seven values is greater than uh 0.5 that will be uh round of seven okay but here the percentage symbol is not visible so when you just pass the one percentage it will be show through the error because unsupported format uh because here the considering that if you pass the 1 percentage the meaning is you will pass some um you know the data type here as well that can be string that can be float that can be integer so avoiding this confusion we always using the double percentage so that will consider as a percentage okay so one percentage will consider as as a like you will pass some data type but actually you don’t need to pass some data type right so double percentage you can use it so here uh uh like uh s we are calling string I we are calling the integer so again in the data type already the values is available you can just make it string integer float character everything is there okay so this is the one way to defining this string formatting there is also one way is also there to defining the string formatting you will just write a print and uh whatever values is available like Rahul so he’ll make double quotes always there because of the spring uh this one curly brasses ra you will consider as a dynamic values Rahul got curly brasses percentage marks in cly bres exam okay so here the curly presses you have to pass the values here like I will pass the value is uh name I will pass the value is uh M I will pass the value is subject just before you have to write F this is also the very simple way but again if you make the statement is a very Dynamic especially in the number format so this one is also useful you can also use this one one also so both are very same you can use it sorry we have to give this space and yeah full stop so again everything you can find it out here uh you you can easily find it out here uh one more thing one more is also there uh dot format option okay so you can just use it the same thing here curly brasses got Rahul got curly brasses exam uh cly Braes marks in cly bres exam okay and after that just do format and you’ll pass the values is one by one okay so here when I just pass the value is um uh name first what will be consider and then M then subject again so okay s j c so again you will be confused that what is the difference between in that okay this option is available then why I will use this so this one also have some uh plus point is that suppose um here you have to pass the proper order otherwise the value will be swapped so but in case if you pass the different order I’ll pass m is here I pass name is here I’ll pass a subject is here itself when I just run it you’ll find it out the value is 78 got Rahul percentage it’s very weird statement right so actually the by default uh this one uh the indexing point is also there 0 one and two so when I just run it so by default the values is there but actually this uh the zero index it should be it should be here so I’ll make it zero here okay so you can see you’ll find it the two times because I also pass the zero is here as well so here I’ll make the one so you can change the order as well so all three have a different different positive points uh we can use it okay so one more topic is also there in uh string formatting so uh string formatting is done in a string there is also one more topic it’s very small topic is um skip sequence and uh raw string skip sequence and raw string let me put the heading here skip sequence and raw string okay skip sequence in the sense suppose if you are uh writing some statement and the value will not be print in the place of that uh uh that symbol it will be showing the meaningful result let’s say for example I’m writing here I um working in Python programming language okay which is uh dynamically type language okay I just want some statement after the uh High I want to print in next line I’ll use the slash n so sln is basically going to the next line right it’s not like that it will be print the slash okay and after the statement again I want to in this next line it will be in the next line I want to uh dynamically typed language have some uh space as well SLB B for backspace okay B for back I’ll make the t t for a tab okay so when you just run it you’ll get the values is because of the sln is giving the next line because of this sln is giving the again next line because of this SLT is giving the again some spaces here so that’s why it’s giving the uh uh that meaningful result not exactly is the printing the values right so this one we are calling the skep sequence so I just uh Define it here a different different type of skip sequence like slash n for next line/ t for tab SLB for back space SLR for reserved and uh Slash a for alert so different different skip sequences there sorry it’s a skip sequence okay skip sequence and what is a raw string so raw string in the sense sorry draw string in the sense if if uh you want all the statements as it is I don’t want to print the meaningful result I want as it is values so just before you have to write r that will consider everything as a raw string so the value is not displaying it here sometimes it’s very useful whenever you’re reading some particular files from local machine or in particular server okay suppose if you are reading and uh somewhere the double slash is available single slash is available so python is giving some meaningful result but you don’t want you want as it is uh path so that time we are using the r especially for uh reading the CSV file in the data science we mostly using the r to avoiding the errors okay so that string topic is finished so we covered everything we covered uh four thing here the first one we discuss about uh what is the String which is the immutable and Order data type and uh we discuss about the positive and negative indexing that can be easily slice and uh concatenate and repeating values and uh we also discuss the method function and we discuss the string formatting skip sequence and Ross string so that complete the details again if you have any confusion you can just put on a comment and uh please refer that um uh jupter notebook file your confusion will be cleared there okay so let’s discuss about the next topic which is a tle so tle is one of the smallest data type like uh uh like a number number is very small that was only uh you know uh the integer float and complex but the tle have some values but it’s not as much of uh big topic so let me just cover it in this video only okay so again the tle so first we have to clear that what is the definition the Supple is again it’s a immutable and ordered data type ordered data type okay when you’re talking about the how the tle is defining the tle is defining in a round bracket suppose I have a value is a five a 8 7.0 and high okay so that I store in the variable T so uh uh first of all this tle is a comes under the sequence sequence means is a particularly order and that collecting the data right so the five is a integer 7.0 is a float high is a string so that is a that’s why the tole is become a uh sequence which store the different different data type even inside a tle you can also store the list as well dictionary as well anything so the tle list dictionary in the set that working as a container so the container is nothing but a sequence okay so here as I said it’s the ordered data type so again have a positive and negative indexing is there okay sorry uh oh why it’s showing like this okay have a positive and negative indexing so 0 1 2 3 have a positive indexing and as well as we have a negative indexing as well -1 – 2 – 3 – 4 so like the tle we can also apply the uh slicing order like uh the T slice with uh uh two you’ll get some values obviously you’ll get the value is 7.0 right you’ll get the value is 7.0 in in case if you pass the T of three you’ll get the high but in case if you pass the minus 3 then the value will change that will be 8 right so we can also apply the concatenation here we can also apply the multiplication here so this symbol is used for concatenation and this symbol is used for repetion okay so and uh the likewise the uh string we have also the method and function are available so the best part of this uh tle is that not a best part but uh yeah uh the tle have a very less method when you’re talking about a method have very less and a function okay so method have very less just we have a count count method like T do count and T do index that’s it we don’t have other method is here so again is a tle uh again is a immutable so that means we can’t change the values in between and uh the function when you’re talking about so it will be the same as the which we discussed in the string that like U uh what is the max values what is the mean values what is the um a type okay there is also one more function is available which is a tle which will be responsible to convert any data type into tle okay okay so mean Max is there yeah and we have a len which is very very important Len which will show you how much uh data is available inside a tuple so let me just clear it in the practical way it’s very uh small data type we can see so again you have to refer the data type Jupiter notebook you’ll find it out the practice uh um notes there okay so tole I can Define it here in the round bracket I’ll make this the T1 be Define in the round bracket 47 7.9 and um uh high is here we can Define it and he we can Define it okay so let me also Define one more variable is a T2 where I can Define it 4 5 6 2 there is very small values so the T1 if you access it uh access it with the two so the value 0 1 2 which is a 7.9 you value will generate sorry it’s a T1 not a t 7.9 value will be generate but again I want a 7.9 High both the values so you will start with two you will start with two and end with high start with two and reach till three so the p have a rules that never end with last values so if you’ll write three that it will be considered as a range the 2 to three it will start with a true but not end with three okay so it will showing the value is 7.9 so you have to write here the four this rules is not for only tle it’s rule for everywhere in the python always start with the index always start with zero first thing second thing never end with that values always ending with before one because of that let me write it here always start with index zero and in case if you pass the range is uh 9 meaning is that the value will start from 0 to 8 okay so here when you just pass the two colon 4 the meaning is that prob with two and three like this so this will be applicable for everywhere in the python not for a tle only okay even the last data type which is discussed that was a string it’s also applicable for them also okay so we can also apply the concatenation T1 + T2 you’ll get the value is the complete concatenation we can also apply the uh repetition as well so if I’ll multiply with the three then you’ll get the three times that same values okay so these are the values are available and uh uh we have a different different method as well before going to that method let me just uh do the uh negative indexing and some more values try to get it suppose I want this both the values uh 6 7.9 and high from negative indexing so T1 this is the values I want to start with 6 so that I will take the value is -1 – 2 – 3 -4 so I’ll write write the minus 4 here and when you just print it you’ll get the Valu is minus uh you’ll get the values is six and when you click only colon then it will be start with a uh minus 4 till last okay but I don’t want a high so this the value is minus1 and I want to end with here so when I just write a minus 2 min-2 so you know that it never end with the last values is always always ended before one right is before one so definitely it will end here you can run it and check that so better do you have to use minus one minus one in the sense it end with min-2 this is the rule of python is that never end with last values and always start with zero if you are not defining and the values is always start with the same same if you are defined this is the way and one more thing suppose I want to make this order as a reverse how we can do that so the E1 you can make it and when you make a colon that meaning is that start with the zeroth index end with last okay and after that suppose uh okay after colon you can also increment and decrement so by default start with a zero 1 2 3 in case if I’m writing the two so it will be jump like this 0 2 4 and I just run it you’ll get the values like this but if you make it minus one okay the first place become the minus one then again it will be decrementing so it will make the reverse order okay oh sorry T1 the T1 values of this and you can make is the reverse order all right here if uh if I’m applying the method and function the P1 dot count okay count you can just count it how how many times that values is available I want to know that how many times high is available will tell you yes it’s a one time is available right so in case if you have a multiple times high is there like uh uh T2 how much is there okay so let me make a T3 is equal to T T1 + T2 T1 + T2 so this one P3 I want to perform some operation how many times four is available let’s make it p 3 dot count and make it four you’ll get the values is two okay so again the t uh when you apply the index order dot index index will tell you where is exactly the position suppose I want to know the position of 7.9 7.9 it will give you the value is sorry it’s a T3 give you the value is 2 0 1 2 but the confusing part is here confusing part is here if I want to know the position of six P3 dot index of 6 what will be the values it’s one but I want to know that what is the position of this if you’re walking in the Jupiter notebook click on it here and inside a bracket just write shift tab you’ll get the complete notification okay so it will tell you where the position are starting and where is ending so ending is a huge number and starting is a zero so always start with a zero but if I’m start traveling from the one uh sorry 0 1 2 if I’m traveling from the two so that means it will not check the previous one so here if I start a start T start is equal to two if I’m writing so that means the the two is here it will check only these part so what is the position of six in this part okay start s t take no keyword argument okay let’s remove it so you don’t need to pass the uh keyword there okay so when you just pass the two here the meaning is that it will be start from two only from here it will not check the previous one so this way we can find it out a last thing uh I didn’t uh discuss that why it’s called as a immutable because I have the D1 in case in the place of 7.9 which is the second position I want to replace with some values like U hello so you can’t do it that is not supporting in the tle so tle is mostly used for a security purpose uh the value when you’re defining in uh any any metadata or we can say any storage place we always using the round bracket so that when you start working on a python it should not be changed by mistake to assigning some values okay so now the tle topic is finished this is uh the topic is there in a tle so if you have any confusion you can put on a command we completed the three data type numeric string and tle so now let’s discuss about the next topic is a list that is the fourth data type list so list basically a a mutable data type so whatever we discussed the previous one is a tle string and numeric that was a immutable data type but this one is a mutable data type mutable and ordered data type again so mutable means changeable ordered means have a positive and negative indexing so list is always defining with this is LS is a variable defining with a square bracket that can be the any data type you can just write it like integer 5.8 is a float High okay and uh 7 five so you can Define like this so it’s a square bracket all right so have a positive and negative indexing as well because of it order so we have a 0 1 2 sorry three and four I have a NE negative indexing as well minus1 -2 – 3 -4 – 5 so when you’re talking about the operations so it have also the same operation like a tle and string so we can perform the operation like uh slicing so like LS of for the particular slice if you do it uh like one so you’ll get the answer is 5.8 so if you the slice is the multiple values um like uh 2 to 5 so you’ll get the answer is high so that will be the single quotes here High 7 and five that is the more than one values is always in the square bracket okay so we have also the uh uh this symbol plus symbol which is denoting as a concatenation concatenation okay and uh the star symbol which denoting as a repetion okay that will repeat the Valu in the many times and uh the same as um same as the tle we have also this method and function are available but because of this mutability because of the changeability we can change the values so we have so many method and functions are available so here I will discuss a few method and function and later you can just run the Jupiter notebook file you’ll understand easily so method and function our function is the same that will be Len that will be mean that will be Max that will be uh list list also the function okay and uh that will be the type okay this function very common we we we are using in uh every data type so only this one like for a list we have a list function for tle we have a tle function string we have a s Str function okay so method when you’re talking about so method is um uh we have uh like U we have a DOT count okay we have a um we have a index that that is a common it’s there for a tle and uh in string as well and we have also the other method is like append which is very famous append insert okay so many method are available so again when you just run the jupyter notebook you’ll find it out all the methods there so few method I will discuss here and I’ll discuss in some practical implementation here okay you’ll find it out in the Jupiter notebook each and everything okay as I implemented almost every method here but still if you’ll get any confusion I’m there so let me create one uh heading is a list okay so LS is a variable I’m making some values here 6 comma 3 comma 8 comma 4.7 comma uh H comma K okay so if I want to change the value is H to hello so what is the position of H which is the 0 uh 0 1 2 3 4 that is the fourth position so fourth I want to which is nothing but a h i want to make as a hello hello and later when I just check the values is LS so yes I can see the value is hello so it’s very simple we can just do it right we can just up change the values because of it’s a mutable data type we can easily change the values which is defined inside that right so here H is changed so whatever index is defining for H so in the place of H is showing the hello but you can’t do it in a tle okay so uh we can also uh slice it many things like LS of four what is the values is a hello LS of U uh 2 which is the8 from the eight I want to Define with the last values so you can see the last value is this one but the same time if I want to print till a f only five only so it’s saying that it’s LS not s saying that 8 4.7 and hello right 8 4.7 and hello it reach till four only right so it will take two it will take three it will take four it will not reach till fifth values okay so we can also perform the operation like a concatenation repetion as well I have LS2 which the list is containing the 742 and when I just perform the ls plus LS2 so you’ll get the value is is combining the all right so adding the all the values is here so concatenation we can perform we can perform the repetion as well it’s repeting the values right we can perform the functions as well here all the functions in LS I want to know that what is the length LS so you’ll get the values is six there is a six elements are available so uh inside the list tle dictionary and uh set so that values we are calling the elements right this elements are available there is a six elements and uh when I just perform the operation of minan of Ls so you’ll get the error because these all are a number but the hello and KY is a in these both are a string so string cannot be compared uh to each other right less than greater than symbol is not supported between the string and integer so what we can do it here so we can just remove it or else you can just take the any other like other variables so here when I just check that what is the minimum values in LS2 so which is the two and LS uh LS2 what is the uh maximum values what is the maximum values so you will get the values is seven so we can find it out this way but again so when I just uh competiting with the tle and list for example you have a tle I already Define I think let me just use H T1 tle I want to change the values Pi I want to make is a he uh not a he I want to make as a uh hello okay so we can directly convert this tle into the list so when I just make the list of T1 so it will make the complete list but in a list we can perform the operation right so I can store in the temporary variable temp variable I store it you can store in any variable obviously temp I store it and I just pass the value is the position of high which is a 0 1 2 3 so when I I just pass the value is three you’ll get the answer is high and when I just perform the assigning the values perform the this assignment operation hello here and check the value syst temp you’ll get the hello later again you’ll perform the operation like a tle you’ll convert your list into the tle so make the values this okay so we have this option like uh the the list we have a list function tle we have a tle function so because of that we can change the values right so lots of method is also there that we discuss the um function so method is also there for example I have a list LS I want to add some values so ls. pend we can add some values here suppose 400 I want to add it I can add it here LS the 400 is added but at the same time I want to add in the position of the two or we can say just beside the eight so you have to find it out the position where you want to add it 0 1 2 3 in the position of three I want to add it so upend is always adding in the last but when I just use the ls do insert so this is also one of the function insert so you can what what you want to add you can just take the help from Jupiter notebook shift tab it will tell you where you want to add sorry first where you want to add index is where you want to add I want to add in the position of three what you want to add I want to add a th000 more so when I just run it and check the values LS th000 is adding in the position of three okay so the 4.7 is just transfer in the one position so that means it’s a mutable right the position is changing it here but when you’re talking about the list and a when you’re talking about the tle and a string that cannot change the positions okay because that is a immutable data type insert we can perform we can perform the uh deletion operation so here uh append and insert we mostly use for adding the values if I want to perform deletion operation so that remove operation here I want to remove hello we can directly remove it here and check the values as LS so value is removed so that value is removed from the uh from the values we I just passed the values here but I want to pass the index so ls. pop is there pop is taking the index I will pass the 0 1 2 3 4 5 I’ll pass the index is five the pass the index is five then it will be removed the uh K values take the ls that is remove the key and here you can perform the main Max right there is no any string values is available you can perform it Max obviously it’s a th000 so you can perform here okay so likewise we have lots of method is available remove is there pop is there okay so other method is there you can just check it in uh data type see sorting method is there if applying the ascending order desc ascending order right we can apply the clear clear will remove the all the values there you just run it the shift tab shift Tab run it you’ll understand everything it’s very simple way so much method is there again you don’t need to remember each and everything but you should know that that option is available in a list okay you don’t need to remember because a very small small thing is there okay so in a list there is one topic is very uh famous which is the list comprehension list comprehension so this list comprehension is mostly used for optimizing the code so whatever code you can write in a three four lines because of the list comprehension you can make it to one line and it’s very fast okay so suppose I want to display the 1 to 10 number it’s is very simple example 1 to 10 number so with the help of for loop I can display it here for I in range I can pass the values is here one to uh 11 so this is the rule of Python programming language is that is always starting with that particular values and if you’re not assigning that will be considered a zero and never end with last values okay because the range of 1 to 10 1 to 11 the 10 values should be printed so another programming language why it’s not like that because their indexing start from one and here indexing start from zero so when I print I so it will showing you the 1 to 10 number okay I want to perform the operation based on that I want to perform like U make a container of the uh uh you know the cube of all the values so when I just make it Cube because when you have the particular list and perform the uh I want to store in okay like that suppose if you have the particular list I want to make it all the values as a QBE format but in that time when you just directly perform the operation like um suppose I have a LS and when I just performing a q to the power of three it will show it saying that it’s not supported so in that situation what should I do so we can directly uh you know display all the values display all the values with a for loop it’s iterating all the values is one by one what is happening here it’s printing all the values one by one right so like here LS is this LS is this I want to perform the cube operation based on that so can you do that no it’s not possible when you just apply it here Cube it will giving you the error so likewise we have the one one of the requirement is that I want to make a list of the cube of 1 to 10 so here when I just make it cube of 1 to 10 so the displaying all the values I’ll make one particular uh uh list like LS three is a blank list and every time I’ll just append it append with LS3 sorry not LS3 I I will append it uh let make it a result okay here I’m just using the for Loop but after completing up this data type I have to go in the very details of conditional statement and loop so again if you have a confusion if you if you are okay with that then you can just listen to it otherwise you can just pick the video of uh the for loop as well I have already created not already created after that you’ll get the a for Loop okay soend why it’s not working okay I have to write ls. up okay so when I just check the ls you’ll get the LS3 LS3 not LS LS3 you’ll get the values 1 8 2 7 like this so but with the help of list comprehension you can easily do it just one line of code list comprehens some syntaxes like that so so you’ll apply the for Loop for variable in sequence so before just we have to write variable okay this is the sequ this is the uh syntax of the list comprehensive so what I’ll do I will just use use the for I in range which is a uh because range is a sequence range which is the 1 to 11 and before that whatever want to print you can I I’m just printing the only I so that showing the 1 to 10 number but I want to print the cube so it will showing the cube okay so as I said that in the ls I want to make it the cube directly I can’t do it but if I apply the list comprehension there for uh B in LS3 so before when I just pass the One V you will get the as ittis values because it’s a iterate the all the values is 1 by one right it’s iterate so you have a freedom to do anything with a V so I I’m applying it here the three you’ll get the values is completely the cube of all the values right so here LS3 previously was like this uh not a LS3 let’s perform the ls you can see here previously the ls was like this let apply the cube in all the values is one by one so we with the help of list comprehension we can perform this operation and in real life in the real application we are using this one so based on the list comprehensive I’ve just given some exercise you can just try it it’s very easy I also given the solution as well here you can just try to understand and do it okay so each and everything I just apply it here you can check out and just run it one by one you’ll understand everything here okay so I also created the 2D and a 3D list right so 2D and 3D list let me just explain a little bit 2D and 3D list 2D and 3D list okay so L if you have a list like this that means it’s a one day list okay it’s a one day onedimensional only if you have LS2 is like uh a particular list is there the list inside a list so list inside a list like 4 6 8 comma in the second list we have 3 5 7 like this so that means there is a two rows there’s two rows and three columns so that means it’s a 2 cross three Matrix is there right so when you have the same kind of with a three dimensional as well like uh LS3 so this is the particular one di uh it’s a 2d list I’ll make the 2D list in the same time I will also make it this 2D list in a one particular wrapper so let me change the values like a 15 16 18 13 15 and 17 and everything I’ll make one particular rapper then it’s become a 3D list right in a 3D list that we can say that it’s a this was the two rows three columns and I apply the one more D there right which is the two so 2 cross 2 cross 3 the value will be 2 cross 2 cross 3 it will be right we can if you want to iterate it the for Loop will really help you so it like if I want to slice the values LS uh LS3 this is the values I want to change in the position of 16 okay I want to change the position of 16 first you have to find it out so which uh uh Block it’s available this is the F this is the first block this is the second block so available the second block that means 0 1 so I find it out this block and again it’s a which block it’s uh because I want to change the value is 15 right again is a which block is a zero Block it’s a one block it’s one again what is the position it’s a one I want to change the values is a I change the values when I just take the ls three obviously LS3 get the values is high so this way we are performing the list operation and we can also iterate with the for Loop like for I in LS3 so it will be iterate the one list will be iterated here one bracket will be trated here like print I you will get the values in one list one list and the second list right so again I I want to iterate it so for G in I print G so when I just display so you’ll get the value is G iteration so again I can iterate it the uh with a G as well for K in J so then you’ll get the value is a okay so you’ll get the all the values so if you have a three dimension you have to apply the three for Loop to read each and every element okay so this is the list uh 3D 3D I also completed and list comprehens I also completed all the methods and function as well please check out this Jupiter notebook your all the doubts will be clear now we reach till fifth data type which is a dictionary so dictionary is a little bit different with tle and list what is the different different is that there is no any positive and negative indexing is there in the dictionary that means dictionary is unordered data type but it’s a mutable data type if it’s a mutable let me just write it first it’s a mutable and ordered data type sorry unordered data type unordered data type okay so there is no any positive indexing for a dictionary no any positive and negative indexing so dictionary is a defining like key value pair with curly brasses key colon values okay Curly brasses close so if I want to Define any dictionary so we can Define the dictionaries like this so suppose the variable is a D in a curly bres I’m defining the value is a colon 15 comma B colon 18 comma Zed colon 19 again I told you there is no any restriction for a data type if you started with any string is here and I want to put it here is a integer you can do it there is no restriction any data type as I said in a tle uh topic itself right so likewise the tle this is also one of the container but it’s contain the data as key value paay so likewise uh couple and list so we’ll also discuss about the operations their method and function so when you’re talking about the operations so we can also slice the values but with a key because there is no any 0o 1 1 2 3 there is no any positive and negative indexing is available right so we can’t directly access it suppose if I want to access the value is a 15 so I will write D of a okay we’ll write a d of a then you’ll get the value is a 15 if I accessing the value is a d of Z so you can get the value is 19 this way we are accessing the values but here you can’t perform the operation of the concatenation and multiplication means this star symbol you can’t perform it this plus symbol you can’t perform it so I’m going to remove it this part okay so likewise the uh list and uh uh tle we have also the method and function is available so let’s talking about method and function method and function so here this is not a sequence right which have a positive negative indexing and defining in the one particular uh uh brackets so we can’t use it mean and Maxes here but we can use a length we can use a type we have also own uh function which is a d CT D this function is also available so when you’re talking about the method so also have lots of method is available here like uh we have a do keys keys like if I have a diction if I have a variable is a d so d dot oh it’s not running okay wait wait a minute just me just open it again there is some web problem okay so let me just continue with this okay so we have a keys we have the values as as well okay we have pop okay we have the uh uh Keys values and items so the lots of method is available let’s do it practically let me jump on a practical implementation this one and uh we’ll also discuss about their application as well where we can implement the dictionary in the real life okay okay yeah let me just remove it these things all right let me create one file here all right I already created let me just take it experiment yeah again you have to follow this uh J notebook which is already there in a description you can just uh access this link via GitHub and just run it you’ll find it out all the information here right but I’ll just run it few um you know method and function here yeah the same dictionary a same Jupiter notebook let me create here dictionary I’ll create one dictionary is the D1 is equal to in a curly bres suppose like uh uh R and pass the value is 19 K I’ll pass the values 8. 8.9 I’ll pass the value is e colon hello I will also pass the value is the 5 colon 19 so there is no any restriction for the data type so like you started with the here the string so the key always should be a string it’s not like that you can pass anything here this this restriction is not there in anywhere in the python all right so D1 if I want to access any values I’ll pass the Valu as a k you’ll get the values as 8.9 and D1 I want to access the hello you’ll get the value is oh what’s a what’s the problem oh sorry I just accessing the value is hello with t that that is not possible I can access the T I can access with the T and get the value as a hello right this way it can be performed okay so when I just perform some operation methods here like a D1 do Keys you’ll get the all the keys here okay so r k T5 these are keys and what is the values E1 dot uh values you will get the values here again if you uh if you already aware about that you just the run this file which is I shared with you the dictionary run this file and run this video in a 2X or 1.5x you don’t require to listen each and everything right these are very basic basic things is there and just when you run you’ll understand so I’ll just give you the complete overview here okay so suppose if I want to add some values so there is no any upend option is there right there is no any upend I want to add some values how can I add it so the D1 pass any keys I’ll passing the keys here like uh U I’m assigning the values here 1,000 so when I just run it and get the values here D1 you’ll get the U in the last values okay so like way we can also assign the values so dictionary have some um you know applications so I’ll discuss about that again I will not each I will not write each and every line code so I’m taking the help from here suppose if I’m defining the values here okay here this is the list okay so question is why I’m creating a list here why not sorry this is the tle uh why I’m creating the tle here why not a list the reason behind that tle is very much secure secure in the sense we can’t change the values so most of the time we are using the tle as a key in a dictionary okay so it’s not like that you can’t create a list you can but most of the time we are using the tle because of the security purpose okay so T1 is a tle I want to make each and everything as a dictionary so you know that the Cur if you make the curly brasses like blank curly brasses so uh for example uh D2 blank cly brasses when you check the data type that you’ll also get the data type is a dictionary dict here is showing the dick not a complete name is a dictionary all right so this D1 I want to make as a uh dictionary uh dictionary key so D2 which is is nothing but a dictionary Dot from keys there is a one method from keys I’m passing the values is Keys which is a T1 so you’ll get the values is like this name as a none because I didn’t pass anything colors is a none like this so I’ll make I’ll store this values in the D3 even you can store in the same variable as well it’s on you right so let’s assign some values so D3 I’ll D3 this I want to assign some values in place of the name so I’m assigning the value name okay here you can assign directly any name like Rohit you can assign it or else you can create the completely a list here it’s on you like inside that you can Define one key in the values you can pass n number of n number of uh uh n number of uh uh you know sequences sequences in the sense in in one sequence you can create it like a list on top you can Define the multiple values what is my target here I want to create a complete table I think you you aware about Excel you you seen Excel somewhere right at least I’m expecting this this time okay so in a table suppose I have one name I have a a phone number and I have a um marks something like this so okay so the keys is this this values is always constant this is nothing but a column name so when you’re talking about the terms of the dictionary that will be calling this part as a keys and all the values will consider as a values okay so values of the particular key so likewise I want to Define some values suppose the name is name is uh name is like RIT okay uh Manoj John and their likewise their values is available so you can Define it so in a terms of dictionary when you’re talking about let me just remove unnecessary things yeah okay I want to create the complete table in the terms of the dictionary which will be the pair of uh list and dictionary okay so I have many names available I’ll I’ll just copy paste from uh this file so this one I’m just defining here okay I’m just defining all the values so name I Define the M marks I Define the 90 subject are defining the uh ma maths and college are defining the Mumbai University okay so when I just run it so you’ll get not info obviously uh you have a D3 so d 3 D3 D3 okay when you just check the D3 you’ll get the values like this at the same time if you have a multiple values you can also Define it m I’m defining with uh the other name is John so again if you have one values you don’t need a container container or a sequence we can also say if you have one values we don’t need a container if you have multiple values we need a container which can be either which can be either list or tle I’m just making here a list okay you can make a tle it’s not a problem okay and I’m just passing the values 56 and any values so maths let me pass the English okay let’s store it and uh Mumbai University and uh okay IIT Bombay all right so when I just run it so you’ll get the values is like this so here the m and John you’ll get the same time if I want to make it this as a table this is not look like a table but there is a library which you’ll learn maybe um after U uh 8 nine videos topic is the package and modules there is inbuilt packages available is the pandas import pandas okay I’m importing the pandage which is inbuild package and already installed in a Jupiter notebook and Anaconda if you’re walking with any other libraries then you will not get it par directly you have to install it import pandas and pandas do data frame so I’ll just make it completely a frame okay frame and when I just pass the values at D3 run these values you’ll get the complete table where the name College subject and marks is considered as a keys where the other thing considered as a values so when you just enter in the data science part currently you are just learning the Python programming language when you enter in the data science so everything you are dealing with a table and the table we are reading in the data frame format then you’ll start the operations so if you start the operation if you already aware about that yes this table is nothing but a collection of the keys and values right so mes John Mumbai University iitb this is nothing but a values where is the name and college that’s considered as a keys so let me just Define is the variable DF data frame and DF when I just pass the values do Keys you’ll get it the keys because this is nothing but that data frame is also nothing but a combination of list and dictionary so when I just pass the DF do values you’ll get a values as well see everything is a values there is no any Keys okay and some other method is also uh adding here like a DF do columns which is not there in the dictionary but this is the method of data frame you’ll get the values but you can see the keys is very much similar to the uh DF do columns but if you perform this operation dictionary do column you will not get it this is the uh method of a data frame don’t apply it I I’ll just remove it here okay when you enter in the data science then you’ll understand here just try to understand that a table is a made with a dictionary and list so again I request you to run all the files you don’t need to create anything if you want to do experiment do it but at least run this file this all the values is available like uh how we can get the keys how we can get the values items how we can perform pop clear operation how can get the values how can add some values how can update the values right so this is one one line of code you just run it you’ll understand easily each and everything like here creating some particular data frame is here so likewise uh list we have also the dictionary comprehension dictionary comprehension is the same as list comprehension the only thing is that the syntax will change the reason structure of the dictionary and a list both are a different let me first remove it this I’ll write the syntax and after that finish the dictionary comprehension all right okay dictionary comprehension okay dictionary comprehension when you’re talking about uh the syntax the syntax is very very same call brasses so again we have the key values pair suppose if you apply the operation is like for each in sequence so here you have to perform the key colon values is mandatory I want to print one to 10 number okay I want to print one to 10 number but at the same time I want to show the values as well suppose if you have a list you performed like for I in range which start from one end with 11 and before you just wrote the values is I and you’ll get the one to 10 number this is I you’ll get the one to 10 number but I want the cube of this all the number with the same numers should also be defined like one colon 1 2 colon 8 3 colon 27 4 colon 64 like yes so that was a list here I’ll make the curly Braes make sure that you have to use key values pair so I colon I’m just using IQ okay I Cube you’ll get the values is like this 1 28 327 464 5 6 like this until 1,000 okay so disc dictionary comprehension is the same as list comprehension while the structure is changed the set is a mutable mutable and unorder data type it’s a unordered data type okay so unordered meaning is that there is no any positive index there is no any negative index mutable means we can change the values easily in between we can delete it we can update it we can append it we can insert anywhere right but it’s unordered the meaning is that we can’t put any index so that we can access it so defining the set we are defining like this is the curly brasses even dictionary is also defining with the curly brasses but have a key value pair and here curly brasses and with the values directly 5 8 7.9 High K like this so this is a set so there is no any uh you know the same data type concept is there in the entire python again when I said the statement the many times again I’m saying there is no any data type okay so that don’t be confused anywhere so when you’re talking about the method and operations so I think set concept you already learn in a school days set the right so whatever you learn like a union section and difference and a difference update um you know this same thing same concept is also available in the programming language as well we talking about the operation so we can iterate it with the for Loop like other programming language for Loop concept we can apply it but we can’t access with any index even in the dictionary we had key so that we can access it here we don’t have any key if you want to take a values is one by one you have to apply the for Loop okay even the for Loop you can apply in any data type so when I will not write it here okay we’ll directly jump on a method and functions okay let me just write it here method and function again there is issues okay method and function so method is basically uh let’s first discuss is the union okay and the second one we have a intersection I’ll just write a small small there is not a capital intersection we have a difference okay we have a difference here is a point okay so set if you have defined with the S so s dot s dot s dot so let me just explain you a little bit about what is a union what is a intersection and what is a difference okay so suppose I have one set S1 which Define the value is a 5 7 8 and 10 I have a different set S2 which Define the value is uh uh 3 7 uh 11 and 9 okay so when you just created the complete set let me change the color complete set so there is one set where the values are available is a five 7 8 and 10 there is one set S1 and when you’re talking about the S2 so S2 is like this okay 7 is also available it’s a 3 11 and 9 when you’re talking about uh uh the um Union when you’re talking about the union so Union will take s One Union which Define the symbol like this in S2 and in a programming language we are writing the statement and s do Union with S2 okay so it’s there is no any symbol concept is available in a set programming set data type so in a set theory in a mathematics that symbol was there so the value will be the value will be uh 5 7 even 8 is also there 10 and three and 11 okay 11 I already defined okay okay here let me just write it at 10 11 and 9 okay so this will be the union so Union is basically like this we’ll take all the values we’ll take all the values better the same way we’ll take all the values here all right okay so when I talking about uh the next concept is a uh intersection so S1 intersection S2 so it will take only the common which is the common values here so here only one values is available which is a seven so intersection will be like this this part only seven okay only seven will consider as a intersection so this part will be a intersection and you know and if you’re taking entire things that will be the union if I’m talking about the difference there is also one more concept is a difference so difference uh let me just make blue color okay so if have a value is S1 and S2 here is a 7 uh 5 10 and 8 3 11 and 9 okay if I have a value is this is the S1 and this is the s 2 and if I value is S1 difference S2 if I Define like this so from the S1 I’m removing the S2 okay so it will take the value is one Le this only this part it means only the seven will remove okay because from the S1 I’m removing the S2 so 7 will remove so you will get the values is a five 10 18 so here is the very interesting concept is there he uh if I have a toule I have a list as a container so what is the need of a set so what is the special qualities there in a set concept the special Quality quality is there the set never take a duplicate values okay so I can also write somewhere let me just write it okay can I take it the next page it’s very difficult okay all right so let me go to the Practical implementation I’ll just write on a practically itself let me just remove all those things all okay all ranks yeah all right so we are learning the last concept is a set so set is always take a unique values I can write here okay so set first of all it’s a mutable let me write here itself okay it’s a mutable and unordered data type unordered data type and the second concept is that set always take always take unique values unique values there is is no any duplication you’ll find it out in the set concept but in a tle and list you can put a duplicate values as well that is a speciality of a set concept set data type if I Define the set is like the you know curly brasses 4 6.8 and K and nine so this is the set okay it always take a unique values here is sometime confused that I’m just using the curly brasses as a set curly brasses as a dictionary as well with the key value pair but how to define the blank set and blank dictionary it’s very very confusing right so suppose I have the uh a variable temp variable TMP variable so which is the curly bres so what will be the data type of temp it will be the set or dictionary so when you just check the data type okay when you just check the data type of attempt so you will get a dictionary it’s not a set but how to define the blank set so blank set is defined like S2 is equal to set set function bracket see this function we are using to define the blank set when you check the data type here S2 you’ll get a blank set okay we still here so let me just create one more a set here S3 is equal to 4 6 uh 9 okay 1 6 okay six let me just take it one more time 6 6 6 and uh uh 15 so when I just print the value is S3 you will get one this six is one time it’s not showing the multiple time here in case if you have a list if you have a tle it will showing the multiple time but the set will take always the unique values so I have S3 I have S1 I want to perform some operation here like uh Union intersection so S 3 dot Union if I pass the value with S1 you will you will get the values with the combination of S1 and S3 but the value will be always unique you can see here the 1 15 5 6 which is a combination of uh S3 and S1 here there is no any particular order is available because of the because of uh the order is not available so you can’t access it in case if you’re passing the S3 in square bracket of four you will get a error because there is no any POS positive and negative indexing is there but you can apply the for Loop here like for uh variable V in s so if you want to iterate it you can iterate you can iterate it but you can’t access any values with a square bracket like uh list tle string and a dictionary with a key that you can’t do it here okay so again uh you can perform the U difference as well we can perform the intersection as well like S1 do intersection intersection you’ll pass the values as S3 you will get the common values here which is S4 and 9 if I perform the S1 do difference okay difference so there is the two things difference and difference update so if I pass the values S3 so whatever values there in S3 which will be uh s which whatever value is there in S3 in S1 that will be removed so here the 6 and 8 you’ll get the values you can get here S1 and S3 so S1 and S3 here you can see the S1 which is a four and 9 which is a common that’s why it’s remove the four and 9 from the S1 with S3 and now I said that there is the two values the difference and difference update the difference when you apply so the value will be as it is it will giving you the result S1 is as it is S3 is as it is but if you apply the values S1 do difference update difference update and pass the value is s uh3 you will get the update updated values in S1 okay previously the value was not updated as I said that we can add some values as well we can update some values as well we can remove some values as well right so if I am talking about S3 so I want to add some values S3 do add and pass the value is suppose 56 so you can add it okay because it’s a mutable data type if I want to remove anything as three. remove I can easily remove it like nine you can remove it if I want to uh update I already discuss there is lots of things is there intersection Union difference okay so you can perform it so again you have to run this J notebook where is the last section yes last section here you will get the two difference set and performance all the operation here the one by one you will easily understand all right so you can see you’ll find it out each and everything thing yes uh the one thing I forgot to discuss with you the mean and Max and Len the same concept we can also apply it here so mean Max you’ll find it out the minimum values you can find it out the maximum values like S 3 mean of uh what is the minimum value of S3 you get one what is the maximum values of S3 you’ll get uh S3 but again don’t forget to run that jaal notebook okay that give you the more clear idea as compared to this video right video just giving you the complete overview but the details if you want to go the jiter notebook is important for you so before going to the next topic like uh uh looping concept first you have to understand the entire data type concept from the Jupiter notebook this is the set so there is one more application one application is there in a set which is the uh set comprehension likewise the dictionary comprehension we had we had a uh list comprehension so set comprehension is also there comprehension okay set comprehension so set comprehension the syntax will be the same like the and list so whatever for we have to use for that particular variable in sequence sequence can be any range any uh other sequence like a list or tle or or list or tle mainly so here just you have to write variable and curly bres is mandatory for a set okay so let me just create it I want to print just one to uh uh uh one to 10 number one to 10 number let me just print it here for I in range I’ll pass the values of 1 comma 11 is same like a list and dictionary comprehension only the syntax is little bit Chang this because of data type is change when I just run it 1 to 10 number in case in case if you you have a list okay instead of this uh set I printed the values is instead of the I I I’m just want to print high so the high will print 10 times you can see here high is printed the 10 times but if you apply the same concept for a set you will get only the one times it will be generate 10 times but the accept only the one times go here and run it so you’ll get only one times that is the speciality of a set which is always take the unique values never take any duplicates okay the last concept of the set is that Frozen set the Frozen set is basically it’s not a new thing here it’s we can say let me just remove H we can say it’s a it’s a immutable set so whatever we we had a set concept that was a mutable so here we have immutable set immutable set but again if it because of the set it will be unordered immutable set and that is the unordered okay it’s a immutable set that I was talking about Frozen set okay that concept is a frozen set so let me just discuss it little bit and after that uh we’ll stop this video because the Frozen s concept is already there in the Jupiter notebook okay the heading is frozen set Frozen set which is nothing but immutable set and unordered okay it’s immutable set and unordered so suppose I have one particular set which is the S4 and I Define the values like this okay there is so many duplicates is also there if I print the S4 you will get the only unique values so this is the set which is a mutable but uh if I want to make S5 as a frozen set Frozen Frozen set yeah Frozen set I’ll pass the S4 and run this values so S5 is a frozen set S4 is a normal set let me also Define one more set it here so 5 6 2 1 yeah that is enough okay so can we perform the operation in between the Frozen set and set answer is yes so only thing is that it’s immutable so if I want to add anything in S5 which is a frozen set do add and pass the values is anything like uh 1,000 that will showing you the error because Frozen set has no any attribute of addition but because of this set we have we can perform the operation of like a union intersection difference this values we can easily perform so like if I want to perform the difference operation here S5 do difference you can see the common values is a five and six so S5 difference with S6 which is the set normal set which is the mutable set we can say and S5 is the immutable set when you perform the operation you will get a Frozen set values okay but but if you do it Ulta if you do it the opposite one S6 dot difference and pass the values s five then you’ll get a set because I perform the operation the difference on S6 okay S5 on S6 so S5 is nothing but a frozen set S6 is a set that’s why it’s perform like this again you can you just run it it a small thing is here you will get the values finally we completed all the data types numeric string tle list and D dictionary and set but after completing of all the data type and we we discuss in the very details way but we have a confusion sometimes which one is a mutable which one is immutable which one is ordered which one is unordered because so many things is there where we can add it where we can remove it so in this video we will focus on that at the complete mind map of all the data type so that if you’re going for interview you just have to refer this slide you can easily understand all the data type in the same time okay so let’s start it so numeric data type we have a mainly three main function uh first we’ll start start with a function so we have a int okay we have a float we have a complex this three function and string we have a St Str function tle we have a tle function list we have a list function dictionary we have a dict function set we have a set function this all the data this all the function is available for all the data type all right when you talking about how we are defining so integer we are defining like a 5 7 like this the float we are defining like 8.9 with some decimal point complex we are defining like a 7 + 8 G okay string we are defining always with the if if you start with the single quotes always end with the single quotes if you start with the double quotes end with the double quotes tle we are defining with e is equal to round bracket 5 8.9 like K anything you can Define it there is no any common data type concept is there in the entire Python programming language so list we are defining like L is equal to square braet 5 8 7 9 7.9 square bracket we are using dictionary we are using the key value pair like a d is equal to key values okay key values pair and when you talking how we are defining the values D is equal to like 5 col 8 okay 7 col 9 for a set we don’t have a space so I’ll just change the color okay the set we are defining the value is s is equal to curly bres 58 directly you can pass the values this way we are defining the all the data type okay so when you’re talking about the mutability and immutability okay mutability and immutability which one is a mutable and which one is a immutable right so the numeric data type is a immutable string data type is a immutable tle data type is a immutable list is a mutable dictionary is a mutable set is a mutable okay see it is a mutable and the next one is a ordered and unordered so let me just write here ordered and unordered okay ordered which one is ordered which one is unordered so numeric data type there is no any concept of ordered and unordered likewise the uh numeric uh for mutability as well to numeric there is no any meaning of mutab and immutability because it’s not a collection anything like string is a collection of some letters or El uh okay so if you have only one letter so at least it will be defined the index is a zero right so so string tle have a meaning is that it’s a mutable and immutable ordered and unordered so likewise in a numeric we don’t need any discussion for numeric immutable and mutable string is a ordered okay couple is a ordered list is a ordered dictionary is unordered set is unordered clear set and dictionary is unordered whereas a tle list and dictionary is a ordered all right so if you want to add anything again so dictionary uh uh sorry numeric there is no any meaning of that we can add it or we can’t add it likewise the string as well so here tle dictionary tple list tle list dictionary and set this will be considered as a container because it contains some values right so like the tole we are containing the values is a round bracket list is a square bracket dictionary is a key value pair set is also containing the values whereas where is tole let me again make it different color tole list and set it’s called as a sequence okay why it’s called as a sequence because we are directly pass the values so only dictionary we can’t as a sequence because it’s a key values pair if you just iterate the values you will get a only key if you’re not passing the dot items you’ll get only keys so that’s why we are not considering as a uh sequence but dictionary is a container so this is the way where we can remember it if that is not more important like which one is a container which one is not container because that is not a question question is that which one is mutable because giving you the information that we can’t change the values it’s a immutable if you have a mutable that we can change the values that is giving the information right so the container sequence is just tell you that we can we can just uh you know wrap up the multiple values at the same time if you’re talking about the add the values so no we can’t add any values okay I’ll pass I’ll write the no we can’t add any values there because it’s a immutable but in a list if we want to add anything so we have a multiple option is available like uh append okay we have insert okay in a dictionary there is no any direct concept is available and and and we have also the extend option is there extend okay when you’re talking about the dictionary we can’t directly add anything but like this b square bracket key and pass the values is values we can add it right there is no any direct method is avable label but we can do it and uh set yes we have uh s do add method is available this method we can add the values but in a tle we can’t add anything the last thing is the delete so there is no any meaning of uh the deletion of in numeric and string because these are not a container but if when you’re talking about the tle so tle no we can’t delete anything because of it’s immutability we can’t delete anything but in a list we have a lots of option is available we have a clear option okay let me just change the color okay we have a clear option we have a uh remove option we have a pop option okay this option is available in a list and in a dictionary we have a pop option is is available okay and uh in a set we have also the pop option we have also the remove option that is a remove and we have a discard option as well okay but the important is that yes in a list dictionary and a set we can delete anything we can add anything and uh uh in a tle we can’t delete anything we can’t add anything okay so this is the complete mind map where we can just remember it and we can perform the operation this this data type operation in any applications let’s understand the conditional statement the conditional statement there is a three keyword we are using the first one is if second one is L if third one is else okay before starting the Practical implementation first we’ll understand the flow chart of uh conditional statement in a diamond shape we are always using a condition so condition is always start with if that can be two scenario that can be true and false if the condition is true then giving the statement okay giving the statement and pro uh the block will terminate after giving the statement it will not checking any other block it directly terminate okay here I’m just writing here and but if your condition is false I want to give a one more condition uh to check that time we are using L if we are not using IF in case if you’re using if that will be the separate block L if is also the condition then it can also be the same same scenario can be true can be false if it’s true then giving the statement okay giving the statement and the same thing after giving the statement program will terminate and after the uh Al if condition I want to give one more condition then again you have to use the AL if but in case if you don’t want to give any other condition you just want to stop it you can directly top this block but we always doing this practice that uh the the last one we always using else so else is not a block else is just giving the statement in case any block is not uh you know if any if any block is not passed so here I’m just using else else is just giving the statement if any block is not satisfied then else block will run and then directly terminate after the else block you can’t write any other condition in case if you’re writing that will be considered the separate block the separate section that is not a relation of the particular block so whatever we discuss that is one block is mentioned there this is complete one block like if the one condition is satisfi then giving the statement not satisfi then giving the any other state any other condition to check that the condition is satisfied or not let’s try to understand in the Practical scenario how exactly is working and then we’ll also enter the real life scenario as well let’s say for example I have a three variable a is = 5 b is = 8 C is = 19 this three variable is there and the condition is always start with if we are writing if take a space and write it down a is greater than b okay that uh your condition after the colon it automatically taking the four space that we are calling indentation and we consider as a block if I write the statement as a print hello and when you just run it and it will be check the condition is satisfied or not so a is greater than b means 5 is greater than 8 is it true or false so obviously is a false that time is not giving any answer but if the condition is satisfied like a is really less than B that means five is really less than eight then it’s giving the answer is hello okay but here I put only one condition in case if you have a multiple condition is there if a is greater than b okay if a is greater than B that time will print normally hello and and uh when you click enter after this print statement it’s automatically the same block this is the same block but I want to write one more condition so obviously I have to go back and write one more condition which is the L if L if C is greater than b colon let’s write some statement statement is hey and if I want to one more uh uh if I want one more condition I’ll write it the L if is a is greater than C there is a three condition I mentioned there and simultaneously you can just write a many condition is here okay hello hey hi and after that we always using the ls this is the good practice in case if you’re not using it will not show you any error so likewise here it’s not showing any error so same wise here it will not show any error if you’re not using else just write down here else colon and your statement print hello uh just buy else is always execute if any block is not executed previously if any block is not executed that time is working so python is always working the top to bottom okay it always check that line number one is um um satisfied or not satisfied a is greater than b the meaning is that a is greater than b B that is false Okay C is greater than b which is true a is greater than C which is also false and else is always is a default one in case previous one is not executed that time it will run okay so here the block number two here the third one line number three is execute it when you run it it giving the answer is he but what happened is all the condition is satisfied all the condition is true like a is greater than b okay A a is less than b uh and C is greater than b and uh a is also less than C that all the condition is satisfied so what will be the answer the answer will be the first one because according to the rules here which we discussed if the first condition is satisfied is giving the statement and terminate the Block it’s not entering the next block because l l if will check if the first condition is dissatisfied right if the first condition is satisfied is giving the statement and terminate the block but here the L if is after the false of the first condition so here it giving the answer is hello one day again the last one if no any condition is satisfied that time the buy will execute which is the default one if nothing is there nothing no any condition is satisfied like uh I’ll just change it here uh greater than less than greater than so all the condition is false there is no any true condition and uh so when you just run it it giving the answer is by because nothing is satisfied here this is the way of conditional statement we are using but again do you think that we are using this kind of conditional statement in the real life answer is no we are not using this kind of conditional statement this is the way where we are learning we are starting the conditional statement to connect with the real life let’s take one example and we’ll understand it how exactly the conditional statement and other things like a loop is working the example which I selected that logging with username and password login with user name name and password okay this is the real life scenario where we’ll implement the conditional statement let’s say for example one one different example and obviously the practically we will use with the username and password login if you’re going for applying in a passport in a passport office there is a first condition you should be eligible for 18 year old okay if you are 18 year old the first condition if you you satisfied then it will be check second condition do you have a pan card do you have a AAR card do you have any other government documents it’s like that like it is like condition inside a condition right so here in the real life we always using condition inside a condition that scenario we are calling nested conditional statement the statement which we are using calling nested conditional statement nested conditional statement okay as we discussed in the last slide so where we decided that if and L if is using for a condition where is the else is giving only the statement okay else is not giving any kind of condition only the if and L if given the condition let’s understand the flow of the Ned conditional statement the flow is always start like this if you have a condition condition one okay so obviously the condition is always start with if that can be true scenario can be true can be false okay if the uh condition is false that time if you want any other condition we always using Al if okay if you Al if that can be true that can be false that we understand in the last uh slide but if the condition is true and I want to give one more condition okay that I can write here condition two I want to use one more condition what will be the keyword is it be a if or if the answer is if okay so previous slide what we had we had is like if the condition is satisfied given the statement and not satisfied that time Al if or else right so there was no any confusion Al if is always coming from the false but if I want to give one more uh condition that time which keyword we have to use the keyword which you are using it here if if the condition is coming from if the condition uh as I said that Al if and uh if I have right Al if and if I have so both are giving the condition right both are giving the condition but if the condition is coming from the true part and if the condition is coming from the false part so we are using accordingly if is coming from the true then we are using if the condition is coming from the false we are using Al if hope this one is clear so condition is always the two scenario the true and false okay if the condition is true and again if you want to give one more condition condition number three so again we have to use if but let me just stop it here if you want you can just increase it accordingly I’ll give the statement okay I give the statement and give the statement if the statement is given OB obviously the program will terminate I’ll make the termination is here end program is terminate in the end it will be check in other block if you have okay so here given the state condition is uh the statement is uh ended again if it’s a false I want to give any condition so what will be the keyword condition number three what will be the keyword the key keyword will be Al if keyword will be Al if right why the AL if because is coming from false part so if its condition can be two possibilities can be true can be false if it’s true and here here if I want to give any other condition then what will be the uh keyword condition number four what will be the keyword keyword will be if because it’s coming from the true part okay and and then let’s give the statement I I don’t have much space so I’ll just close it here okay okay and then program will terminate and after the false if the condition is a false it here don’t worry we’ll understand with the Practical scenario and that is a real life example so you can easily understand okay so giving the false if the false and if you want to give the condition L if you can use it or else I am just using here the else with statement okay else is not giving any other Condition it’s just stop the block the same time here this El if I after the El if I want to give the condition I want to give the condition let’s condition number five okay condition number five then it will be start with if not Al if why because the uh uh the condition is coming from the true part okay so it’s giving the statement after giving the statement program will terminate after the statement program is always terminate it not take any other section okay and here is a false was there here is a true was there after the false it’s on you you you can pass any else block you can otherwise you can D directly terminate the block here I am also terminating the block without giving any else part let’s make it a else part it here okay else part and terminate the block so this one looks little bit clumsy but uh it’s very easy when you start doing the practical and uh when you start doing any practice okay uh let me just summarize it what exactly the conditional statement is working with Nate conditional statement see we have a if we have a l if and we have a else okay if and L if is giving the condition these both are giving the condition and this is giving the statement is not giving any condition and this one this condition is always start in it start always using the if always if we never start with L if and if the condition is coming from the true part we are using if if the condition is coming from the false part we are using Al if very simple let’s try to do with the Practical scenario okay so to understand the Practical scenario with the Ned conditional statement again uh this is I have to write one more heading uh which is nested conditional statement nested condition okay nested condition don’t worry you’ll find it out this uh this Jupiter notebook below the link in this video okay so suppose I have one username which is very simple just like um a hurry and the password which is defined it here currently we are not connecting with any database in the future we definitely will do that I’ll continue with this this example in a very broad level hurry 1 23 it’s very this is the password is very simple hurry 123 I want to perform the operation condition if the first one I have to take a user so uh user input user input I I take the example is input please enter your username okay the same time the password uh password input PS WD I can write it here it’s just a variable input please enter your password okay the condition we can just perform it here if your user input is match with double is equal to you are comparing you match with user if it’s match with you can just writing it this currently I’m just checking that my program is performing well or not user name is correct so when I just run it it’s uh asking that will please enter your username username I’m just writing the hurry and is asking the password is hurry 1 2 3 so the username is correct that means whatever I wrote the program that is perfectly fine okay so when I can say that my uh when I can say that uh you log in it successfully if your username and a password is correct right so if your username if your username uh is match with hurry and if your password WD input is match with password okay this password and his input is matched with password that time I can say that print login successful logging successful okay all right so let’s run it again and check that so here you can say the if inside if you perform it right if you have a multiple username multiple password that time you can just perform accordingly L if can also be performed I I’ll show you so when I just run it your intro username which is the hurry password is uh hurry 123 okay so logging successful but again when I just run it there is one issues if my username is incorrect still is asking that what is your password if my username is Inc correct it don’t need to ask the password right so if I’m my password is a correct so it’s very difficult to know that which one is wrong so it’s not showing any other any information you can see here it’s not giving any other information so this is wrong we have to use else so that we can tell to the user hey your password is wrong your user is not wrong the first issues you have to solve it here is that it should not be asked the password until your username is correct okay my username is correct the time it’s ask the password right if I run it my username is incorrect it not ask the password that I perform well but if the username is incorrect I have to give the proper answer hey my username is incorrect so the line number three If it’s incorrect I have to use else block for that else I have to write there my usern name is incorrect okay my username is incorrect not my username username is incorrect that’s it username is incorrect some explanatory symbol okay username is incorrect right so if I’m writing anything any uh not proper username then it’s saying that username is incorrect but again if my username is correct like hurry and it’s asking that enter your password so if my password is incorrect that’s not giving the proper information I have to write something here for the line number five if block else print the user uh print the uh password is incorrect okay password is incorrect so that we can know that which which is my incorrect uh you know section is there if I’m writing the hurry password is incorrect the password is incorrect is mentioned there let’s run it again hurry already 1 2 three now properly loging logging successful and in the real life scenario if you have any proper software so after the logging successful you can start is any other function any other block to uh different application you can start from here right from this uh username and password login in case if you have a multiple username multiple password then what will perform so I can also perform like I have a multiple username I’ll copy it I’ll not do anything with this blog multiple username that uh another username is a kind of uh John John 123 right so here I will use because the first condition is not satisfy I want to check one more condition that will be the L if L if user input is uh if user input is match with um the previously it’s checking with the user So currently I’m checking with John that was uh hurry and that was uh Harry 123 right previously I defined a different variable but I I can write it out directly here here John if my um user input is a match with John okay the time I will ask the password again the same thing I’ll perform I’ll ask the password what is your your password if my password is also match with here I will use if not Al if go back again you can check it if your condition is coming from the two the time we have to use if right here if the condition is coming here L if if the condition is coming from the true we have to use f okay so you can use it here just give me a minute yes sorry for that let’s continue I will use the condition here if my password p a s WD input is match with is match with John 1 2 3 if match with the John 1 12 3 the time I can write the statement print um logging successful okay Lo logging successful that can that time I can also write it so here you can say I use the if inside if I use the AL if inside the if right I also use the else as well so username is incorrect like if not match with not match with John the time is giving the username is incorrect but in case if your password is incorrect and here password is incorrect I didn’t write anything let me just write else password is incorrect okay when you just run it is asking that your enter your username I’m writing the John okay it will also accept the hurry as well and here I am writing the hurry 123 so that’s saying that password is incorrect because it’s already enter in this block and is checking this kind of password okay it cannot be checked the previous one let’s run it again hurry H 1 12 3 is giving the loging successful John John 123 is logging successful it’s perfect L fine so hope you understand the scenario and when you’re talking about the future persp future perspective of this login with the username and password the simple thing is that what can be the uh future scenario the first thing is that if you have the thousand of user thousand of password then how we will maintain it so you can use the dictionary to maintain it in a temporary basis and that permanent basis you can use the database second example is that if my username and password is incorrect so the block is like down block is uh stopped directly like a password is incorrect stopped but it should be ask the password one more time right so the time we are using the loop so the next con concept which you are using which is a loop and where we’ll discuss that how the loop we can perform with the user and login pass uh this example there is two types of loop is available let me back two types of loop is available while loop and for Loop okay before going to the Practical implementation we’ll first discuss about the flow chart so the every Loop there is a condition and after that we are entering the uh block right the condition is always showing in a diamond shape and statement is a rectangle shape so here the condition is not defining with if the condition is defining with a while if you have a condition and uh condition and I’ll Define it a while okay so that can be two scenario that can be uh true that can be false here I’m writing the false uh because of the reason I I’ll show you because it will be very difficult to define the structure that’s why the false I’ll write in here can be true can be false if the condition is a false that time is also giving the statement okay the time is also giving the statement and you can also write one more condition like with while we can also write a condition with if anything you can write it but if you write the condition with a while let me write properly while if you write the condition with while then if the condition is true the giving the statement giving the statement after the giving the statement back to the loop again it’s never terminate the difference between the conditional statement and loop is that Loop is end Loop is continuous uh running whereas the conditional statement is ending okay so the loop is end when the condition become a false the one only one way to condition uh there is only one way to stop the loop if that condition become false okay this is the way our Loop is working so when you’re talking about a nested Loop so nested Loop is also the same but before going to the nested Loop let’s first understand some practical scenario the last video we discussed uh uh this example I’ll continue with the same example before going to this um you know real life example I’ll give you some small uh you know exercise suppose a is equal to 5 is is equal to 7 and B is equal to 9 is there okay and we wrote uh I just want to print 1 to 10 number not to this number with this number I want to print one to 10 number so I want to start with one okay is equal to 1 so while there is a condition while there is a condition condition condition is a should be less than r equal to 10 so one is really less than r equal to 10 a while is working kind of condition with a loop right condition with a loop and and write the statement is uh High okay so the number a is equal to 1 which is true which is giving the true section to uh true statement here and it will enter inside a loop and 1 a is always one so when you just run it here when you run it here it will be run in uh like a infinite Loop because a is always one and 1 is always less than or equal to 10 so it enter in the infinite Loop so you can see here your process is still running so it will never stop so I have to forcefully stop it here and then I’ll tell you where how the proc process will working okay I’ll make the increment I’ll make the increment here a is equal to a + 1 a is equal to a + 1 so what will be happen he starting the a is equal to 1 and also print the a as well a is equal to 1 the next time is become a equal to a + 1 so a + 1 is become a two two is assigning to the a it not ending the loop it will running again and again again and again and until the condition become a false here the condition become false like if the number become 11 which is not less than or equal to 10 then the program will stop when you run it 1 2 3 4 5 6 9 8 10 okay program will stop so you can just write down here uh program finished finished okay program finished so when this blog will end then program will finished okay and this we are using so as I said that this is the why while is working as a condition with a loop if it’s a condition so I can use the default statement like else so yes I can also use LS it here and instead of writing here I will use it here so when the condition will be running it will be run that statement and when the condition become a false the for this condition become false I can use it here okay so like this this one is working so when you’re talking about the nested Loop how how the nested Loop is working so here I will just focus on the while loop okay for Loop we’ll discuss later I’ll focus on the while loop here so nested Loop how it exactly is working I’ll just connect with the real life scenario as well let’s first understand with the uh flowchart okay let me remove yeah so I have a loop I have first condition condition with the while okay that can be true scenario can be false can be true okay if it if it’s false so it’s on you you can uh write uh statement without else with else as as well so I’m just writing here with else else statement again State else okay else is always giving the statement No any condition so the condition number one and if the condition become true I want to give a statement you can give the statement okay according to the rules it will be back and repeat it again and again and this will be end but I don’t want to uh repeat it only this block I want to add one more condition is here so what I will do I will write one more condition condition two that again it will be used with while okay and that can be two scenario like uh the previous one can be true can be false false okay if it’s a true then it will be repeat the block it will be repeat the block I’ll give the statement okay I’ll give the statement after giving the statement it will be jump it here but again just think about it if here the condition become false I give the statement the program will terminate the answer is no program will not directly terminate here when you just directly terminate if you’re writing that means it’s a false this is not like that it will program terminate if you have a loop inside a loop this one is Loop inside a loop we can say nested Loop we are working right The Heading name is listed Loop if the program uh the second Loop because it’s coming from here after giving the statement here if the block if the uh condition is a false given the statement after giving the statement it will be back it will be back it will be back to the loop if the first one is also false then it’s okay if the first one is also false then given the statement then ter end the block this is the way our nested Loop is working okay so to understand the scenario I’ll give you one example and with that example we’ll understand okay I want to print 1 12 100 number uh I want to okay I want to print a 1 to 100 number 1 to 100 number okay in the 100 number starting 1 to uh 20 I’ll print hello and 20 to 40 I will print a high and then 40 to uh 70 again I’ll print hello okay 70 to uh 72 uh 72 100 again I want to print here okay I want to print uh let me also put one more condition 70 to 90 print hey again 90 to 100 I want to print hello again you can see I want to print hello three times one time two time and three time so in between high and ha is also there so how can we perform with a nest uh you know nested Loop is here in this example let’s try to understand okay so instead of writing the loop I can write it here uh while and for but I’m working with the while okay I’m working with the while all right I want to print one to 100 number let’s print one is is equal to 1 and uh while a is less than Ral to 100 and just print the hello first okay hello and with that number a all right and uh let’s increment it is very very important otherwise it will be enter in the infinite Loop let’s run so 1 1200 it printing in the hello but my question was that in a 20 to 40 I want to print high okay and 70 to 90 again I want to print he let’s first focus on this 20 to 40 hi and again hello 20 to 40 so I will enter inside the loop again while a is greater than 20 and a is less than or equal to 40 okay less than or equal to 40 if it satisfy the time I print high and with increment a is equal to a + 1 so what will be happen so it’s printing 1 to 100 number 1 2 3 4 5 6 100 right but in between if the this block is satisfied like 21 so again 21 let’s print a as well 21 High 21 22 High 23 high like this this program will run repeatedly when the number become the 41 it back to the again Loop is this satisfied or not yes it satisfied that means the 41 is also less than or equal to 100 then again hello will print when hello will print run the block like this 21 to 40 like this okay and again hello will back because because I want to print the 40 to 70 hello again so I will not write the separate program for hello okay because previous block it already running the hello the same thing I have another condition which is for 70 to 90 he so I’ll write a while a is greater than 70 and a is less than or equal to 90 I’ll print the value is a a again you have to a is equal to a + 1 you run it so high which is start from 21 to 40 again 71 to 90 again hello this is the way our Loop is working okay this is the way our Loop is working this is the process so hope you understand let’s try to understand how can how can we Implement with our real life scenario which I promised in the last video Yeah copy just paste it here I want to incrementally running this program okay incrementally running this program so let me just remove one block let’s make hurry only okay so what happen if my username is incorrect it show knowing that username is incorrect but it should be giving the option for to pass username one more time this is not showing it here so what I can do I can apply the loop is here okay I will ask the usern name in a loop while I’ll make it true directly I’ll make it true when I just make it true yes I’ll make it through it here when I make it through so it will be uh you know in on a looping format so it will ask the question username username is hurry which is incorrectly I’m passing it here so it’s saying that username is incorrect okay when I just pass hurry again so it’s asking the password password is incorrect if I’m passing here it’s saying that password is incorrect and again is asking the username let’s pass the hurry hurry 1 123 proper password logging successful after logging successful it should not ask anything so what is a good practice of writing the code writing code is that make a small code to run it and check that where is the mistake and Sol it one by one okay so if the my loging successfully so make sure that you have to break the loop okay if here I’m forcefully breaking the loop because I’m not performing any numbers is here so that after some time the number become a false it will never be false so that’s why I’m breaking forcefully okay so again username wrong is asking the username is incorrect so hurry I will write hurry 1 2 3 so logging successfully into breaking the loop okay so here I want to perform the nested while loop because you can see when just run it hurry uh wrong use uh yeah hurry and password is wrong the time it should be ask only password but it’s asking that password is wrong and asking the username one more time it’s not make sense so what I can write it here hurry hurry 1 2 3 let me just close it I will perform the condition that uh this password uh password condition separately while true and everything I’ll put inside a loop so what will be happen if my username is correct if my username is correct it will be enter in the second Loop okay entering the second Loop and if password is wrong it’s not going back directly it will be repeating only the password part let’s run it oh sorry let’s run it my username is hurry password is wrong it’s asking the password only okay if my password is correct hurry 1 2 3 so what will be happen logging successful is a break the loop but it’s breaking this Loop only but the problem is not breaking the first Loop that’s why is asking the username you can see it’s breaking this Loop there is a two while so obviously there is will be the two break okay so after the break I have to break one more time is here okay in this condition here as well if my blogging successful I have to break two times inv Violet okay sorry here I can’t use it because uh this will be here why I think so yeah why I can’t use it because it will be the same block password is incorrect okay wait a minute I make it wrong this is for inside because it it was impacting to this else that’s why I was not able to use it so username is hurry password is incorrect is asking that you ENT enter your password only I’ll write the password is here hurry 1 2 3 it’s showing that login successfully properly Stop the Loop so I am giving you one uh task for you so you have to apply the numbering the the task is that I will explain in after two three videos okay I’ll explain after two three videos not a two three videos after the uh loop ending so the task is that apply oh not here sorry I it code hurry hurry 1 2 3 the task is very simple you have to apply the number part apply number in apply number apply count if username and password is failed in three times okay if the username and password is failed in three times so you have to stop the uh apply the count block account block if the username password is a failed in a three times so your your process should be blocked for some particular duration just imagine that if you’re applying the username and password in ATM machine it’s blocking for some particular duration like 24 hours so you here you have to block for just 20 seconds 30 second right so I’ll explain you after two three uh after completing of the for Loop so whatever flow chart is showing it here for while loop that is also applicable for for loop as well the syntax of the for Loop is a little bit different uh when you compare with the while loop so basically how exactly the for Loop is working so for Loop is working like for this is the Syntax for any variable you can write it and uh that sequence in sequence and the code whatever um block you are writing so I’m just writing here the block so you can whatever uh you know block or any statement you want to write you can so here the sequence can be anything sequence can be your range sequence can be your list sequence can be your tle sequence can be your set right anything so basically the for Loop is used for the iterating of the process if anything is available in a uh you know in any container if you want to iterate it if you want to display the one by one we are using the for so let’s try to understand the Practical implementation so yeah for Loop suppose I have a sequence sequence is uh scq limes right scq is equal to range so range is one of the function which provided the sequence from one number to another number with interval so if I’m passing the range is like 1 till 15 yeah 11 so python have a rules that it never end with last values it end always before one so if I’m I’m writing the 1 to 11 that means it’s a 1 2 3 4 5 6 7 8 9 it never goes till 11 okay so I’ll just use a for any variable I’m writing the v in sequence so when I just print that variable so it will be printing the one by one it’s printing like 1 2 3 4 till 10 okay so that sequence can be anything so simply uh the range is very famous so let me first discuss about the range and after that I’ll also discuss other sequence as well so like here I want to print 1 to 10 let me again print and then we’ll discuss the details for I in range I can be it’s one of the variable 11 print I okay so one to 10 number here if I want to print 10 to 15 it will be going like start from 10 and end with 60 then it will print a 10 to 50 okay because it’s never end with the last values so after this comma it always the value is one because always incrementing with one okay but in case if you want to increment with the two like 10 12 14 16 like this let me write the 26 okay 1 to 26 so I want to increment with y two so 10 12 it will be going like this right so this is the incremental way so if someone is saying that just print 10 to one so the process will be also the the same like for I in range 10 we will start with a 10 end with one when you just print it you will not get any values because after 10 it’s become 11 but you put the ending value is one so I’ll pass it here so it will not print anything so you have to decrement the value is a minus one so it will start from 10 and reach till min-2 not a uh it will reach to two not a one because the python is never end with the last values okay so you can’t pass any decimal point is here in increment and decrement always the integer values in case if you pass 0 1.4 will showing you the error so float object cannot be interpreted as an iner always try to understand the error statement it give the lots of information okay I’m just removing it here 10 to 1 10 to2 is printed as I said the other sequence is also acceptable here uh for examp example I have a sequence is a is equal to our statement is India India so if I’m just printing the uh this uh statement India in a for Loop for uh for V in a V is nothing but a one uh variable a just nothing but India so when I print V it will be showing the value I and d i a The separately okay because it’s it’s passing as a sequence and it open it here the same thing is applicable for any list as well so in the sense if you have a uh any list is available where five whatever values is available inside that that can be string as well okay and when you just apply the for for v in LS and print the value as uh V and it will be showing the value is the sequence order for example I want to perform the value as U um 1 to 10 number with the square up of each number like I have a list okay LS is equal to IM me just write a list which have the range of one to 11 so it will be showing like this okay this is the list but I I don’t want to list like this I want to list of the square of each values square of one is one square of two is 4 square of 3 is a 9 square of 4 is a 16 like this so let me store the value is any variable is a LS so when you directly applying the ls is a square of two it will be showing the error because that operator is not supporting so how can we do like this so that time the for Loop is really help us so we can like for each any variable each is one of the variable each in LS and when you just print each showing the values like 1 to 10 number but I want the square of each values so you can just perform because these are the one by one number the square of each values when I just run it is going to square but again the square of this values I don’t want the separately I want in the proper list like the original format so it will be showing like this the that time we can use the comprehension concept we can use the comprehension concept here I’m just using least comprehension list comprehension concept basically list comprehension is nothing but applying the loop in a list okay so whatever I I printed here I can I can just wrap up with the list how can we wrap it so the for each in LS was there so whatever you want to print you have to just write before you have to write before LS okay this is the this is the syntax of the list comprehension and whatever uh data type you want I want a list just make a square bracket it will be showing you this all the values sorry not LS that output you want to print so each will be showing like this so each is showing the all the values but if you want to apply the square it will showing you the square the syntax of the list comprehension the very simple simple uh very simple is that where where uh just uh uh sequence uh just iteration for where in sequence and before just write where that’s it this is this this is the syntax of uh the list comprehension but when you’re talking about the double comprehension the concept is also very similar just you have to perform the square uh round bracket it will be a uh tle comprehensive the comprehension concept is very famous and uh very useful in a real life scenario when you’re making any kinds of projects okay back to our topic um to understand the nested for Loop last concept is remaining in uh loop next for Loop how can be perform I selected one of the example the example is uh pattern concept I think you learn this pattern in a college test pattern okay pattern concept the pattern concept uh let’s try to understand how the pattern concept is working and after that I’ll Implement in a practical way so the pattern concept suppose I have this box okay I want to show you pattern here is a star here is a star here two star here is a three star and here is a four star okay as we know that uh our index in a python is always start with a zero so the index of the Python will be can we change the color yes we can change the color yeah so the index is always start with 0 0 1 2 3 so this index is also start with a 0 1 2 3 so the basically I want to display the pattern in the order but this pattern is made with a 3 cross 3 Matrix right so first you have to make a 3 cross 3 Matrix and then apply the logic there so let’s understand it okay how to remove okay so let’s understand it here first I’ll create 4X 3×3 pattern for each in range which is start from always zero so if you’re not passing anything to always start with a zero and I want to reach still three then I’ll write four colon Print Star okay when you print star it will be showing like this uh the one line uh like um the vertical way is printed here when you just apply the for Loop inside that for each uh better to pass rows and column wise the first one is rows right how many rows you have to print one 2 3 4 so here I’ll pass R here I pass a c for c c for column R for rows let me again explain that this is called as a rows and this is called as a column okay column 1 2 3 four row one row two Row three row four okay this is the way we are using all right so I’ll just use a row basically row and column in range pass the value is a four and again colon and just print it so when you just print there is a 4 cross 4 Matrix obviously it’s not a 3 cross 3 it’s a 4 4 cross 4 Matrix so I’ll remove uh this one this one four cross 4 Matrix because there is a four call uh four section is there python is starting from the zero that’s why uh I make it 3 cross 3 but actually it’s a 4 cross 4 okay when you just print it then you’ll getting the 16 stars but it’s not in a cube format why it’s not Cube format the reason behind that everything is a printing in the next line so in a print there is a keyword is a end keyword is available that by default is a sln if you want to know you can just shift click uh click anywhere inside this bracket and click shift tab you’ll find it out what is the default values available which is slash n when you just remove the slash n with a space okay by default is a slash and will you remove it and make it is just a space it will will be the horizontal V but I don’t want all the stars is the horizontal V I want only this all four values is the horizontal V the next all four values the horizontal V the next four next four like this so what I will do I will use the column is a horizontal way but the rows I will use as a vertical way if I’m not passing anything the automatically the end is equal to sln is there so when you just run it automatically four cross for Star will Beed so till here we understand now I want to make the pattern so make the pattern so it’s very simple how can we do that see here you can understand um yeah here you can understand the first point first point is a position of the 0 and zero so what exactly is happening the the row is taking the value is uh first one first is taking the value zero and uh then it will be enter in this this for second for Loop that will also taking the value zero right so that’s why the printing the position of the star zero the next time again going back and it’s taking the one that’s why it’s one 2 3 so I don’t want the second for loop as a four I don’t I want the dynamic based on the previous one okay I want to make a dynamic based on the previous one let me just remove okay so how can we perform it so basically so whatever rows is coming I want so after that this one this part should be only one so that it will be print only the position of zero and it will be ended and back to the for loop again okay back to the for loop again and when this row become a one so this one should be two let’s make it plus one this one should be two so that’s why the column will take only zero and one okay take you only zero and one so when I just run it we showing like this and when the row become a three so this portion become a four when this become a four when this one become a two this become a three if it become a three then it will be print one this in the position of 0 1 2 so that’s why is printing the 012 and it will be reach till four only that’s why showing the push star like this you can think about a different way of the uh opposite star so again don’t try to memorize it any stars try to understand the how the star pattern is working the reason behind that the star pattern is there in your syllabus because with the star we can easily understand how the nested for Loop is working how the nested concept is is working because the star is not only display with the for Loop we can we have other uh concept is available to display the star let’s discuss the apply the count block if the username and password is fail in three times so we already generated the code where is that yeah this one so I want to apply the block if the username and password fail in a three times So currently hurry if I’m passing hurry 1 2 3 and showing the value is logging successful what if the uh login uh your username and password is wrong more than three times so I’ll apply the count processes here count is equal to Zer and in every uh wrong username on a password it should be increment where is the username and password wrong here else the password is incorrect so I’ll just make it uh count is equal to count plus one and password is incorrect um one this attempt is remaining attempts are remaining okay so I’ll just make it here F so uh let’s do it in case if my password is wrong let me just see that uh the statement is correct or not um hurry and password is wrong then it’s showing that password is incorrect only one attempt is remaining so this is not a right way okay okay hurry 1 two 3 so what I’ll do better I’ll just fix it the uh three times if your username and password is wrong is more than three times then the process should stop for particular duration I’ll just make it minus okay then it will showing that uh it only three times is remaining only two times is remaining this kind of you’ll get only three attempts okay the same statement I’ll apply for if the username is wrong my username is wrong and I’ll make it comma uh this particular attempt is remaining okay this particular attempt is remaining all right so okay this okay so if my usern is wrong uh all right I forgot to write F this is string formatting if my usern is wrong two attempt is remaining one attempt is remaining zero attempt is remaining in the sense is the last one it should be stop it here so I have to put one more condition if the count become a zero I have to stop it what I can do it here uh so anywhere like uh the breaking the loop if my loging successful I can also write L if Al if we can write Al if the count is equal to equal to zero the time please wait for 10 second currently I’ll just write in the 10 second okay 10 second and after that process should start again all right so I’ll do the same process for uh this is for password I’ll do the same thing for username as well I do it username as well but the your process should stop for 10 second so how can we do that so there is a like library is called as a Time import time okay so you can directly write the time do slip your process will stop for particular duration so I’ll do it here time do slip for 10 second so automatically it’s a second how can we know that you can just write time. slip and bracket you can just check it what exactly is there it’s a second I click on here inside and click shift tab this option is available in the Jupiter notebook only and if you have any other ideally you can find it out other options okay let me just remove so the process will stop for 10 second and after that it will again start so it’s on you if you want to put the timing you can okay so currently it will be stopped for 10 second process will yeah only two attempts is remaining one attempt is remaining I’ll write hurry password I’ll make it wrong this is the last attempt zero attempt is remaining that means there is no any attempt this is the last one I’ll write it here uh hurry password is hurry wrong let me just write it just wait for 10 second the process is still running it’s not like that your process is totally end up it’s running for 10 second it hold for 10 second you can increase it now it’s ask asking the password again hurry I will write it and again it’s waiting for 10 second because it’s already been uh uh already been you know um is a kind of uh uh already your count was Zero that that’s why it’s waiting for 10 second but it should not be it should not be after 10 second it give the three times option right but here I’m passing the wrong password still is waiting for 10 second so that one glitch is there there I have to just change it uh it should be make it zero again uh it should make it uh three again all right so I use it hurry 1 2 3 and let’s make it yes sleep for 10 second and after 10 second after 10 second Make It Count is equal to is equal to 3 all right Make It Count is equal to is equal to three and it’s here uh where is wait for 10 second and the same thing we have to apply for password as well so this is for username I think yeah this is the username I think so we have to do for oh sorry not here it already there just count is equal to is equal to 3 not is equal to is equal to is equal to is equal to is a compar comparing it’s assigning the values so let’s wait for yeah one attempt 0 attempt there is no any attempt is remaining I’ll pass the hurry I’ll pass the wrong password it’s wait for 10 second if the 10 second will end up then again it should be Q next three attempts okay so let’s see yeah two attempt is remaining one attempt is remaining hurry 1 2 3 so this way we can perform the operation with a Time basis okay so you can also apply the different different operation this is from the totally scratch in a real life we just adding some front end otherwise the back end we are applying the same process this is the good way to learn our programming language all the concept try to always connect with the real life so function is nothing but a block of organized code where we can reuse your code again and again use for performing single related actions so we’ll also discuss in a practical manner so let me first show you how the function we are writing in Python programming language so we are first defining is a def def keyword we are using to define the function now after that function name like I’m writing the hello you can write anything any function name and then parameter we are defining like parameter 1 parameter 2 parameter 1 parameter 2 right and important to you have to make the uh colon after that it will taking a four Space 1 2 3 4 automatically taking the four space when you click enter and you can write your uh function body okay whatever C code you want to perform you can just write it but function will run when you call it so here when you just calling hello when you’re just calling the function and if you define the two parameters so you have to pass two arguments okay so suppose I pass the five and six that is the arguments so the five will store in the parameter one and the six will store in the parameter two okay sometime you confuse that which one is a parameter which one is the uh arguments so this is not a much complicated thing right so let me just remove it I also Define the same like here I Define the function with function name there is a three main parameter and after that when you just writing the function name the argument one will we passed to the parameter one so parameter we are defining arguments we are passing so hope this one is clear right so argument two will pass to the parameter two three will pass to the parameter three so in the function there are so many uh types are available not so many four main types are there so the very first one is a predefined function and predefined which is system is already given the function we are just using it right mean Max int print whatever you you already use it that is a predefined function you just just call and pass the values you’ll get the answer okay I’ll give you one small trick to Def to identify which one is a function see if you have a statement and after that this bracket is there that you call as a function okay so mean is a function Max is a function print is a function after that is bracket should be there because that function is a calling all right so we can also make the function which is we are calling user defined function that means we are defining the function the third one is anonymous function we’ll discuss in um practical manner a function without name so here you can see the uh you can see the def and function name so we can create a function without name but this have a different purpose first we’ll discuss the purpose and after that we’ll show you how we can make the anonymous function the last one is a recursion function that things we’ll also discuss let’s jump on the Practical Implement implementation how we can uh uh function can perform in practical way suppose I have a very small program a is equal to 5 b is equal to uh 4 and C is equal to a + b and uh I’m just printing and just print C and you’ll get the answer is 9 5 + 4 is equal to 9 but here if you want to uh just addition of different numbers for example I want to add 15 and uh 28 so every time you have to change this like 15 here and uh uh 23 so this is very simple program just imagine that if you have very complication fun any um equation is there like like I need annotation yeah okay uh like um y = x² + 2x this is the function uh this is the one uh mathematical function this is not a programming function okay I want to create this program like if Y is equal to x² + 2 into X okay this is the function and uh I Define the x is equal to uh 15 and when you just print it okay and uh pass the value is y and you’ll get the answer is 255 and in case if you change the values is 25 you’ll get accordingly this answer but imagine that this function I want to use somewhere else this mathematical function don’t be complic don’t be uh confused I I’m talking about this is the mathematics function and which function we are talking about here which is a programming function okay here I write a mathematical function programming function I didn’t started so suppose this mathematical function I want to reuse any other places to make a different applications uh so it will be very complicated to to to call it or else you can just copy paste and write the code again so this is not a right solution so what I can do I can make one block and call this block again and again right so I have a different uh equations instead of saying the function I’ll say the equations that will be better okay uh Z is equal to y + 2 y + 28 this this is the one of the equation is there so what what I’ll do I’ll just write here Z is equal to uh and different places I want to use it y + 28 so I’ll get the answer z I’ll get the answer here 709 uh 703 so here when I just change the value is like two you’ll get the answer is eight the next time value is change accordingly but I have to use this uh program again and again so better to better to uh you know I have to run it then you number will change so better I can make a block and call that block again and again so let’s make a block is a depth EF and function name is a equation equation okay as I told you bracket is very very important parameter it’s on you if you want to Define you can otherwise you can leave it and uh like equation is the equation is y equal x squ plus 2X you required X as a input so I’ll just pass it here parameters now your block is ready I’ll just print it y okay I’ll just print it Y and I just run it you’ll not get any answer function have a rules without calling the function function will never execute okay so here I can see this is defining the function defining the function okay I want to call it so what I’ll do I have to define the values X is equal to some some something or else you can directly uh pass the values equation I’ll pass the value is five so you’ll get the answer accordingly so this one we are calling the function this section calling the function okay this SE is calling the function in case if you change the value is like uh 25 you’ll get the answer accordingly right this is the way our function is running when you’re talking about how the block is executing what is the processes behind that so process is running like this it will check the line number one okay and then go to the line number uh sorry line number one is just uh comment so obviously it will start from line number two which is a comment right comment will not execute it will just run not giving you any any answer so first we’ll check the line number two and after that directly jump on the line number six if the function is defined there it will never enter inside right and uh after line number six it’s calling to the function then again back to the line number so now you are calling so that’s why it giving you okay yeah that’s why is giving you uh it it will be uh giving the line number two again okay and then it enter the line number three like this and then line number four as well so this is the way our function is working right it’s not like that top to bottom approach so yes python is working the top to bottom approach but if the function is there it will first checking that where the function is calling and after that entering the inside you can understand one of uh uh I’ll give you one one more example the use case of uh this function let me first remove it okay suppose you are making the calculator is a simple example you making one calculator addition subtraction multiplication and division there is a four different different function you define it but at a time you are using this subtraction so other things will not execute because you define inside a block if you define inside a block so this one this one this one you can save your memory you can save your time because the other program will not execute only the sub program subtraction will execute so imag that if you have a big project and in a project at a time everything is not running so part part wise the values are running right which one is required you can just call it but you have to Define you can’t remove it and you can’t write the code again and again that is the reason function is very very important so in a function there is so many topics is there which I have to discuss here so very first topic is a return statement okay written statement other next topic which is uh we can say um so user Define which we already did equation is a user defined function and uh um uh we can say uh system defined function a predefined function we already used it like in float print these are a user uh these are system defined like a print I’m using here as a function which is system defined the two type is done and the third type which is anonymous function function and the fourth one which is a recursion function the fourth one which is a recursion function okay recursion function there is a these topics we have to discuss let’s discuss the about a return statements let me just remove it okay so return statement uh I’ll take one example like hope you remember about math there is a um library is called as a math and if I want to know the square root of some particular values like math.sqrt I’m just giving you the use case why written statement is important and what kind of problem what kind of problem is solving by the written statements see if you running any any any if you’re learning any topic first try to find it out why you are learning what kind of problem is solving this topic so like sqr I want to know the square root of 25 you’ll get the answer answer easily which is a 25 and I can store it somewhere I’m storing in the variable R and uh print this statement as a um s root of 5 is R very simple statement is there uh square root of 25 is 5 very simple statement okay I want to create like this because here the sqr sqrt is a kind of method so method and a function both are the same okay here is little bit confusing like method and function both are the same or different so method and function both are the same let me just Define it method and function so you can say method when when we Define a function inside the class we are calling method okay so here we here I created the equation which is not inside a class class I am talking about object oriented class and object which is this one is not inside a class so we are not calling equation as a method we are calling function only so here why I’m calling square root of his a method because math is work like a class uh math is a work like object which class is defined somewhere okay with the object I’m calling method so method we are defining as a function don’t be confused method is a defining as a function but only difference is that it’s inside a class so if I I have a value is like a I have a value is like a def um ABC dep ABC I Define it okay and inside you write a body so this one ABC is a function but if you define like a class class name class name is suppose U uh temp okay class name is a temp and you define it and inside that there very uh important uh parameter you always right is a self so now here the ABC become a method why is a method because you are calling like a t is equal to Temp okay you created the object here and the T dot ABC you can use it this ABC with the help of object which is a t that is is the reason I was saying sqrt is a method so now currently you’re not aware about a object oriented in a python so you just consider that method and function both are the same as a defining purpose only difference is that that method is inside a class so currently we are not inside a class so we’ll call as a function okay okay so I want to make uh the program like this okay suppose I created the function which is the Squire root okay let me change the name the same like I want to create it X as a parameter and I’ll make it it it’s a square root so um answer is equal to x to the power of x to the power of 1x 2 anything which is the power of 1 by two which is nothing but a square root okay let me again clear it like a square root of 5 which is nothing but 5 to the power of 1 by 2 or we can say 5 to the power of 0.5 the same thing and you can write it here just ANS okay when I just call this function as square root and pass the values is 25 you’ll get the answer is 5.0 which is a correct answer but can I write like this can I store it in R variable yes we can store it can I write like this print um square root of 25 is um R can I make like this you’ll getting the answer is 5.0 here but here I’m getting the value is none let’s try let’s understand it here here we print it the print meaning is that the the actual work of the print is nothing but displaying the values that’s it it’s not doing any other thing it’s just display the values so when you just um uh you know call this function here is square root 25 when you just pass it here you’ll get the answer is ANS is get the answer is five and here just display it’s not doing any other thing it’s not store any values so what I want the square root square root should store some values so that it can be defined it here so we can solve this problem via written statement see the word saying everything return meaning is that returning the value to the function so inste of writing the print I will say return so I’ll return this value to the square root so then you’ll get the values as it is like this okay so return return basically can be used any other function this function when you just calling it this function when you call it I can store it somewhere else so that we can reuse it hope you understand the return statement concept okay let’s jump on Anonymous function let’s jump on Anonymous function a function without name is called as an anonymous function what is a mean Anonymous function that we are defining we are defining anonimous function with Lambda keyword with Lambda keyword okay Lambda keyword what is the um you know syntax of that let first discussed okay we are writing the Lambda Lambda and we’re passing the arguments like uh a sorry a comma B and then you uh doing some operations let’s understand it here so syntax is not much important but you should know that how we are writing so just we have to write Lambda what operation you want to perform I want to perform the operation of um a cube of any numbers yeah we can say U addition of XY Z so I have to Define it X comma y comma Z colon colon what operation you want to perform I want to perform is the 2 into x + y + z that equation I want to perform when you just run it we’ll find it out the function is created okay function is created how can we um uh you know call it this function right function is created it’s saying that function you can um defining the function without any name here there is no any name but if you want to call it you have to store somewhere I’ll store in the result variable I’m directly storing it there and with that variable I can call it result is equal to um result is equal sorry result when you just run it it will saying that a function you have to pass some parameters I’ll pass the parameter 5 comma 7 comma and 3 I’ll get the answer is 20 because this one is taking as a argument these are the parameters and these are the operations I perform it the question is if we already have a diff param diff parameterized function is available in um in this topic then why we required this Lambda why we required answer is here let’s understand the example where we can use it this kind of function um suppose you want to create one function which is very small and you want to call it again and again why you required the separate function if you function is very small you can just Define it here call it the same time okay how can we use it let’s define one variable which store many values okay yeah this values I want to uh take only the um you know even numbers so many method is there there is one a famous function in build function is there which is the filter function I can directly use it filter function okay filter function so when you just uh put your cursor in between and type shift tab you’ll find it out suggestions so first you have to define the function and what you want to iterate it I want to iterate a and function you have to Define it okay let’s define the function name is a uh even this is the function name even and a I want to pass it so even you have to Define it right even let me Define separately def even and I’ll pass as a any parameters because whatever Val U value you have the whatever list you have iteratively one by one it will be pass and giving the answer so if x is a modulo of 2 is equal to equal to Z that means it’s a even number and should be written written as a x okay when I just run it oh so compressed so I’ll just use the list and I’ll get the answer I’ll got only a even number from this section so there is a 13 and 21 is a odd number but here I got only even number with the use of filter function but you can see here this function is very small so you define separately and it took a three line more space and obviously the calling from the different function from the different places obviously is a memory consuming so what I can do I can use the Lambda keyword so I can use the same thing filter I’ll pass the values here Lambda X and then condition I’ll apply it X modul of 2 is equal to equal to 0 and what you want to pass I want to pass a just pass it a that’s it and make it list and you’ll get the answer is yes same thing so here I defined with the five line of code here I Define the one line of so both are doing the same thing only difference is that with the help of Lambda keyword I can reduce my number of cod so that I can save my memory and space because this is your learning phase start now you are just learning but when you go in the project perspective so we have to take care about the optimization as well your project should not be take much time your project should not be take much memory so Lambda is one of the good solution so one thing the definitely you are uh in your mind uh in case if your uh number of code in a function which very big right like uh the function is very complicated here is just three line if you have a five line six line that is okay if you function if your function itself have almost 20 to 50 line so in that time should we use the Lambda keyword the answer is no so Lambda keyboard is using if your function is very small and you are it iteratively calling it the time we are using you don’t need to Define it separately you in that function itself in that predefined function itself you can use the Lambda a function call itself is calling a recursion function let me also write it here a function call itself calling recursion function let’s do it in a practical way suppose I have a function uh function name is U um process okay and inside the process this normal print statement is there hello world all right so when you just call it this process function process then as expected answer is a Hello World here the process is working like this your function um work like this line number one then four again line number one two after line number two in case if I’m calling the same function again same function again the function name is process same function again so what will be happen so it will be call the function again one line number one line number two and three again one 2 3 again 1 2 3 1 2 3 1 2 3 it will be like a loop but actually it’s not a loop it’s a recursion recursion have a limit what is the limit let’s discuss it first so here you can see uh the process is stopped now means there is some limit to stop when you scroll down you’ll find it out the maximum recurs and depth ex exceeded while calling the python object so there is a limit so limit you can also find it out with the CIS module Sy CIS means system CIS do get recursion limit get recursion limit get recursion limit you’ll find it out how much limit this recursion have so every system every system in the sense uh if you’re working on a Jupiter notebook and if you working on a normal python if you’re working on a py charm if your environment is a different then recurs limit can be the different but you you can use this command to find it out the recursion limit I can also increase and decrease the recursion limit so increase the recursion limit is very simple just you have to pass set recursion limit and I’m passing it here 8,000 okay 8,000 and later when I just check that what is this recursion limit it will showing the 8,000 but the question is how can we decrease it suppose this H world is showing 3,000 times I want to check one the five times or six times so that means I’m decreasing the rec person so there is um one beautiful feature is there written statement with the help of written statement we can perform the recursion process suppose I have a number is n and uh here I pass the value is a five and every time when you call this process when you call this function I’ll make it n minus one at the same time I can also print that n as well so that I can track it how much value is there so when I just run it you can see here the 5 4 3 2 1 and and it’s going till down there is there is a limit is a 3,000 so it will be going down and run it again and again right so what I can do hit here so when you scroll down down down down it’s a 7,000 it’s going to more than 7,000 the reason behind that I increase the limit which is the 8,000 right I increase the limit that’s why it’s going till here after uh 7,000 7,000 something and is going this statement is maximum recursion depth exced while calling the python object my target is that I want to stop in after five steps so I can use it here the condition if my n become a zero that time I will return return just um uh recursion done okay the statement is is a recursion done that’s it so because you know that after the return statement any statement is written there it will never accept okay so when I just run it it will going till uh 1 only what exact what is the meaning is that it’s not acceptable after the return statement like I think I already discussed but again I’ll tell you in the short way the dev hello there is a function and if my number number is a = to 4 and B is = 8 and return is equal to a + and before return let me just use the print print A+ B and when you just call it hello you’ll get the answer is 12 and after the print statement uh my statement is there um um hello world okay this normal statement hello world after 12 is showing that hello world but in case if you use the written statement for a plus b return statement for a plus b hello world where hello world will never display the reason behind that because after the print after the written statement whatever things is there will never be execute okay if I’m writing the normal ABCD any thing so it will be never execute so that is the uh functionality of the return statement we will use this functionality in a recursion function to stop the recursion so here the recursion is STO because when the number become a zero when a number become a zero and at that time it return the recursion done and when the line number three is executed after that whatever you wrote it will never execute that is the reason it’s not going in the next one but here the question is why the recursion done is not showing right why the recursion done is not showing the reason behind that it’s a return if it’s a return so you have to display it okay uh I have to uh I think process I have to also return yeah process app to also return that time uh whatever is returning the values it will also display so that that’s why the recursion done is also showing it here one um uh famous example is there uh uh for a recursion function uh which is mostly um you know interviewer is asking this kind of question what is the factorial number okay let me just explain what is the factorial number so factorial number you can understand like this uh it’s a application of application of recursion function okay so with the with the help of recursion function we will use it so instead of write this the factorial number with the recursion function okay recursion function so we’ll use the um recursion function uh yeah I need a pen so hope you know about a factorial number I’ll give you a short way so suppose I have a factorial number of five factorial number of 5 is equal to 5 into 4 into 3 into 2 into 1 it is going till one only it’s not more than that the answer will be 120 okay 54 20 22 3 60 602 120 but we can also write like this the 5 factorial is equal to 5 into 4 factorial till 1 till one it’s not going Beyond one it not accepting the zero because if you multiply with the zero you’ll get the answer is entire zero and uh if you have a six factorial that is a five uh 6 into can I remove okay 6 into 5 factorial if you have a 7 factorial 7 into 6 factorial so we can also do like this because the 5 5 into 4 factorial the meaning is that 5 into 4 factorial is 4 into 3 into 2 into 1 so we will use this kind of uh application uh to understand the factorial number like I’ll create a function Factor name is a fact fact only okay and I need a number I’ll Define the number is n colon I’ll return the value as the N into means N means exact number the four uh yeah if if if you take the example of five factorial then 5 into factorial of four fact of 4 which is the n minus one right if I pass the values is six the 6 into factorial of five if you pass the value of 7 7 into factorial of uh 6 but again so when I just call it here the fact which is value is a five I’m expecting the number is 120 the problem is here when you just run it you calling this function again and again again and again there is no any limit to stop it so that’s why it’s not defining anything it’s not showing any values the reason I’m not printing anything I’m not displaying anything every time is returning the values so I want to put the limit so that I can get the exact number so how can you define the limit so limit we can Define like this if number become so again you can you can see here it’s maximum recursion depth X exceeded because it’s not showing the number it’s not showing any values the reason I return the statement not to print so if number become a one for that time I will return one if I return return one if you multiply with one then will stop it’s not going any other things so when I just run it get the answer is 12 okay so you can take as a input uh uh okay in put okay I and PT okay anything you can take the variable input enter the number for factorial vectorial okay so I can Define it and that should be the integer that should be the integer here I’ll pass I and PT I n PT so when I just run it it’s asking that what enter the number for factorial I’m passing the eight is here I get the factorial is the 4320 so this way we can understand the recursion function so package and module this topic is playing the very important role for uh all the uh Frameworks and advanced level up Python Programming because uh whenever uh you enter any kinds of uh any framework work any any technology like a web development or data science so many libraries so many modules are there so here we will learn that how modules and package we can make it we can build it like uh from Custom based we’ll try to make the modules and packages so first one is a module module is nothing but uh any python file which have a py extension is called as a module so you have so many python file you create but sometime we creating the Jupiter notebook file that Jupiter notebook extension is i p y and B so that is not a module so python file should be in the py extension that will consider as a module and the module can consist of function classes variable anything because that is the file inside a file so many things we can write it we can write a function we can write a class we can write a variables anything we can write it there and what is the uh package package is nothing but one uh directory we can say where consist of the multiple modules but there is one special file is called as init so that name is init it should be available there that we are calling packages so for example I have a file which is the uh a which is the file name is a. py B do py c. py so these are all a modules but make sure that there is one more file should be underscore uncore init uncore uncore py if this one is also present and it’s available in the particular folder uh suppose the folder name is okay yeah suppose the folder name is a uh for example folder name is main so main is nothing but a package which consist of the multiple modules so let’s understand in the practical way I’ll create the multiple modules and I also explain you how we can create the packages as well like this there is a package I can also create the multiple packages as well for example like this example here so open change close these are a modules even in it is also the modules that is consist of the one folder which is called as a image Right image so image is a package the likewise the image there is also one more package it’s called as sound we can also say the package but the problem is I here I mentioned that the sub packages because you can also create the init file and make the one more folder which is the game so can you say this this one is a package this one is a package also become a package but the problem is here the main folder other folder inside that folder two folder is also available we can say it’s a package uh it’s a sub package okay so in case if you calling this one is a package that’s not wrong why I’m calling here the sub packages because it’s consist up the one more packages that’s the only reason okay someone is also calling this one is a library someone is also calling this one is a library so library is nothing but is a collection of the packages so if I clarify this what exactly it meaning so module is nothing but a consist of the multiple function and classes whereas the package is the collection of the modules whereas the library is a collection of packages or packages we can also say that it’s a collection of sub packages let’s do it practical implementation of package module and library in uh uh you know in a coding way so you can open your any ideally I’m just opening the visual studio visual studio and open one particular location where you want to walk it this package module and Library concept okay I’m just opening one folder uh yeah this is the location here nothing is available okay okay I think I selected the files I have to select the folder yeah exercise now it’s done I already selected here all right let me close it unnecessary files yeah I’ll I’ll create one file python file so file name is calling. py okay so in this file I’ll try to call any other modules let me first create any modules here even the calling file is also called as a module but the variable file is not a module because the extension of calling is a py where is the extension of variable is i p y and B so that is a jupyter notebook file both are a different so only calling is a module let me create one more file which is the load module yeah we can say load file I’ll create some function def info and uh some statement here print this is load module okay simple because variable uh sorry uh module is nothing but a collection of of any function any variable any classes anything you can write anything here this is the function I can also Define one variable here a is equ Al to 55 and uh let me also Define one more function def add and pass some uh parameters r n comma M okay and uh R is equal to result is equal to n + m and I will return return R okay so there is two function with one variable let me just write it first here two different function and one variable okay so I want to call it this function with different file so calling is a file both load and calling is available in the same location I want to call the load module so how to call any module we are using the import keyword import load so when you just use the import load let’s see what will happen you can run the file here so hope you have completed the configuration if you not then uh you can just refer uh my video for uh installation of vs code in case if you’re facing any issues you can also uh you know text on a chat all right let me just remove the unnecessary things so nothing is printed here because I didn’t print anything let me also print just normal statement print um hey that’s it hey so when I just call this this function uh this um you know this load module when I just call it here you’ll get the values is here only here but I want to call the info function I want to call the add function so if you if you want to call the ADD and info function so load do info you have to write it so when I just write the load. info you’ll get the answer accordingly so first is a he because I import it and uh in load module the statement was already there here and inside the function info the statement was this is the load module so that’s why it’s sprinted I want to call the a variable as well because I Define one variable which is the 55 a as a variable and 55 is a value so load. a you can also call it but uh that value you want to print it previously the info function is printed something here is just Define the values so I can also print it and see what exactly the values so I’m expecting that the value should be 55 so yes value is a 55 we can also call it that variable as well we can also call the function with the parameter to passing the arguments so load do add and pass the uh arguments because two parameters defined it here n and M I’m passing the parameters three uh passing the argument as three and 8 so I’m expecting the answer should be 11 so yes okay so here is not printing any answer the reason behind that I return the values I can store somewhere I’m storing the ens wer answer and that answer if I want to print it print answer so you’ll get the answer accordingly that is the 11 so hope you understand the concept of module and when you go into the next topic which is a package that is a collection of module so when I just create one uh folder inside that I’ll create a multiple python file and uh one init file as well then it’s become a package so let’s create it I’ll follow this structure load I created here so let me create other two files which is play and pause and I’ll put inside the sound folder that’s become a package okay let me create one more file which is the play. py I’ll create one function name which is the info let’s create an info so that you can remember it everywhere I’ll write the function which is the info it’s not compulsory that you have to pass the same function everywhere just for remember purpose I’m just writing here print this is but the statement I’ll make it different this is play module okay and let me also create one more file uh pause. py def info I’ll make it print this is um pause module okay all right so this is the files I’ll create one folder for them the folder is sound I’ll create it the folder name is sound sound I’ll pass all the modules play load play and pause inside that function inside that folder folder name is sound but here the sound is not a package because I didn’t Define one a file which is the init so in it is nothing but a Constructor so what is a Constructor so Constructor is whatever statement you write inside the Constructor it will automatically call you don’t need to call that function even the Constructor concept will also come in objectoriented programming that time I’ll discuss very details way but here you can just understand I’ll create a Constructor the file name is init.py that I don’t need to call it it would automatically called okay so inside that I’ll create a file which is theore uncore netore dopy so let me just write it all the statement to everywhere first uh let me just write it okay so so first in a Constructor let me write something so the statement is this is um sound package simple this is sound package and in a load I already defined so many functions pause let me just Define a def info the state m is this is okay pause module that’s it and play is already there is a play module so now I can say the package is considered as a uh so sorry sound is a considered as a package so now I want to call the info function which is available in a sound package because the sound is a completely a package let me also delete it here because it’s already available inside okay play uh load play and pause so yeah so sound is a package so let me make as a comment all right okay so if I want to call the info function which is available in the sound so you have to first call the sound okay you have to call the sound so when you just call the sound so let’s see what will happen so answer is showing that this is sound package so how it’s happened because I didn’t call anything I just import the sound but this Constructor is automatically called which is the in it so inside the init the statement is this is the sound package so that is the reason the first statement is this is sound package okay so again that info function is available in a pause module for example let’s let’s take it a pause module I want to call the info function which is there in the pause module so I have to go inside pause okay pause so you can pass as a reference as the uh a you can Define any variable so later a do info so when you just call a do info which is nothing but a sound. pa.info so here you’ll get answer which is this is a pause module there is also one way uh another way to uh call any function from sound import pause because the previously you are entered the sound and then enter the pause so here from the sound you enter only a pause so this one is a better way to call any modules any function okay so I’ll just directly pass it here pause doino that’s it you’ll get the same answer so in a real life whenever you importing any uh any packages any libraries like pandas numai anything so sometime we are using the from sometime using directly import so now you understand why I’m using a from why I’m using the import directly okay so now here the sound is consider uh working as a package so I can make sound as a sub package as well so you can create one more folder which is the image let me create it and later I’ll show the hierarchy as well so by the way this underscore Pi cache it’s just generating the cach that what function you called it so here you can see I called the pause I called the init so that is the reason it’s generated so previously you can also see what I called I called the pause and in it so that packages are generating here is also the package I call the load so that is the cpython so you don’t need to care about that it automatically generating so let me also create one more folder which name is image okay that folder name image image so inside that image I’ll create a three different file which is the open change and close with in it let’s create it from here here it will be quite faster first I have to create the Constructor okay and it then I’ll also create the uh open. py then I also create change. py then also create I think close is there open change and close py okay three files I generated here so sound uh sound is a package now here image is also considered as a package because I created The Constructor I put inside multiple module as well so I’ll put this packages this image and sound I’ll try to make it as a sub package with game as a main package okay so I didn’t write any function there but the same thing you can also follow for image as well so game here consider as a main package if I’ll pass the image inside a game let me just drag and drop control C cut I’ll pass inside image okay I’ll replace it the same thing and make sure that if you have the image and sound as a package if you want to make game as a uh library or a main package you have to create one more file which is the init then it will be considered as a package or Library underscore init.py make sure that double underscore in the both side so now game game is a library image and sound is package or we can say game is a package image and sound as a sub packages so you can say anything let’s back to our calling function yeah yeah calling modules where we are calling the different different uh uh functions so if I’m writing the same statement from sound import pause so do you think that it will be work absolutely not the reason behind that because previously the sound is a aable sound folder is available in the same location where the calling function was available yeah calling uh file was available so when I just run it here it will showing that the no module name sound reason previously sound was the same location now sound is available in the game location but if you’re using the game Dot Game dot sound because it’s available inside a game so it will work right it will work so let me also write something in uh in it of game currently game Constructor don’t have any kind of statement that is the reason is not printed here let me just write some statement in a game Constructor in init.py so the statement is this is game Library okay game library now so when I just call this again function calling function so the statement is also here this is game library because it’s available inside uh um inside a game library that this Constructor in Constructor is there in the game library that is the reason is printing here now uh this game library is available in the same location where this calling Fun calling file is available imagine that if the game libraryies is available in the different location if you want to call it again so it’s showing the error right so in that situation we have to find it out one a global place where I can put my library and I can access anywhere in my laptop so let me just change the place of the game Library So currently is here I’ll just copy cut not a copy directly cut it here and let me just put it outside because here the calling file there is no any game Library so when you just run it it will showing the error no module name game so how exactly this working because uh you know whenever you importing any inbuilt library that is pandas numai mat plotti anything in that situation uh this library is available in the global location so that we can access it so let’s take the example of fondas and how exactly is working So currently yeah so currently uh I have a many libraries so n pandas M plotly let me just open first the command prompt command prompt here okay so I am using the Anaconda prompt so I’ll just open the Anaconda prompt here so I already have a pandas but still I’ll just write a pip install pandas okay okay so it will showing the statement is that uh the pandas is already installed and it’s also showing the statement um you know the location where exactly the install C user your um you know PC name and anakonda 3 lip and side packages so the same thing here there is one um library is in build Library which is a CIS CIS is a system so let me just open the python here directly sorry here anywhere you can open it I can write it here okay so import CIS system sis. paath so it will showing you the path where exactly all the libraries and all the python packages are available so this is showing the complete list let me just open it one by one for each in. paath 1 2 3 4 print each Okay so that will showing the one by one so you can go to any location so main location is this one lib lib is Library let me copy it and open your uh Windows Explorer File Explorer and paste it there in the URL see user your PC name Anaconda 3 and lip so it showing the location here I want to see that where exactly the pandas is available you can see it here the pandas is available C user PC name anakonda 3 lip and site packages so here definitely site packages one folder is available you can just search it site packages yeah site packages and you can also search the where exactly the pandas pandas yes here is the pandas so you can find it out other libraries like a matplot li numai numai yes you can see the numai and matplot Le if you searching you’ll also find it out somewhere M plot lab okay so exactly if you are importing the pandas numai mat plot Li that all the code is coming from in this location if you just checking the pandas so inside a pandas sometime we are using a pandas do data frame so where exactly the data Frame data frame is a code so go to the pandas you’ll find it out somewhere go to the pandas and uh here is the API here you can find it out like so many things is available you can easily find it out there right so in the core I think uh data frame is available yeah you can see the reshape is available uh interchange is available indexes is available group by we are using D types we are using see inside that the lots of code is available so we are just using that particular code right so with the help and here here pandas is nothing but a library so inside a pandas so many packs of packages and packages is there with in it you can see with in it when you go to the inside of core you’ll also find it out in it somewhere okay in it in it is there see here is the init is there now so these packages libraries you can find it out where exactly is available with the help of CIS uh packages CIS Library so now the my target is that keep uh the game library is available in the local location I want to change it I don’t want in that uh you know local location so that if I’m access and we change the location so it will be showing that no module name a game so what we can do I can put this game folder in any of this location any of this location lib side packages anything I’ll directly put the lib let me go there yeah so Li so I’ll directly pass it here hope the game yeah it’s not available I’ll just put paste it here game paste it here so in your system anywhere in in in a system when you just run it it will not get any kinds of error okay still showing the error I think I have to refresh it kind of uh okay uh you can just access it uh let me just run it again it should not be it should be accessible okay let me just write it here import game okay it’s so okay let me just pass it in the side packages here is not working then I’ll just pass in the side packages side packages a lips or lips yeah okay let me just directly paste it here team okay go inside a lip and game okay let me just run it again here import G yeah this is the game Library so you can access it there is uh and the current location is my RT and my RT is the PC location and here I’m trying to access the game it’s accessible so here is not accessing why there is some some issues there is some issues let me just try to use it import game this normal import game so hope it should be available so I don’t know why it’s showing this error okay so there is some issues so better I can go in the particular location uh let me exit it so where exactly I’m working I can also search it here uh the location is the location is uh D recurrent learning python exercise okay I can just go there D CD recurrent learning Python and exercise okay so in this location I’m trying to just access the game libraries is it accessible or not so I’m just uh I think there is some issues in uh you know in in versions so I think I’m just using a different version here and different version there so that is the that is the problem because I just copy the path from a command prompt here so let me just import it here it will definitely work yeah here is working so if I’m just accessing game from game import sound dot play Sorry dot here I can’t use it uh but here I can definitely use it do sound import play okay so this is the sound packages that is also working here the play play do info yeah this is the play module is perfectly working fine here so if you put your libraries inside U uh the global location so you can access anywhere in your PC so p is working as a package manager which is responsible to install any kinds of packages or libraries so if you’re using the python more than uh 3.4 version so that means PP is already there you have to just use it so if you want to install a package like pandas so you can write it you can write it like pip install pandas that’s it so you have to write it pip install whatever libraries if you want to install just write it down so pip uh will install that particular libraries in global location in your system so there is one more topic is a name attribute I think you saw this name attribute in a Python programming language is many places so let’s understand it how we can use this name attribute so suppose if you have vs code okay if you have a vs code and uh yeah and I have one file which is a um load file load. py so the variable is 55 and DEP is equal to info and uh pass the statement is this is this is uh load module okay and one more function is available def add and pass to parameter a comma B simple and just um you know perform some operation result is equal to a + b and later return the values return the result okay now it’s done but I want if if I if my target is to create the complete a module which will be the load module but I want to test it that whatever function I wrote it that is perfectly fine or not okay so here uh I just want to um you know test it this add function is properly running or not so what I’ll do I’ll just call the function 5 comma 8 and when I run it so hopefully we will not get any answer because I return the values but when I just print the statement like uh print the statement directly so we will get the answer is 1 so which um I was expecting 13 now the answer is also 13 everything is perfect but here I just want to call the load module let me just call it import load okay and when you just import load let’s see what will happen so import load I just load the I just uh you know load the load module that name is the same I just imported the load module but here I was not expecting that answer should be the 13 because I didn’t call the add function here I didn’t call the add function let me just call the add function uh print load do add I’ll pass the values is 5 comma 12 so I’m expecting the answer is 17 so here I got the 17 but the same time I also got the answer is 13 as well which is wrong not wrong but uh I have to see that where exactly this 13 so 13 is basically I just printed here in the load module just for experimental purpose so if you doing the experiment so don’t direct don’t directly write it the experimental uh print statement so what will happen ke um if you write anything and import it somewhere so definitely that uh statement will uh call it so I can use it name attribute if underscore uncore name underscore uncore is equal to is equal to mean what is the meaning of main so main is nothing but main is nothing but the own file okay main is nothing but the own file so when I just run it here definitely you will get the answer is 13 okay I here you’ll get the answer is 13 why the 13 because I just passed the values is five and 8 so here I pass the condition if my name attribute is a main main is same file that time it will be called this function add but so what will happen when you just importing this file import load that time your name attribute is not a mean your name attribute is become a load okay your name attribute is become a load so how you can you can see that uh so here here when I just print it you will not get the answer is 13 you’ll get the answer is only 17 so let me just verify it ke uh that that time the name attribute is a main and uh uh when you just call the uh when you just import the load module that time is become the file name so print uncore uncore name okay I’m just writing here name attribute what is exactly the name attribute here so definitely here I didn’t pass any kinds of condition so that if you just use it in any other module in a calling Fun calling file so this one will definitely print so let me first print it here so when I just print it so here you’ll get the answer is the name attribute which is a mean all right the name attribute which is a main here I got the answer is mean but at the same time when I just calling here and uh run it so definitely this line will execute line number 10 will execute and when I just call it you will get the answer is load and what was the condition the condition was that the name underscore uncore name is equal toore main that means in the within a file it will be called but if you import it somewhere that will not call because the name attribute become the file name okay that condition I didn’t pass it here so hope you understand the entire uh package and module concept if you face any issues anywhere if you just importing something package Library anything so you can uh you know put the comment below we’ll definitely I I’ll solve your problem exception handling is a unexpected event is exactly an unexpected event which occurs the execution which occurs during the execution of the program that disturb the normal flow of the instruction so there is a lots of keyword is available to handle this kind of exception so the keyword is a try except else and finally so there is a four main keyword to handle the exception so let’s say for example uh this is the real life example how exception is occurred suppose if you’re running the car and car is suddenly stopped that can be any unexpected event maybe your engine failure maybe the petrol is finished can be anything but suppose if the petrol is finished the fuel indicator is giving the answer you’re giving the uh instruction that yes your petrol is finished find it out some nearby petrol pump so the fuel indicator is not solving the problem but is giving the instruction that this is the exact instruction you can handle via petrol so this is one of the example so let’s try to understand in the practical way like any unexpected event is occur to how we can handle it so open the Jupiter notebook I’ll just create a new file to better exception handling oh that file is not available yes the file is not there let me just create it exception handling exception handling okay suppose I have a very simple program a is equal to uh yeah a is equal to I’ll take a input okay as a integer enter the first number just normal program I’m just writing it later I’ll just create some issues and try to solve this B is equal to ENT andp put enter the second number okay and R is equal to a + b simple not a plus b a divided by B and I will print it R just normal answer yeah we can say I can also write it the proper statement answer is okay so asking the first uh first number that is the four I’m just passing it here second number is a three answer is 1.333 okay so it’s very normal program so you’re not expecting that you’ll not get uh you not get any kinds of error but let me run it program and 5 divide by 0 so that time it’s unexpected event is occurred so I was not expecting that I’ll get error right because it ask the question enter the first number I pass a five enter the second number I pass a zero zero is also the integer but I got the answer is zero division error so different different error is exist we’ll discuss in uh you know in pptq how many types of error is there but here the error is occurred so how can I handle it because 5/ by 0 that invalid it’s kind of invalid so if you using uh the calculator any calculator your mobile calculator you can also check it 5 / by 0 Let’s see what will be the answer the answer is showing that Infinity so if you check the 5 ID by 0 in your mobile maybe you’ll get a different answer maybe it will showing the invalid all right so different different statement is showing so instead of showing that red color error if I’m just showing the infinity that will be better so that is handle the error it’s not solving the error right so here uh so 5id by 0 the value is not exist so I will try to handle it if I’ll face this kind of issues how we can handle it so I’ll just use a try try means I’ll just normally try the normal flow of the program so normal flow of the program I’ll right okay so in case any exception occurred except except exception accept exception uh the time I can I can write it here print Infinity okay I can I can write it anything so if I pass 6 IDE 0 you’ll get the answer is infinity whatever you write it here you’ll get the answer accordingly so it’s not solve the error because 6 IDE by 0 the number is not exist but I’m just handle this kind of error if this kind of error is exist how can we handle it so in case the error is like here is saying that enter the first number by mistake I pass the value is uh T which is the string and here you’ll get a different error but instead of showing the error is showing the infinity that is like not sensible right so different different types of error is exist so here the common standard exception is available which is the zero division error which I just discussed name error it occur when the N name is not found and indentation error like if you conditional statement of for you are using the time is occurred and input output error is there eoff error is there so kind of some common standard error is available and uh we can handle it with their own name instead of writing The Only Exception so exception is just we can see the main class so where the different difference of classes is available zero division name error and indentation so let’s understand it in a deeper way in Practical implementation so here I use the try I use the accept there is a five keyword let me also write it here four keyword four main keyword try except try except and uh finally and what else yeah else else so these are the four main keyword is available in exception handling so try and accept we already used uh let me go first deeper here because the statement was that if I’m passing a t the still is getting the answer is infinity so in that situation how to handle it let me copy paste there in that situation instead of passing the exception I will pass it the uh exact error so in case if I uh face the issues okay you know so if I’m just pass it here okay T so I’ll get a value error so here I’m not getting the answer so because uh you know here I directly use the exception so when I just run it here separately here pass the R so it will you will get a value error so you can copy and paste instead of passing the exception I will just pass the value error so it will handle the one value error so I’ll write it here please enter any numeric number okay please enter any numeric number number when I just run it here and if someone is passing the any uh statement like T so it’s throwing the statement please enter any numeric number because I passed the any statement right so uh but uh if you’ll get any um zero division error then 5/ by 0 then it will showing the zero division error so again you can Define it zero division error separately okay accept zero division error so if you’ll face any kinds of um you know zero division issues so it will showing the answer is please enter any nonzero values okay so this one is perfect but here is very common question ke uh in the starting phase how you know that what kind of error will occurred because it’s a unexpected event right so in unexpected event how can we find it out the solution is that so whatever you know value error I know a zero division error I know so I can write it but your save side you can also Define it here except exception if zero division will not catch zero uh value error will not catch then exception will definitely catch because it’s a main class and inside that other classes available like a zero Division and value error so so here I’ll just write it down this normal statement invalid okay in case if value error zero division is not captured then exception will definitely captured so one thing is also here uh let me just pass okay you’ll get this kind of answer so one thing you can uh Define it here ke let me just copy the first one okay we can also pass the references as well so here instead of passing the infinity I’ll pass the invalid okay so invalid so if if someone is passing the W any U string values in an integer so definitely it will not convert it so it’s showing the invalid I can also pass the references as e and at the same time I can also Define it e so you’ll get the uh answer is T if I pass so you will get the answer is invalid even let me just Define it here uh colon so that it will be separate okay if someone is passing so it’s showing that invalid literal for integer with a Bas 10 so that means you have to pass any best 10 number but if I’m just passing any zero division issues okay so it’s showing that the invalid and uh the E is representing that division by zero so that error is also we can check it with passing the references um here is not compulsory to pass e you can pass any variable there okay try and accept we understood uh how we can use the uh else and finally block so let me also use it here okay all right so if you’re using U you know the accept after accept we can also use the else block try accept or else else okay so here I’m just writing the normal statement is um uh uh program finished program yeah program done just normal statement so what will happen here the uh program completely done yeah successfully completed successfully program successfully done because when I’m just passing any statement like 2 divide by 6 uh definitely we’ll get the answer is 0.333 and program successfully done but in case if I’ll get any kinds of error any unexpected event is occurred like w if I pass it so it’s showing that invalid and that time the program is not successfully done okay so we can apply the looping concept here uh like the program is running it again and again until we are not done so like if I’m just pass it here the while loop while true so it will be running again again and again but when the program is done that time it will be break so the else is also playing the important role in some situation uh where if everything is if not getting any kinds of error so that time else we can use it so here when I just pass W it will get the error at the same time it’s showing that invalid okay um it’s showing the invalid and again when I just pass the first number properly the two divide by 0 so it also giving the invalid division by zero but when I just pass the proper number so it’s showing that program successfully done and uh the while block is finished this way is working and finally block is kind of uh it doesn’t matter exception is there or exception is not there the finally block is definitely called okay so else is kind of if you not have any exception that time it will be run but the finally block no matter what is happening in the program but finally block will definitely execute so I will choose this one this program because it looks good because zero division is separately and value error is separately okay yeah so finally is Shing that um U like kind of um if I’m making any any any games okay if I’m making any small games so in that situation uh try accept is working very well and finally is playing the very important role create a very small game to generate a random number and we have to guess it so where I will Implement all the keywords of exception handling like a try accept else finally I will use it everything let me first create one random number so we can import import random and uh random do Rand range so we can provide the range from where to where you want to generate the random number I want to generate 1 to 100 so it will generate the random number in between so whenever you run it you’ll getting always different different random number so uh random number we can say just I I’ll I’ll pass it num that’s it okay so my target is that when I just uh when I just pass passing the input if the random number is match then it will showing the statement is that okay I guess the number but if it’s not match then it’s less than and greater than it will giveing the answer so user I will take it as a integer input please guess the number okay please guess the number and if the user that uh you know the guessing the number is greater than num then what I have to say number is greater than than uh guessing number you know your number is a greater than guessing number your number is greater than guessing number yeah random number whatever you can write anything random number okay so and L if we can also apply it if user is less than num the time I can write it here your number is less than random number okay random number okay all right so when I just run it it will asking the question is that please guess the number I’m guessing the number is a five it will saying that your number is less than random number right so that means whatever number I have to guess it the next time make sure that it should be more than five but when I just when you just run it here again so your random number will generate again right so we don’t know previously maybe the random number was uh 25 but now the random number is two so make sure that your random number should not generate multiple times okay again your random number is um less than your your number is less than random number so I will just apply the true uh while loop I’ll I’ll apply it and make sure that it will be running the multiple times while I’ll make it true okay I will make it true so it will asking the question that please guess the number and here the random number will be the static it will not generate every time but your while should be the uh you know your your while loop should be stopped when the number is match with your user is match with user is match with number so what I have to do I have to uh directly write it here um we can we can directly write it the if condition everywhere it’s very simple program you can modify it according to you if user is equal to equal to num the time I have to write it here uh okay we can write it yeah you you got the number you got the random number okay that’s it when the number is match so let me run it again please give guess the number the number I’m guessing that seven saying that your number is less than random number okay uh so that means I have to guess it more than 7 I’m guessing the 50 again is saying that your number is less than random number that means is more than 50 I’m guessing the 80 saying that your number is less than random number I’m guessing the 90 your number is greater than RDA number that means this number exactly in between the 80 and 90 right I’m just guessing the 85 so your number is greater than the random number that means it’s the 80 to 85 I’m guessing the 82 your number is less than that that means 83 can be or 84 only two only two option is there 82 or 83 or 84 is less than that that means the answer is 84 yeah you got the random number I got the random number but again it’s not stopped because I didn’t break it I have to break it here okay I have to break it here let me uh let me just terminate the program because I didn’t use the break condition here break keyword here let me just use it break when you got the number so in this small game what we can what we can uh you know add new things or new features the first thing is that in case if I’m running it and someone is passing the T I got the error so in error we can’t afford it like any kinds of error right so what we can do we can directly uh apply try okay we can apply try in everywhere and accept block because exception handling is very common for any kinds of program so whenever you building any applications so we don’t know what kind of exception will come we can’t show the red color error we have to tell them yes it it’s kind of invalid you have to write it uh you know new things uh the proper statement proper number so whatever is mentioned there in a program I’m just writing there the exception okay and just normal statement is invalid invalid right let me also put the colon here because this not looks good it’s like it’s mixing here so everywhere let me put colon colon colon okay great so try we use it except we use it and uh so if you pass it t that means it not make sense like when I just run it it passing the T so it’s invalid right uh so if you got the number exactly the random number so I want to know that how many attempts I did so that things like if I pass T that means by mistake I just pass the T it’s invalid that should not be countable so what I can do it here let me just break it uh what I can do it here the else I can use it if not exception the time I have to just Define one count here the count is equal to zero so whenever your program is run your try is run so that time the count is increased count is equal to count + one okay every time you count is increased and uh when you got the exact number uh when you got ex here I have to do it because if suppose in the first attempt you got the number so you’ll get the answer is yeah I you got the number but uh what is the attempt so attempt will be the one because zero attempt is not possible right so uh yeah you got the number after count this uh string formatting I’m just use it here so I got it like after how many attempts I got the number okay so this number should increase here let me just run it when I just pass the number is uh 50 okay your number is less than random number that means it should be higher I’m passing the 70 less than that then let me pass the 80 is less than pass the 90 is greater than okay so maybe the number is quite similar no it cannot be is it greater than that uh okay I have to go back lesson number 82 number is lesser 83 is the final answer so yeah you got the random number after seven attempt okay so I have to just make it you know here else I use it except I use it try I use it I want to use the finally block so what finally block does so finally block is basically uh your exception is occurred not occurred it doesn’t matter but the finally block will execute is a kind of if if you um if you open any files exception is occurred or not occurred make sure that the file the program is finished the file should be closed because the next time file will open so here is a game so it kind of every steps there is some checkpoints so I can just write it here just normal checkpoint that means one person will do second person will do the kind of I can make it just checkpoint like one person is finished so the checkpoint will occur doesn’t matter the exception is occurred or not right if the triy block will run finally will run accept will run finally will run else will run finally will so let me just run it when I guessing the number I’m guessing the number is a 50 one checkpoint is done right so it will Shing that yes the first one and second one is totally the separate so guess the second number it’s less than that I can make it 90 greater than 80 less than oh it’s kind of the random number is generating the inbit 85 let me just run it okay yeah you got the random number after four attempt right so hope you understand here where we can use the try in case if you have any kinds of issues you can see here suppose if you run it the program and uh you P guess the number less than that but by mistake you pass the number is uh some string so it will showing that invalid the checkpoint will still run but it will not increase the count this will will considered as attempt because it comes under the else where is this exception which is comes here will not consider as attempt so the next time when I just suppose if you got guess the number so this part will not be considered this part will not be considered hope you understand let me just finish this game okay less than that that means it’s more than that 90 okay it’s kind of every time time is generating the number is in between uh okay five attempt you can see here one attempt okay two attempt three attempt four attempt and here the five attempt this invalid is not considered here hope you understand this try except else and finally block last topic of exception handling is uh nested exception handling nested exception handling okay let me just use the same program which I discussed in the last to last session the same thing I will just use it here all right so here the normal program is like division of two number if the number when someone is passing that any string instead of any number then it’s showing the error and that time is handled by value error but in case if denominator someone is passing the zero so that time the any value cannot be divided by zero so that time the values is passing as a please enter any non-zero values so what I can do I can make it as a Ned exception handling as well because the last one I just make it um exception invalid in case both the um in standard exception Handler is not ex uh you know considered that time the exception will considered I can also make it let me just remove it this one here it’s not required I can also make it the separately the tri block everything I’ll just put inside a tri block and then I can apply it here the exception except exception so it’s become a nested exception handling like try inside a try you are just using likewise the nested for Loop nested conditional statement nested condition is means if inside a if nested Loop is Loop inside a loop nested exception handling is try we can say exception inside exception here I also use the same thing here so in case if this kind of exception is not handled that time the main exception class will accept yeah considered me just write it here the error okay so let me just pass it here suppose any value error if I’m passing so that time please enter any uh numeric values so this part is handled and I just run it 5 / by 0 that time this value is handled but in case if you passing any those kind of values which is not acceptable in value error and zero division error that time this exception will considered likewise if I’m not passing anything that is also so the value error how I explain you this one okay suppose if I’m just removing this part only zero division error is um you know available inside a try inside a try and I just pass it t here so that time is showing the values is one error because zero division error is not considered the value error exception so this entire block is become the error so which is handled by this exception class so hope you understand this exception inside exception sometimes like if you have a bigger program like any application if you are making it this Ned exception handling is really required so before going to the file handling let’s understand that how many types of files is which is available in our computer Industries so many format is there to handle the uh data with first one is it txt and uh PDF we have PDF we have CSV we have do Json we have XEL we have do pickle we have okay so these are a format which is available so this format to store the data so data can be anything so data can be stored in the different different format so if I’m storing one data which is like uh uh the college Rel College data where the student marks is there student subject is there student name gender age everything is available I’m storing the data so we can decide the particular format so if I decided the format is a csb so that csb is considered as a file CSV file right so at the end we are generating one file that can be any file like txt PD fcsb anything so these files we can perform some different different operations so what is operation Operation can be I want to open the files I want to close the file I want to delete the file okay I want to delete the file I want to you know update some file I want to newly write some file so these are operations so I created one complete Jupiter notebook so where you don’t need to re you don’t need to listen the entire video you can also refer that Jupiter notebook you’ll understand easily how the file handling is working so here the first one I just mentioned there first we’ll start with the tech uh text file so how we can write it update it read it everything okay to deal with this kind of operations we required some functions so these are a few important function is available the first one is open and close so if you want to perform any kind of operations so first you have to open some file okay and after that you can perform some operations and then make sure that you have to close that file as well so this this function is also very important so here I didn’t write the description what is the mean of read read is just reading the file read line means line by line reading the file okay write is writing the files right line space one by one writing the files but see and tell is something different so that is the reason I mentioned the description as well seek means defining the exact position and uh tell is find the position which is tells us ke where exactly the uh cursor is available don’t worry we’ll discuss in the practical way so one thing is also required which is a mode okay the mode mode is nothing but ke like what operation you want to perform I want to perform writing operation read operation appending op operation rri Operation sorry yeah rri operation or write in binary operation so here is available so I have one file which um my txt txt my text.txt I am try to write something okay so let me just do it one by one so first I will just create one files I don’t have any files there go back here you can see I I don’t have any kinds of txt file okay I don’t have any txt file so I will just create it one files so here this is the first operation open it will just open the particular file make sure that your mode should be w w means writing the files and then line by line I’m just writing the file this is my first program this is my second program I’m writing there so make sure that you have to close it otherwise it will be impact to the another files if you opening in a new section so yes I close it that means file is properly written sometimes we are not closing the files so what happened ke if you write the program uh if you apply the uh writing some uh you know lines in a text but you forget to close it so that time the file exactly not writing in the text file okay so now file is a properly written so we can also check that ke properly written or not my txt my text.txt so yes file is a properly written there so this is the first way to write the files we have to separately open it and then uh write something and then close it so one more option is also available which is a with open we have to use a with open it and if you using the withth open you don’t need to close it the reason because you’re writing entire section inside the block if you’re coming out the block that means file is already closed so this is also one of the good practice so if you’re using the with open that time you don’t need to close anything okay so I’ll also do it like let me just use it my text. TX my text one.txt let me just create uh new files it will be better so that you can easily compare it let me run it here you can also check it my text one txt so yes this is my first program this is my second program that is properly written here okay so yes this way we can write something but if you already written something I want to update it like I want to add some values which is the line number third line number four so first make sure that you have to open that file mode is very very important so here I just use a w mode meaning is that I’m writing something a is I’m appending something okay when I just use the uh third line and fourth line and if you close it and after that you can see you will find it out ke third line and fourth line is also available but in case if you’re just passing the W instead of a so what will be happen your previous statement will delete it and third and fourth will create so don’t apply the w every time w means writing means if you already exit it will be overwrite again so if you want to just up uh update something so you have to write a so I just use the my txt do my text.txt okay then I’ll check my text.txt yes this is the third line this is the fourth line actually directly starting where the um you know the cursor ended previously it’s ended here that’s why it started here and I use the slash n so that’s why it’s showing the slash in next time so now we we understand the read read line WR right line everything uh okay read uh right we we did that so if I want to use the reading okay so make sure that I should have some files okay uh so python. txt I create I have one files is a big file so you can also find it out files on um GitHub okay before going to the python. txt let’s also read something okay you can also read the my my text.txt as well let me show you how we can read it so with Way open you can also use it with open I’m just opening the file which name is my txt do my text.txt my my text.txt and mode is equal to it’s r r for reading okay and then uh uh we have to define the Define the you know as a variable as F3 I’m just defining it okay F uh F50 I’m just defining maybe it will be impact the next one because 3 four I just use it there so I’m just use the F50 F50 dot read line and then read line that’s it so it will be uh store somewhere let me store in the where one okay so we can also check that is the first line which will be printed where one so this is my first program so whatever I write it I can also read it as well but this is very small line of program so uh I can’t explain you you know much here so that’s why I I created I have one files which is the python. txt yeah this one python. txt this is the Big File okay so let’s let’s understand it how we can read it line by line and uh some particular uh specific location if I want to select it I want to read it then how we can do that for example I want to read only the python support modules python support modules and packages which encourage program modularity like this L this line I want to read it how we can read that kind of line uh you know to skipping other things and directly read this one so first of all you have to read first of all you have to open that file if you’re using the read meaning is that it will read entire things and I’m just closing it here and I just use the print I use the print the reason I want to display everything so now everything is a display but in case I want to display a few things only right so here I store let me store in the variable T why I’m storing variable T because I want to perform some operation there okay uh because everything is available in the string format you can also check the data type so what is the type of T which is the string right so like I want to know that how many times pythons is available in the entire book yeah we can say entire text okay so let me just check it so it’s available at the two times so what is the position of that that uh that pythons the first position which is the 2002 so what is the second position of the pythons so you can directly write here 12 23 means the next position so actually why I’m writing here the 213 because it will be start from 213th position so what will be the next so 66th position have a pythons okay so there is a two places pythons is available you can easily find it out here string with string operation okay so here we have a a method is a seek method seek method is exactly we can just Define the positions from where you want to start it like I I I decided that I want to start some particular position which is the python is interpreted objectoriented high level programming language suppose I want to start from there so how we can start it like we our cursor is always starting from here but I want to start here so seek will Define the position in a python yeah we can say here in this location and then it will printed the uh that particular line so I I Define the position which is the 216 okay let me also check that what exactly U showing that particular line so when I just do that 1216 the current position so which is tells us so tell it will tell you ke look what is the exact position and seek is defining the position set the position so when I just set the position when I just set the position and uh from there it will be starting so python designed the philosophy EMP prise code readability with its notable use of significant indentation so this is the line where is that okay yeah python design I want to read this one because I use that what exactly the position of um uh you know the first pythons so that was starting from it will tells us this one 212 but uh it will tell you the entire 212 entire pythons not the P I want to know that the position of P this P so that is the reason I just use the plus 4 and uh use it here 22 + 4 so likewise you can also check it and you know in case if you’re not write writing the plus 4 so what will be what will happen so it will showing that g dot and then values so you can just count it 1 2 three four after four position it should start then I’ll make it plus four that is the reason I did that okay so you can print it everything here so because I just use the C is equal to 216 that is the reason is printing after that okay that is the reason is printing after that so hope you understand how the text operation is working in Python programming language to handle the operating system operations in your computer so there is a module is available in Python which is the Os Os module so in OS module the lots of method is available to perform the different different operations so we can find it out this kind in any module I want to know that how many method is available you can use a DI function Dr OS so these are the supporting attributes so don’t check this one and here the ABC aert access CHD close chmod lots of method is available so every method have their own work so here in this video we will discuss about the few method and we perform some operations like let me just do the first one the OS do get CWD so get CWD will tell you like what is the current location your Jupiter notebook is working in some particular location what is that location there so the D drive recurrent learning and python so in case if I want to change the location how we can change it so this is the location here D drive okay D drive recurrent learning suppose I want to change it I want to enter in the directly in a python okay I want to enter not only yeah Python and exercise I want to enter in that location okay recurrent learning python exercise this location I want to enter it okay it’s already there in the python let me change any any other location back not in Python video I want to enter and Python tutorial so there is no any files is available I want to enter in that location so copy it that path go there and uh we can use it os. C HD change directory so you can provide the path here so when I just use the change directory your path will change and next time when you just check it os. getet CWD so you will get it the current location which is the recurrent learning video on python tutorials and some operation we can also perform is like um I want to make some directory I want to make some uh you know some folders directory is a folder so how we can create it uh current location is this this in the sense here nothing in no any folder is available I want to create any folder how we can create it mkd sorry OS do mkd and pass the values you can you can write anything uh I’m just writing temp directory temp di so when you just run it so temp directory will generate yeah temp directory is generated so with the help of os module you can perform some operation with your computer so that python is providing that kind of facilities other programming language is also there just I’m telling you the python have the OS moduel and uh in case if you have the multiple directory for example my current location my current directory is this and I want to create the multiple directory inside a directory like path is equal to I want to create um you know new dir inside the new di I want to create one more directory is a okay analysis okay inside analysis and then um uh we can say Titanic okay this folder I want to create it but if you’re using the. M KD let’s see it will work or not so os. mkdir path let’s see it will showing throw the error the system cannot specify the path because your current directory is this and inside that you want to create the multiple directories so which is not possible with a mkdir so different method is available which is a Mech DS Mech directories so when you just using the me directories so you can create a folder inside a folder inside a folder like that so let me show you yeah new di inside that analysis inside that Titanic so this way we can create it okay so in case I don’t want any directory suppose I don’t want a temp directory still there so OS Dot .rm and provide the path which is the temp Dr so that directory will delete RM di sorry rmd so that directory will delete as well so this kind of option is also available to you can also delete it okay there is one only one directory which is the new d new dir there is no any temp di because I deleted I want to change this name I don’t want you know this new IR I want to rename it so OS dot rename it okay so rename it so what is the file name new di I want to change it as a new only okay rename n a m e rename sorry so new di I just change it is a new so change it here so that kind of option is available so let me just do the last two method and after that I’ll I’ll show you the list you can easily explore it suppose my current directory uh my current directory is this current di let me just do it o.get CWD okay this is my current Di okay I want to perform some operation uh so like uh I want to add it like new Di and with all the locations right so how we can do it like inside a DI there is analysis folder is available so we can also join the path as well so OS do os. paath do join so my current directory current Di with whatever path you want to join it suppose I want to join with a new so it will be joined like this okay so you can perform the analysis and based on that so. path. jooin you can joining with the two One Directory with any other directory in case I want to create One Directory which name is a new which is already exist let me R OS do mkd which name is new let’s see what will happen so it will throw the error and saying that cannot create a file when that file is already exist so there is a condition we can also apply it okay if os. paath do exist and you can write it that new in case if new is exist the time in case if new a exist if os. path. exist the time will not create okay okay okay let me just try uh okay so it’s kind of if path the the different path is exist then you can create it like I want to uh this one is just tell you like the path is exist or not like I want to check that yes or no so it will show yes that path is exist so in case the new is exist inside that I want to create one uh location like here like here inside a new I want to create it inside new folder I want to create one more folder which name is uh data science okay inside a new I want to create it in a data science likewise okay let me tell you new okay temp Dr and then data science okay so like this live it let me make it the very simple I want to create new directory os. mkd which is name is new I want to create it but it’s already exist so it throw the error so what I can do if not os. path. exist new if it’s not there then it’s create otherwise don’t create so it will not throw the error in case new is not available so currently new is available it’s not enter inside the location but in case if it’s not available I delete it when you run it here so it will be create but inside nothing is there because just now it created okay so when you just apply this kind of condition if not os. path that exist then it’s created otherwise don’t create so in OS module lots of method is available so I just provided the link in a Jupiter notebook W3 schools you can also explore it like anything like I want to know that CPU count okay with a CPU count you can also use it how many CPU is there and you can also perform the operation there is a four CPU kind so likewise I want to also check that in my PC how many CPU count is there so OS do CPU count okay it’s not counts think yeah there is a 12 CPU count is there in their system is a four so likewise you can also explore it other method which is available here this is the last topic of file handling so here we will discuss about an different type of files like a pickle Json CSV okay so let’s create one dictionary so dictionary where inside some list is also available so this is the normal dictionary so pickle is used for preserving the data so like if you save this kind of data into any format like a Json format or normally the text format you can see easily right if you double click with a notepad you can uh see that kind of files but pickle is always store in the preserving method so like if I’m creating this kind of data as a complete data frame I want to preserve it and store somewhere so that in future we can also use it so usually this pickle we are using if you are generating any kinds of you know the model uh machine learning model or uh uh any any kind of model deep learning we are not using because for deep learning we have a separate extension is there so L take the example of machine learning if you created the machine learning we have a lots of steps is available and that entire steps that entire model uh steps we can preserve it with a pickle extension so here I’m just taking the one of the simple example which is dictionary I want to preserve it so again if you want to write any kinds of files we have to go with WB right in binary because it’s a pickle file and that have a two with two extension we can use it first one is pickle second one is Sav okay we can when you just store it uh uh that file will be stored in the pkl format so dick. py uh di. pkl the file is stored and you can’t see directly even if you’re opening on notepad you can’t see that kind of files so we have a two extension is available Sav and Pon okay so in case if you downloaded this file and uh you want to open it normal notepad any other any kinds of you know applications let me just download it and and I will show you how exactly look like so that was a dictionary that was a dictionary and now it’s visible like this actually that was not dictionary that was a data frame but it’s not visible properly if you want to see this kind of data again and if you share to anyone and they want to load it how we can load that kind of files so again we have to open first of all that uh files like with open Lim just use it with open file name file name is nothing but uh di. saav okay and we have to define the mode mode is equal to read in binary and pickle okay that we need one reference as F okay so pickle do load that F I want to load it let me store in the result values let me see result yeah so now we can see that kind of files so directly if you try to open it you can’t so because it’s store in the preserving method okay likewise we have also the another type of files which is a Json Json one of the data format where we can store in uh Json format right it’s a different type of format is there so Json always is working with the um curly brasses inside that key value payer option is available okay so we have a two types of data is available first one is uh structured data second one is unstructured data so this kind of data this word table kind of structured data but in case if you have a sector sector we have an HR and in HR the multiple set sector is there yeah we can say multiple type is there so you will you need to create one more table and then Define it HR how many types of HR is there right but the plus point of the Json is that ke name is a bob but the language instead of defining only one we can also Define the multiple languages as well okay and likewise inside the dictionary we can also make a dictionary so like the language is there inside the language I can also create one dictionary like in in a language I can also create a dictionary for example I can also make like this okay in English what is exactly the marks is there 45 so likewise they totally the unstructured we can Define the data in any way but if you have a table format so we have a limitations like English have a 45 a French have 56 the kind of we can also Define it so the Json is giving the lots of freedoms to Define our data set okay so nowadays the most of the data is available in the unstructured format so we preferring the Json extension okay so let me just show take it as it is yeah all right so we can also write it let me just create one normal files uh per . Json I just create normal file I’m just writing it here and dump now it’s dump and you can also do like this with with um you know with keyword you can also do that either or you can just open the file and then dump it okay so reading the files like file is already created the person. Json you can also see that so Json file you can easily see yeah they look like this okay so Json data is like little bit bigger even uh I can also show you uh some data set okay let me just go to uh covid 19.org one famous website okay covid 19.org okay I’m I’m just going with that okay this is a official website okay any other website is there co9 .org yeah covid 19.org okay I’m not able to find it out any H yeah yeah this is the uh one website is there when you scroll down and you scroll down so you’ll find it out the database here most of the data you’ll find it out in the Json format because unstructured data we can easily store in the Json extension okay see this is the format of the data so the most of the here the data is available like um you know the key and that values that is also considered as a key for that values this one is a key for that values like that we can also Define it like there is no any limitation to Define our data set if you’re doing with the same thing for a table so we have to create multiple tables for that so that is the reason Json is a quite booming and quite famous data type is there okay so we can also read it simply we have to read that data set so when I just read it look like this but if you want to see in uh same as it is the Json format so we can also apply the indent indent means taking a space for each uh sections we can say so to showing like this the name is a bob language and inside a language we have the different languages is there so we can also see that kind of data and and indentation it’s totally Upon Us ke how many indentation you want to pass it you want to pass the four it will be taking the four space otherwise it will be taking a two spaces so we have also uh another type of data which is the CSV is a quite famous I think uh uh everyone know about that CS V and Excel CSV is the comma separated values okay so here I created one complete CSV files so this is the field I Define it and this is the row and I want to create the complete table CSV tables which I will open on Excel uh software okay so I created the complete data let me first show you the data before writing the CSV format okay how it look like so row is look like this so this is the data I created it here and this is nothing but a field okay so field which is the name ear branch and marks so here I here I just just normally open it with with keyword student. csb is my data uh file name and I want to just write it and for next line I don’t want to Define anything and a dict writer when I just pass it and every time I will just write it uh write header and every rows that rows values one by one it will be passed into the um csb so the file is created you can also see that in a student. csb go back and uh we can see C student. csb is created here let me first download and I’ll show show you how it exactly look like the CSV file is created and the data will be look like this you can see okay name ear branch and marks so okay that is nothing but a field yeah name ear branch and marks that is a field and all the rows is also present here the name I Define it as uh Saga here I Define it a 2022 20 and Branch I Define it marks I Define it accordingly it’s created okay accordingly it’s created here you can see with the help of file handling we can also create the CSV file as well so likewise here I also Define it okay new line I want to add it so mode I make it upend and uh new line I didn’t Define anything so next time it will be appending that values so let me just refresh it okay uh here it will not refresh let me open in the same location here student okay so yes Manish math I Define it here okay Manish and Branch 2024 and math and marks I Define it here okay so likewise I also create uh the same thing for a data frame in case if you have uh uh this is the way of file handling techniques to create the CV file but one more way is also available to directly generate the CSV file like if I created the complete data frame with the pandas so it look like this I want to generate into the CSV so data set make sure that this uh this data set type this data type should be in a data frame pandas data frame okay so this is one is a pandas frame. data frame so if this kind of format of data is available you can directly pass data set in 2 csb if you pass the 2 csb so that directly will generate the files you can also see that yeah movies. CSV so the file will be generated in the Excel format sorry CSV format but in case if you want to generate the Excel format as well that is also quite simple why is not opening yeah it’s open okay by default is generating the uh index in case if you make it reset index Tex that will not visible there again uh this kind of things we’ll discuss when we start the pandas and numpy topic okay so let me show you how we can create the Excel file data set do 2XL you can Define it and uh you can write it here the movies do x x LSX that is extension previously it was a CSV that is a comma separated values Excel and csb both are different things both are different format is there okay when I just create it so you can see this one is a uh this one movies is the Excel which have a 5.07 KB that file size is little bit bigger compared to the CSV file this one is a CSV file but when you just click on it you’ll find it out the data is the same but only thing is that the Excel is creating their own format like this one is making at the board B this one is also making as a bold like that okay so this one is also the format of reading the any Excel file of CSV file I’ll just normally open it with the mode of R when I just make it mode of R and uh every time I just make it header and print it that sorry reader then and I print it one by one so you can see that the file so yeah so this way we can and why I just use this next because I want to just print it next one by one okay all right so hope you understand this all these structures but in case if you’re facing any kind of issues because uh this one I was little bit faster reason it’s the extra yeah we can say the different uh format of the data set is there sometimes useful sometimes not useful and uh I just explain the Json CSV and pickle maybe you also use different types of you know formatting but again the the structure the the process which I explain for this kind of formatting of the data set that will be the quite similar for that other format as well okay so hope you understand this video but in case if you’re facing any issues you can write it down in a comment definitely I’ll solve your problem so let’s first discuss about uh the topic which we’ll cover in object-oriented programming series Okay so so we’ll first discuss about what is the object then classes what is the inheritance and also we’ll also discuss uh Constructor polymorphism will discuss abstraction and encapsulation there is a completely a six main topic is there in object oriented we will cover one by one very first one what is the object and classes okay so class is nothing but so the uh topic name is objectoriented right right so first we’ll discuss what why the name is object oriented so object oriented is nothing but almost everything in uh programming language we consider as an object so like if I’m I’m a human my name is uh my name is X someone name is a y so that person is nothing but object so some classes is also there like the person is a x the person is a y the classes will be the human right we can say simply human human so suppose one car is there like here I I given the example as a maruti Audi BMW so these are a car the car is considered as an object where the car is a class this maruti AI BMW is an object the car is a class the same thing here so object which is defined here the Happy angry sad whereas the emotion is a class so the one real thing is which is really exist in a real life so we can say it’s object and some classes is also exist so class is nothing but it’s a blueprint of object whereas a object is a instance sub class instance is nothing but the example so object is a one example of a class so maruti is a example of car Audi is example of car BMW is example of car example is like instance of a that car so let’s understand in the practical way we’ll do it in the python okay so let’s do it in the practical way I’ll I’ll take the same example maruti Audi and BMW I will not take any other things so just consider here the maruti Audi BMW is an object and car is a class we’ll create it accordingly I’ll try to connect with that how programming uh in programming language objectoriented we are implementing so let me create one Jupiter notebook so it’s taking a time yeah now it’s created let me just take it oops concept okay so very first one is object and class we’ll try to Define it in a p in Python programming language we are defining with the uh class and class name so class name I’m writing here the car whereas the object will be BMW Audi and these are the things okay so car is a class so inside that we have a different different uh uh you know object is there so inside a car we can just Define it we can Define it the multiple functions so inside there is a class to multiple function is available right so the function can be the engine the function can be uh you know uh some indicate fuel indicator uh function can be the seat how many seats are there how many doors are there right so there is a door I’m defining the the function is a door so it’s very important to write it down here the self okay in Python programming language self is very very important whenever you’re defining any uh method inside a class so I’ll explain you later why the self is important for this self and then normal statement this car have four doors that’s it okay and and Def engine self is very important print this car have very powerful engine okay and uh let me also Define one more things is here uh seat self print normal statement this car have five seat yeah now then we just create an object so object can be uh BMW I’m defining it here BMW is equal it’s a object so car is a class so we Define the object like call the class and using the bracket and after that with the BMW what are the functionalities available you can directly call it okay so BMW do door so currently I just Define the very high level just door engine and seat but you can also Define it the very specific things is there ke in a BMW uh what is the engine is there so BMW have very powerful engine as compared to the marutti Suzuki or atata anything right so we can also Define the separate separating and we can call to that specific engine and specific seat okay and uh uh then I just call the B I just call the only door function so door will open right when I just run it so this car have a four doors okay so if the BMW i define it BMW do seat then it will call the seat only so this car have a five seat okay so likewise uh suppose if you have a different car car okay and I Define it car and uh T do door when you just call it so you’re not expecting that it should be the answer is a four seater a four door there is only two door right but here I directly Define it the four door because it’s a uh you know just default value I just pass it that I printed the values but you can pass the arguments if you just calling the uh door function and your object is a thar so definitely it should it should be pass only the two door not a multiple door is there so likewise we can also Define it so we can pass the arguments here is showing the four door because I Define it so here my main Moto was that ke how we can create a class and object so car is a class door method seat is a door engine seat is a method I can directly Define it here this is nothing but a class and these are we are calling the method and these BMW is nothing but an object BMW is nothing but a object object calling okay so this way we are defining here the the confusion is that what is the meaning of self and uh in case if I’m not writing the self so what will be the impact here so suppose if I’m deleting the self let’s see what will happen throw the error it throw the error is saying that the car. door takes zero positional arguments but one was given so that means so here the self is very important to Define it because so by default when you are creating the object it’s passing some arguments okay so that’s why it’s saying that take a zero positional argument but one was given but means here is passing some arguments but uh uh you know but I didn’t Define a I didn’t Define any positional argument so here I didn’t Define anything so that mean we have to define the self so what is the use of Self in case if I just use it here the self what is the purpose of that so self is a kind of self is a kind of one parameter so it’s using for passing the references so here I Define it self is a parameter is a reference to the current instance to the class and used to access the variable belonging to the classes so it’s very simple like if I have any variable uh the variable is um door is equal to four instead of defining here directly the four I just Define it as a variable I pass it the door okay I pass it the door and uh the same thing for a seat I also Define it seat is equal to 5 okay I Define it the seat okay all right so when I just run it so you’re getting the same answer nothing will change because I just create the one variable and Define the variable here same thing here I create the variable define it here but in case I want to use this door variable in a seat function is that possible so absolutely not we can’t can’t do it because it’s a local variable so it’s useful only inside that function any other function if you want to use it it’s not possible there so how we can use it so like here I want to instead of writing here okay instead of uh uh instead of writing this car have a five seater and door and doors are door is it possible to write it so it thr throw the error if you’re calling the seat function definitely throw the error yeah it’s saying that door is not defined in a seat function why it’s not defined because you can see here this car have this uh this this function have the variable seat but door don’t have but if you’re using any kinds of variable and attach with a self so it’s become a kind of global for the entire classes not outside of that so self is kind of passing the references so that it can be used inside a classes self. door instead of writing the door if I’m writing the self. door you can access why not access okay uh self. door is not accessible it should be self. door self do okay let me also Define it yourself I think half of you can’t use it door is not defined mhm okay so it’s throw the error in the first U function uh bmw. door okay so here is throw the air because I Define the self. door and here I’m calling the uh one door so that’s why throw the error so now the problem solved I use a self door and that variable I can also access easily any other function as well but make sure that that all the functions should be available in the same classes if the classes are different so then it create the problem but again that problem have also the solution is that uh we can use the inheritance that we’ll discuss later okay hope you understand that how the self parameter we are using what else we can also discuss it here there is one topic is called as a method and function and uh uh some you know some myth is there ke method and function both are the same uh both are the same or different and if it’s same then why we are using the two different name right it’s very confusing things so method and function both are same first of all let me just clear it it’s the same nothing different so only different is that if you’re creating any kinds of function with like uh Def and uh some function name is like a fun okay let me just write it there if you’re defining the function def function name is a great okay this is the function name and inside that whatever you want to write you can I’m just writing the pass so this one we are calling the function this one we are calling the function but in case if you’re defining any class okay class name is a and inside that if you’re defining this kind of function and with a cell parameter which is mandatory in objectoriented programming language if you are writing in a python so that time the grd become a method okay so here grd we are not calling it a function it’s a method so the difference is that the function and Method both are a same only when we Define the function inside a class is called as a method let me also write it when we we are defining the function inside the class we are calling method very simple so method or function both are the same only thing is that when you’re defining the function inside a class we are calling method there is also one more perception not a perception one statement is quite uh popular in Python programming language only which is in a python python is an object-oriented programming language that is true but almost everything in a python is an object with their properties and Method now it’s very confusing almost everything what is a mean almost everything so that means if I’m defining any variable that is also the method uh that is also the object yes as I said like when we start the objectoriented programming I said ke uh almost everything thing in uh in the world which is really exist is called as a object right so here if I’m defining any kinds of variable this normal variable a is equal to uh 15 and B is equal to hello these are two variables so according to that statement can I say that A and B both are in object it’s true both are object so why it’s object see if it’s object then definitely some classes will be there right because python is objectoriented programming language I said that A and B both are object that means some classes will be there so when you just check the type A so definitely you will get a class actually you writing in the Jupiter notebook that’s why it’s not showing that complete statement when you just print it print a so you’ll get it yes so int is a class of a so a is object integ a class some method will be there some function will be there method will be there not function okay because when you define the function inside a class that become a method so where is the method so when you just using the DI function which we used in I think last classes uh for OS module so di of a you’ll get it all kind of method these are attributes which we are using in object oriented in in class and object and when you scroll down you’ll find it out the object as well uh sorry method as well these are the method two type real image everything right so hope you remember in the uh data type um in string so lots of method is there I I make I separate it okay these are a function these are a method a method is always calling right method is always calling so here when I just use the DI R of B of B you’ll find it out the lots of method I think some method you already aware about that so like uh join we usually implement it split we usually implement it where is that yeah upper lower these we are implemented these are a method so if it’s a method I want to call it how we can call it here so B is a object okay I want to call one method Dot because B is object if you’re calling any method we have to use a b dot what is that upper so this is the method so when I just run it yes it’s working but that classes is the inbu classes so int string di list these are inbuild classes so hope you understand this concept is that why I’m saying that int uh why I’m saying that almost everything in a Python programming language is considered as an object a Constructor is a special type of method which we are defining with the init so I think we already discussed the init in package and module so there we didn’t create it in a class and object but here the Constructor which we defining that will be the class and object so the Constructor is executing when you’re just creating the object of the class so even don’t need to manually call The Constructor so let’s do it practically this is not a theoretical topic let’s do it practically here I’m taking the same example the car and what I just discussed let me just do the copy paste and try to just create one problem and that problem will solve with the Constructor okay so these are the uh code and here I Define the door and that that self. door I’m just using inside the uh yeah the seat yeah in the seat method I’m also using the self. door but what happen if you’re not calling the door method and you’re just directly calling the seat method so of course it will be give the error so here is showing that bound method oh okay because I Define it the door method and door function uh door variable both are a same so never do like that uh so better I’ll just do a doors okay and here I also use doors so here you’ll find it out you’ll get the error all right let me just remove it this one you’ll get in the error because you didn’t call the door method and you’re using this door variable so in that situation what is this uh option for you because anyhow you have to call the do method then you can use whatever you have Define inside that particular method so avoid this kind of scenario we are using the Constructor so Constructor we are defining with underscore underscore and it underscore underscore inside that cell parameter is always be there and whatever you’ll write print this is Constructor okay this is Constructor so whatever you’ll Define inside the Constructor this in it and that will automatically print so let me just remove it both okay let’s just create uh create the object BMW is equal to car so when I just run it automatically this method is run it’s executed it even I didn’t call it here so let’s call the BMW BMW dot the seat method seat method if you’re calling so there is a variable is self. seat okay self. seat which is Define it uh Define it here here directly and seat number better uh let’s change the variable name seat number so don’t make it the variable name and Method name are same otherwise the conflict will happen and you will be confused that why the getting the different error yeah different answer okay the better of door I’m also taking the door number yeah number of door okay number of Doors number of doors okay so here when I just run it and check the error car object has no attribute of number of doors the reason behind that because I didn’t call the uh car method and directly calling the seat method here so the seat uh there is a two variable I’m just using SE seat number which is defined in the same method but the number of door is defining the different method so avoiding this kind of conflict if you’re just using the same variable in the multi multiple method so don’t use it here I can directly use it inside a Constructor because Constructor will always always execute and you can directly call any method you not depending on any method here so when I just run it yes this this car have a five seat and doors are four so right so this kind of Constructor we are calling the non-parameterized Constructor so the Constructor is also defining the two types the very first one is a parameterized second one is a non-parameterized parameterize simple you have a parameter non-parameterized you don’t have a parameter right so which I Define it here this one is considered as a non-parameterized Constructor red Constructor and if I want to make it a parameterized Constructor whatever you passing the number of doors and uh seat number so that you can pass as a parameter so let me just Define it and uh we are doing the Constructor let me also make the heading properly here so this is the Constructor topic okay so I want to make it parameterized Constructor here so this is normal non-parameterized Constructor let me just remove it my target is to make it parameterized Constructor so whatever is Define the number of doors so instead of taking the manual Valu is the four I’m taking as a parameter wise uh suppose the door number okay door number suppose that variable I’m just taking it and at the same time so all the variable which I Define it even the self dot seat number that I also take it inside the Constructor itself okay let’s take the seats number let me take the number of seat directly number of okay so uh here I’m getting the values as a parameter so let’s not take it this one now so this is the normal method I’m just making it so inside a door I’m just printing the number of doors engine just normal statement and Method and seat and we are printing the seat and doors both so here I don’t want to make it manually four and five let’s make it some Dynamic way so in the place of four I’ll just pass it the uh door number and here in the place of five I’ll pass it the seat number so whatever value will be store in the seat number and door number that will be that will assign into the self do number of doors and self. number of seat so here when I just pass when I just call the Constructor when you don’t need to call the Constructor automatically call let me just create the object of it BMW is equal to car and here you have to pass the parameter because if you not you have to pass the argument if you’re not passing the argument it will throw the error what is saying that the car do in it missing two positional argument which is the number of door number and seat number so I’ll pass the two arguments let me pass the four door and five seater okay four door and five SE when I just run it so this this is Constructor that statement is run that means there is no any problem in the Constructor so now when I just pass the when I just calling any method like bmw. seat so that running properly okay bmw. seat oh the core object has no attribute seat number okay it’s not a seat number it’s a number of seat okay when I just run it yes this one properly working the main Moto of it here if you are just defining the parameter inside the Constructor it’s become a parameterized Constructor and if you define the parameter of course you have to pass the arguments okay and uh you can also make it default parameter as well so you can make it get zero in case if I’m not passing anything if I’m passing the four and five of course I’ll get the four and five as a seat number of seat and number of doors but in case if I’m not passing anything so in the time is taking 0 0 so that default value we can also Define it so this way we are doing the Constructor let’s first discuss about the definition of The Inheritance so inheritance is a mechanism which inheritance is a mechanism in which one class classes acquire the property of another classes so there is so many examples available for inheritance so I’m just took one of the example of uh parent and child so likewise the child is always acquiring the uh you know all the kind of property and uh other stuff of uh his father so the kind of uh this kind of classes this child this classes we can say the child classes okay and it’s we are also calling the derived classes it’s already mentioned there derived classes and uh we also calling us yeah child classes and and this one we are calling the base class we calling the parent class parent class okay so likewise we have a two different name we are using it so there is a multiple type of inheritances exist in the objectoriented programming language okay I already mentioned there the super class we also calling sub classes we are calling of this child okay so there is a multiple types of inheritances exist single inheritance multiple inheritance multi-level inheritance hierarchical inheritance and Hybrid inheritance so here the the complete map of the single inheritance and multiple all kind of inheritance map is available so we will discuss about the Practical implement how we can perform the inheritance concept with the Python programming language okay let’s jump on the coding yeah practical implementation okay I required one classes uh let me just take a very simple classes is U father okay so I’ll take the very uh you know real life scenario situation where you can easily relate it like I create a I will create father class I will create a child class I will just create object of the child so that you can easily real relate with the real life example father and so whatever if you want to create any kinds of Constructor you can otherwise it’s not required currently okay so we’ll create one method so method name is like the father have car okay so the child can acquire the car car and self is very very important self and let me let me also pass some parameters car model your model I’m just passing it here and just normal statement okay father have a car here I can also Define the model as well so this is one class I’ll also create one more class which is a child okay child and here I will inherit the father let me first create the child later I’ll inherit how to inherit I will also discuss in a deeper way as well so def a child have a bike okay let me also pass the self and bike model yeah yeah model we can say model and print the statement is I have a bike and that also Define the model as well simple so I’ll create one object the child object the ra name is Rahul Rahul is a object of child class now I create it if I want to call any method which is available in the child class I can easily call it Rahul dot bike okay I can easily call it so now when I just run it you’ll get the statement is I have a bike so whatever bike he have so we can easily get it okay so here we can simply perform the operation and also check that key uh this one is running or not there is a error why it’s Error because we defined one parameter but didn’t pass any kinds of arguments so I will pass the arguments what kind of bike you have I’m just passing the fet simple so I have a bike FZ but can Rahul call the car method is that possible so no Rahul cannot call the car method because it’s available in the father class so I can simply create I can simply inherit that father class in a child class so you can just create just round bracket and inside that whatever class you want to acquire it you can directly write out there that class name so I’m writing the father so when I just writing the father inside the child bracket that means I’m just acquiring the all the property of child uh all the property of Father inside the child so when I just run it so I should get the answer now okay so father is also have one parameter so I have to pass the arguments so I’ll just pass the arguments as like maruti simple maruti okay when I just pass it so father have a card which is a maruti so simply Define it here so one class acquire the property of another class so property of another class in the sense property can be any variable can be any method can be any function method and function both are a same so you you can call to any kind of the inherit Constructor as well you can call it okay so this kind of inheritance we are calling the single inheritance we are calling single inheritance we can just Define it single inheritance simp so let me also take one more example of another inheritance and after that I’ll Al assign you the one kind of task for you you can try it and check that key uh you can you know you can easily do it this inheritance sing multiple or multi whatever you can do it or not so single inheritance is done and now I have to take some complicated in inheritance let me take the Hybrid inheritance because when I just take this hybrid inheritance so hybrid will be cover the hierarchical inheritance which will be this and uh it also cover the multile inheritance as well so I’ll just go with Hybrid inheritance and uh you can also do the practice of multi-level inheritance and hierarchal and multiple separately as well okay let me just also Define the uh here headings so that you can also do it so you will get this Jupiter Notebook on GitHub just go to the description you’ll find it out one link just go there and find it out this this Jupiter notebook code okay so uh I’ll go with the Hybrid inheritance inheritance inheritance okay it’s one sorry okay so Hybrid inheritance I’ll just try to create it I’ll just take this uh same example this one okay now this one is a single inheritance I’ll also create one more class which have simply mother and Def car self model not a model I’ll not a car I I’ll take something else uh scooty okay scooty suppose mother have a scooty uh so I can also Define it here the self and model I will not pass anything I can directly call the scooty and print this normal statement okay so mother have scooty okay simple so child here the child is acquiring the father only and uh let me also create the object is Rahul is equal to child and Rahul will call to father rul will call to sorry not a father rul will call to car r can Rahul can also call the bike as well so he will not get any kinds of error okay so model is required so I’ll just pass it here okay so maruti I’m just passing the same thing and there I’m just passing the F said so this one is working but if a child try to acquire the property of scooty Rahul do scooty so you’ll get the error while getting the error because here the child is not acquired the property of mother so I’ll here I’ll try to just acquiring the property of mother as well just do the comma and pass the mother so what will be happen so child is acquiring the property of both mother and father both okay so simply you have to just pass the both the classes inside that bracket uh which one which class you want to inherit so this kind of inherit this kind of hierarchical uh this kind of uh inheritance we can say it’s a hierarchical inheritance because I have a father I have a mother and here is a child so it it acquire the property of father and mother okay so when you’re talking about uh other inheritance like if you have a multiple things so so this it’s not a hierarchical inheritance we can say it’s a multiple inheritance multiple inheritance okay so when you’re talking about the uh you know any hierarchical inheritance so one kind of class should be there so let me also create one more classes and father and mother both can acquire that kind of property so we can say uh we can say Define that um uh property we can simply we can say property so property can acquire in inside a property function so father and uh mother both can acquire the classes so we can also Define it here so that become the hierarchical inheritance so upsider one we can say it’s a this one so this one we can say it’s a hierarchical inheritance and uh in inside one we can say this downside one it’s a multiple inheritance so let me just remove it clear all the drawings yeah so let’s create one kind of class and just Define it this one is this hybrid this currently it’s a not a hybrid this one we can say it’s a yeah this one is a multiple inheritance I can also Define it here multiple inheritance multiple inheritance I have to also pass The hierarchical Inheritance as well inheritance okay so currently I just use the uh multiple inheritance let me also Define The hierarchical Inheritance as well so I can just take it here one of the classes which is okay property okay okay properties I can M it because maybe I think some in build function or in build classes can be so I will not take the property I’ll just take the properties I’ll create one function is a uh okay land Square self I Define it here so that property father father mother both can acquire it at the same time child can also acquire it so I can also Define it here uh just normal statements so we have five acre ACR I think we can call call it property in India okay the normal statement is there so currently that properties classes cannot uh you know it’s not connected with a father and mother if they want to acquire it they can also directly pass it here the properties so this is just a normal example how the all kind of inheritance is working properties okay so simply uh properties that spelling is Miss wrong I think okay properties so there is no any error so in case if I’m creating the object of father and mother anything So currently uh the object of child is already present so let me also directly call that Rahul do properties Rahul do land Square so when I just use the land Square I don’t need to pass any kinds of arguments so Rahul can also access it why father and mother so same time if I creating the object of father and mother like f is equal to father and uh F do land square if I’m just calling it so you can also access it so inheritance one of the simple topic of objectoriented programming language so here I just use it the Hybrid inheritance inside a Hybrid inheritance so multiple and hierarchical is a covered so multi thing is remaining in the multi-level so you can also try it and let me know if you’re facing any issues but I’m I’m I’m damn sure you will not face any kinds of issues because hybrid is covered kind of all kind of uh levels because the multiple is already there so you have to just increase one of the labels so it become a multi-level inheritance let me also create one heading multi- inheritance okay so polymorphism is nothing but like many form the simply we are calling is the many form right many form we can directly say so when you’re talking about the definition of the polymorphism is simply if you have any kinds of function and the same function name being used in the different way let me just remove it that annotation yeah the same function name being used for a different types so not only the function uh usually we are using for a function that we are also calling the method but we can also do the same for operator as well so polymorphism can be achieved in the many way so the very first one I think you already aware heard about that that is Method overloading method overloading and uh the second one we are calling method overriding okay so and we have also the another type is also aaable uh that uh we have Operator overriding Operator overloading Operator overloading and uh we have also one more type is there the duct type okay why I mention there the operator overloading and duct type here because in this video and in the series we going to discuss about the method overloading and method overriding which is very very important um in the polymorphism perspective but you can also learn it the method over loading and duct type as well but if you want any if you want a video for uh operator overloading and duct type I can also make it it’s not much as much complicated okay so these are the way to achieve the method or uh to achieve the polymorphism concept let me also write it here this way we can achieve polymorphism okay so uh polymorphism we can also understand it there is two way the first one we can we can try to understand with without classes okay without without classes which I will discuss in this video okay without classes and we also discuss in with classes as well okay so with classes like here method overloading and method overriding that we can do it with classes but let’s understand it very simple way how polymorphism is working in um you know normal examples so let me also let me take one heading polymorphism okay startingly I will not make it much complicated overloading overriding we’ll discuss later but let’s understand it how polymorphism is working with a simple function without any classes polymorphism okay let’s say for example if you have um you know inbuild function is a len so Len is a function if you you pass a simple statement is hello okay so it will give you the answer is the length of five length of hello which is uh five but in case if you’re passing the length of any uh list 5 6 8 9 there is no any restriction to pass any kinds of data type I can directly pass a string that is also acceptable I can pass a list that is also acceptable if I’m passing Apple dictionary set anything that is acceptable so the one function have a multiple form to define the length of uh the length of container that container can be the string that container can be the list dle anything suppose if I’m defining any function here the def def add function I’m passing the values is x y and Zed okay x y and Zed and just uh returning the values return x + y + z so when you call this function the ADD and pass the values is 4 comma 5 comma 6 then you’ll get the answer like addition of all the values which is a 15 but in case if you’re passing only two values two arguments but you define the Define the three parameters but if you pass the two arguments definitely you’ll get the error but if you directly Define some uh you know default parameters which is if I’m defining the none here so that is acceptable here uh not a none uh none type cannot be added let me pass a zero okay pass zero so you’ll get the answer is 5 + 4 so the same function I can add two values the same function I can add add three values as well so here the add function being being like uh the same function is uh you know working for multiple forms so we can use it right so this there is a two techniques is a method overloading and Method overriding so that is a two different totally different techniques we’ll try to understand it and do it in practical way so how exactly the method overloading is working so let’s say for example if you have one class okay class and the class name is a uh for example is a cal So Cal class so inside a cal clock I can Define it multiple methods uh multiple methods but the name will be the same so the name is like def me method name is ADD I can pass the parameter is like X comma Y at the same time I can also Define one more method which is ADD and this time I will pass the parameter is X comma y comma Z okay okay so if you have a two different method is available but the name are name are same so when you create the object of the class so the class name is suppose C Class name is a cal and object is a c Cal okay and uh C do add if I I’m just calling it if I’m calling the add function with three parameter 5 comma 7A 8 then definitely you will get the addition but the same time if I am just calling the addition U addition of only two number suppose if I’m not passing the eight okay so function is already defined the add function is already defined so definitely this function should call but in a python this kind of you know normal overloading is not supporting the reason behind that the python is a interpreted language and it always take piing the current positions current positions values so here the current one is the add which is defined with the three parameters and if you pass the two parameters the previous one is not accepted it’s being overloading but if you’re defining if you’re passing the only two parameter it not able to call the previous one so the complete overloading is not acceptable in the Python programming language let’s try to understand in the Practical implementation okay uh the topic is Method overloading let me just uh write it down the heading here method overloading okay so the class I Define it the same example I will take it class calc okay inside a cal I’ll uh I’ll Define the uh function add and pass the parameter is a comma B okay and uh make sure that you have to pass the self uh par meter which is passing as a reference which is compulsory in in the Python programming language I’m just passing it here return of A+ B okay so and then I’ll Define the ADD and pass the uh parameters a comma B comma C okay there is three parameters and uh return the values A + B + C and me also Define a without parameter def add and self inside I’ll just pass the A and I will return return e that’s it so very simple example is there the method overloading so method overloading let me also write it down the definition here a see okay uh method name are same but different parameter method name are same with different parameter okay so here I make the same thing method name are same but the different parameter if I’m just I the structure is ready now I’ll create the object object is let me just see take it as a c is equal to Cal okay all right so here Cal is a class and the C is object I will call the method add the C do add and pass the parameter 4 comma 5 comma 7 so I’m expecting the answer is uh 19 5 + 4 9 + 7 16 so yes the answer is correct the 16 but here I pass the three parameters so definitely this method is run okay but in case if I’m passing only the two parameter what will happen so if I’m passing the only two two or ments this one is arguments okay let me also write it down here this one is a arguments and what you are defining is a parameter okay so here I’m passing the only two arguments and uh the line number five is already defined the um you know only two parameters so I’m expecting the answer should be nine but here is the getting the error it’s saying that the missing one required positional arguments which is C so why it’s showing this kind of error the reason behind that you can see here so the last method is defined three parameters and I pass only the two arguments so it’s not able to check the previous one because of the Python is a interpreted language so if I’m passing the parameters it taking the current one for example if I have the a is equal to 7 and a is equal to 8 so if I run it so it’s being completely over overridden okay so if I’m printing the a so it will getting the answer is eight so what will happen is the first eight is a store in the first seven is a store in a variable when I’m just storing the eight in the same variable so what will happen the previous values is removed so the same thing happening is here so previous value is not considered it’s taking the current one only so what I can do uh so simply the method overloading is not completely acceptable in the Python programming language but if I want to achieve it so we have a you know different way we can achieve it see in a python everything is possible but something is direct or something is indirect so the directly method overloading is not possible but indirectly you can use it so what I can do it here if you if I have a three variables so all three variables I Define it a b and c but make sure that you have to Define some parameters I’m I’m just defining it here zero okay I’m just defining it here zero uh or else or else I can uh directly Define it here is equal to none nothing is there because I I’m not defining anything right so uh is equal to none but a is not equ equal to none here so because if I’m just passing the only a values so it’s not is equal to none okay uh so it’s not none is equal to none it’s is equal to is equal to none hope so it’s correct okay all right so uh this way is not possible so what I can do it here let me just uh okay so let me take it as it is now I’ll Define it a different function here so what I I’m expecting that what is my target my target is very simple is that if I’m passing the three parameters it should be the addition of three number if I’m passing the two values it should be the addition of two if I’m passing the one values it will be just print as it is so how is possible I can Define it the same class let me just Define it C A LC class and Def add and uh pass the self and Define the a comma B comma C simply I I I can use it here the condition wise so if the a is not is equal to none okay and B is equal to is equal to none and C is equal to is equal to none so in that time I will return simply a okay and L if if a is not equal to none and B is not equal none and C is not is equal C is equal to is equal to none so in that time I will return a + b okay it’s not a comma it’s a and at the same time Al if a is not equal to none and B is not equ equal to none and C is not is equal to none in this time okay I will uh return the value A + B + C great so let me just create the object C is equal to calc C1 let me just check it because the previously I Define it so I don’t want to mix up here C1 is equal to calc all right C1 dot add if I pass the three parameter 5A 4 comma 6 Okay so you the answer is a 16 what happened def C where is that def C line number 20 where is the line number 20 oh oh sorry oh it’s not a def it’s a class sorry it’s 15 I’m getting the answer is 15 okay previously it was yeah 15 and if I’m passing the only two arguments it’s giving the answer is okay the C positional arguments is defining it here uh okay 11 line number 11 if I’m passing the ADD and pass the parameter a comma B comma C okay is equal to none let me Define it is equal to none let me Define it is equal to none and let me Define it so the 5 + 4 is getting the answer is nine so if I’m passing only one arguments five that’s it boom right your how it’s happening because if I’m passing the values and in case in case if I’m not passing anything let me also defining else is here none so if I’m not passing anything so it will not give the error it getting the none so what will be happen so if I’m not passing any parameter so default values is none none none okay so all the condition I Define it ke if one values is present a is present it will be return B A and B both are present it will be return c a b c both are all three are present A plus b plus C is working is here and in case if you’re not passing anything so the answer is none so this way method overloading can be achievable but directly the concept was method name are same but with a different parameter if you define it so that is not achievable directly in Python other programming language yes it’s achievable in Python is not possible so the next topic which we have to learn it here method overriding which is mainly used in almost every applications so in the last video in meod overloading what we discussed is ke the same method and same uh different parameter was there method name was same but different parameter but here in the polymorphism is being little bit more complicated method name are same and the same parameter as well right so the problem was the previous uh topic is the overloading that was not acceptable completely so the question is how it acceptable is the over overriding because here the method name and that parameter both are same it’s acceptable because the classes are different you can see here so there is a class is a shape class inside a sh shape class in there is a class uh sorry there is a method is a draw draw draw and there is no any parameter is available here right so I can say the same method but and the same parameter as well but all three method are available in the different different classes like Square class Circle class and he hexagon class so this method overriding is achievable with the help of inheritance concept so we already covered The Inheritance you can also just refer that videos as well so let’s do in a practical way how method overriding can be achievable in polymorphism topic okay let me just write the heading here method overwriting okay so suppose if you have a class class name is a father and uh father have um you know uh one method uh car okay and yes self parameter is very very important in object oriented in Python if you’re writing the code and a simple statement is that hey I have a car okay the car name you can also Define it here suppose the car name is um uh you know uh BMW okay simply BMW and there is also one more class which is a child and child have a bike okay and let just just normal statement here I have uh um sports bike Define it here uh the same thing is a BMW okay the father have a car and the child have a bike if I’m just calling it here uh you know the object of a child simply Rahul is equal to Rahul is a object the child is a class okay Rahul do bike and and uh uh when you just uh call the bike then you’ll get the answer is I have a sports bike which is a BMW and you can also inherit the father as well okay and if you inherit then Rahul can also access the property of a father so Rahul doar if I’m just calling so you can also access the car as well so Rahul is saying that I have a sports bike which is BMW and he’s also saying that hey I have a car which is is BMW so there is no any overriding till now but if I’m creating the a car method inside a child which is also present in a father car and the same method name and the same parameter like here I didn’t pass any parameter and in the child car I’m also not passing any parameter here so when I just writing here the different statement I have car Mercedes okay Merced is bench so here if I’m just running this this method the car so this time it will not calling to the father it will directly call which is available inside the child so here the statement is being changed I didn’t change the calling method here is the same thing as a car previously was also car but here it’s not showing the BMW it’s showing the I have a car which is Mercedes previously it was showing the BMW why it was showing because it was not present at that time and it inherited from the father and that is the reason it’s showing that yes I have a car which is BMW actually the child don’t have a car fathers have a car but now the child have their own car instead of writing the I have a car I have my own car okay Mercedes-Benz so the here the car method this car method is overridden from the father car so this way we can achieve the overriding concept here so there is also the techniques is available the uh operator overriding so there is also one more issues is exist which is uh if you’re creating the class we always creating the uh Constructor which is defined with underscore uncore init so every classes when we Define The Constructor the always the name are in it so when you define it so by default that init is being overridden but sometimes we have to we have to use both the Constructor so in that time how to achieve it how to solve that kind of problem so we’ll discuss in the next video so if the method overriding we have some issues like if we are creating the Constructor and uh uh how we can if the Constructor is also overridden then how can we use the previous Constructor yes parent class Constructor so super function is solving that that problems the super function is used to give the access to method and property of the parent or sibling classes so it’s kind of giving the access it’s accessing related things is there so this things you’ll understand in the practical way okay it’s not a theal topic so let’s let’s discuss about some scenarios where super function we can implement it let’s say for example I have a class okay it’s not a capital letter I have a class class name is um uh same is the father and the father I have one Constructor this time I’ll just use a Constructor last time I didn’t use any kinds of Constructor there so I’ll use a Constructor in it okay so make sure that you have to write a self here self and then just write it uh some some variable uh self. car okay that car name is I I will use it um I’ll use it maruti very simple simple car is here maruti Suzuki Suzuki okay all right and uh a function name is um you know info so inside that I’ll just writing here print I have a car and the car name I can also mention here the self dot car very simple okay same time I’ll also create one more class that is child the child have a Constructor uh the diff in it I’m so sorry yeah here I’ll just use it and it I’ll just pass it here so so you know that if you just um you know apply The Inheritance concept here it will be over done right so let me just complete the code and after that I’ll apply the uh inheritance concept here Def and and then uh self. bike that bike name I can also Define it here Duke okay Duke okay all right and then the same time def info okay I’ll just use the same thing here same function info okay and same parameter here I just didn’t use any parameter I here I’m also not using any kinds of parameter I’ll just use it here I have a bike okay I have a bike let me just write here the bike info right bike info I have a bike and and and I can also Define it here the self. bike simple all right okay let me just create object is Rahul is equal Al to child okay object is created Rahul do bike info I create the object yes I have a bike which his name is Duke all right so here I didn’t apply any kinds of inheritance concept so let me just use the inheritance when I just use the inheritance so I can also acquire the property of father so when I just use it here the self dot okay self dot uh sorry not a self do father I just use it here the father I’m so sorry yeah so yes Rahul can access the property uh yeah we can say the function which is bike info I can Rahul can also be access Rahul doino as well which is nothing but a car info let me also write it here the car info okay car info can also be access what is the issues here the child object ch object no attribute of the car why why it’s showing that no attribute to the car because here the two things is overridden here I have a car info okay that I can also access it but the problem is it will be needed self. car which is not available in this init okay let me just Al let me just write a very simple statement I have a car that’s it okay so you’ll not face any issues I have a car that’s it I have a car so Rahul can also the acquire the property of car info can be acquired but if the Rahul need any kinds of variable from the init from the init like Rahul want to access Rahul want to access the a car can yeah bike let me first take the bike bike yes Duke can be access simply can be access here can can Rahul be access a car which is available here is it accessible the answer is no Rahul cannot be accessed the car uh is it required a function here oh not a function okay sorry rul cannot be accessed the car because this in it here I just use the init because of this init and here I also use the init this is the same method is available with the same parameter it’s become overridden in a child class so you cannot be access it but still I want to use the car uh car variable I want to use it how can we do do that so you can use the super function super function super function. net super dot yeah and it so when you just use it uh okay there is some issues I can directly use it here super super is a function yeah and then use it in it okay uh sorry in it is not as in exactly this in it you have to write it here in it yes Suzuki I can also access it so I I can I I can’t directly write it like this you have to print it so when you just print a car bike you’ll get the bike and if you print a car you can also access the car so the simple is here when you just write it here the self. bike that means you can uh self bike you can easily access it because of this init is inherited from the father in in it so that means it’s become overden so the previous one is not access ible but still if you want to access it the super is nothing but your parent you know from where you are acquired it this is applicable for any kinds of hierarchal um inheritance any kinds of inheritance if you just using it the same concept will be applied the super is like child super is nothing but a father so the father variable can also be accessible if you are using the super function okay super function if you just using it you can access it and now if I’m just writing it here um self. car so that means you can access it so here I can see I have a car which is a Maru Suzuki okay I have a car is the maruti Suzuki but again it is applicable if you’re just using the same function is a car info okay and uh self is very very important car info and just write it here um I have a car which name is I can write it here uh B BMW okay so here showing the BMW because this same function is overridden okay but uh this function is not available definitely it will go back from father class and and use it but here the self. car is also available and uh which is available in a Constructor and Constructor is already overridden to to overcome this kind of problem to solve this kind of problem we are using the super function so super function is nothing but the giving the access the variable method and uh any kind of attributes from the super classes yeah father classes so the definition is also saying the same thing the super function is used to give access to Method properties of a parent or a sibling class okay the super function return return an object that represent the parent class okay so here super is represent that I I’m I’m a parent class okay whatever you need you can just call me so this way uh super function is working so let’s directly jump on the Practical implementation here okay so this this topic is very very simple uh we’ll just create the inner class we’ll just create outer class and try to call it how we can call it and what is the procedure we’ll uh discuss it step by step let me create one class class name is very simple just laptop okay inside a laptop and just for a confirmation um you know so that we I just call it so that we’ll get a confirmation so I’ll create one Constructor because Constructor is automatically called we don’t need to call it make sure that you have to write a self here and the statement this is this is laptop class just normal statement and after that it’s on you if you want to create any kinds of function you can create it but I’ll directly create a class here so class class name is HP okay inside that laptop there is a class is HP and uh again I’ll create object uh sorry not object Constructor I’ll create a Constructor and Define some name here print this is HP class inside the laptop class okay it’s very simple laptop class great and we can also create one one more function function name is info okay and this normal statement here hey this is is info function simple this is info function so the creating the inner class and outer class is really very very simple just we have to Define it which one is inner class and which one is outer class so this one you can understand like this look like outer class yes it is outer class it is outer class and this one we can say it’s a inner class okay sorry inner class all right so how to call it like my target is to call the info function which is available HP that HP is available in a laptop so let me first create object of laptop L is equal to laptop laptop okay or create it and uh if you create it the object so Constructor will definitely call yes uh this is laptop class it’s a class yeah this is laptop class okay and I want to call the info function fun which is available inside HP so H is equal to l do HP okay l. HP right because HP is not you can’t directly call the HP because which is available in outer class so first you have to call the outer class and after that you can call to the another uh inner class okay uh the laptop we don’t have any kinds of attribute okay all right then I can directly write here okay sorry uh HP is a capital letter yeah HP class this is HP class which is inside the laptop class and with h i can directly call the info that’s it so hey this is the info function and this is the one way to call the a function which is available inside the inner class but we can also directly call it here ke we directly create the object is H is equal to laptop okay dot uh HP we can call like this so inner class and outer class we can we directly create the object and that object will be the inner class which is HP and we can directly call the H Dot info if this kind of topic is there so definitely we have also the variable exist so the likewise instance function we have also the instance variable okay instance variable and uh we have also the class variable the same time we have also the static variable again this this kind of things we will discuss in the practical way then you’ll understand easily how the instance function class function and static function is working okay so let’s jump on the Jupiter notebook okay here so I’ll create very very very simple uh function here so the topic is instance function class function and um static function example if you creating any kinds of class with normal class uh class name is uh okay uh class name we can say the first class okay first class okay then normal the first class uh the class name is there and you also Define some one Constructor in it and pass this self and here you define it self dot um a is equal to and self do name is equal to you define it and name is hurry okay and Def info I Define it here and simply I Define it here he hurry right self. name I I I’ll just pass it okay self. aray so simply I just create the object let me create the object object name is FC is equal to first class and FC do info so here hey harry so he har is calling it here so I create the class this kind of um uh this kind of function this info function which I Define it s self as a reference it’s passing the references so that we can use the any kinds of variable within a class so this method we are calling the instance method so instance method and I also Define one variable which connect with self so this variable is instance attribute we are calling okay instance attribute or instance variable instance variable we can say inance variable let me create one more uh variable variable name is like um uh College college name okay college name is IIT Bombay I Bombay okay all right and U uh this instance function here you create it instance variable you also create it if I want to call it print and call it here the um instance variable can I just call it so FC do uh name if you’re calling so you can also get the values as hurry so that is also accessible with object as well okay I created the uh one variable is a college name and I want to access it that uh let me just directly write it here so what kind of variable we are calling actually this kind of variable we are calling the um you know class variable class variable we are calling and I’ll just pass it here college name so when I just call this I Bombay is accessible but uh this uh class variable this one is a class variable I if I want to use it any method how can you use the method okay this one is a class variable how can you use the method So Def class okay not class info one I can write it here better I can write it info one and this one in info two okay info one I can just call it here yeah info so again college name is not connected with a self right so in case if I’m writing it here self and uh just just pass it uh you know print college name and here I just pass it simply the self do self. college name so obviously it’s not accessible let me let me just call it FC do info2 okay um that is accessible here it’s accessible it’s not a problem I Bombay is also accessible college name uh but again this kind of variable is a uh class variable because it’s not connected with self self reference is not connected with that here self if you’re forcefully writing it here yes it’s accessible but this function we can’t call it as a um you know instance method yeah instance function we can’t call it if you write it here CLS see LS and then uh then this kind of method is called as a class method okay that is also accessible hope so uh but uh you don’t need to Define it yourself obviously CLS you have to Define it and it’s accessible so CLS if if you’re passing the reference as a CLS then it’s a class method but if you’re passing the reference as a self that is the instance method okay so there is also one more variable and one more mode method we can also use it uh def uh info 3 okay and if you’re not passing anything and make sure that uh we have also you know decorator we can also Define it so for a security purpose so here we can also write it class method okay so we easily uh Define it here decorator is a class method what we are calling we let me also write it out here decorator decorator okay all right so here I’m not passing the CLS I’m not passing the self so this kind of method and and whatever variable I’m just Define it here inside that um I’m I’m defining it a variable here U like um what is name role number yeah role number not a role number and we can say uh the ID student ID which is maybe the confidential student ID I’m just Define it here 1 121 09 okay 12109 this is the confidential and it should not be accessible outside okay and when you just run it you’ll getting the error not getting the error because I didn’t call it so fc. info3 when I just call it is getting the error like saying that take zero positional argument but one was given because because whenever you creating any kinds of method that automatically expecting that it should be either CLS or a self but here I’m not passing anything okay so that is the reason it’s making that here the take zero positional argument but one was given okay so uh one was given that this kind of error will coming definitely will come so how to overcome this kind of problems so this kind of method is called as a static method this kind of method is called a static method there is no CLS there is no self but how to uh you know solve this problem how to create it so there is a decorator you have to Define it here static method and when you just Define it then to not create any kinds of issues and this variable uh student ID if I want to call it static variable okay fc. student ID so that is not accessible there is no attribute because it’s defined in the static method and and it’s not passing the reference with self and uh this class variable that was available in the outside of that that is a global variable and Global variable for that particular class but here you can’t you can’t call it so where you you can use this kind of um method so simply I can just write it here this is uh my my student ID is student ID when I just pass it and and and showing that hope so is showing that yeah okay okay here is showing that uh student ID my student ID is this one okay and this variable we call calling as a uh static variable hope you understand this this all the method and function this one is a class variable and then class method we have we have a instance variable able we have a instance method we have is a static variable we have a static method we have okay so now it’s done and uh you please refer the Jupiter notebook uh if you don’t want to watch all the videos uh you know complete videos just refer the Jupiter notebook run it and try to understand but you face any issues go back to the video and check it where you’re stacking exactly and now we reach the topic of encapsulation we already covered the many topics like um you know the object class polymorphism inheritance okay so now we we have to discuss about encapsulation so encapsulation is really very very important for a security purpose hiding the information so let’s first discuss about the definition here so this one is saying that this put a restriction on accessing variable and Method directly can prevent The Accidental modification of the data to prevent The Accidental changes an object variable can be only be changed by an object method so those type of variable we are calling the private variable so this is the normal definition we will discuss about in a practical implementation as well so you can just imagine that you have a capsule inside a cap you know medicine capsule so whatever information is whatever uh ingredient is there so we can’t see that that is the hidden but we can see the medicine so likewise here we have hidden information we have important information like a method and variable which is available in the class and we can’t directly uh you know we can easily access the method and variable so we provide some restrictions so that the people cannot be accessed directly so there is the multiple way to protect it so we have a topic is called as access modifier so there is a three access modifier is available public protected and private okay so when you’re talking about how uh public protected private is working so before let’s understand that ke how we can access any kinds of method and variable see there is uh some access attribute is available so if you just use this uh get attribute has attribute set attribute so you have a you know you have opportunity you have option to you know get the any kinds of variable or method easily okay with the help of objects obviously and we have also the one more option is available building uh class attribute we can see all kinds of method and variables we can see that so we just try to protect the method and variable so we have access modifier so there is there is a restriction is providing this protect and private so what kind of restriction they are providing so we need talking about the first one is a public member the public member uh kind of variable a variable which is the publicly so the public member of a class let me just take the annotation yeah public member of a class are variable are available to everyone anybody can easily access it so they can access from outside of the class and they can and also other classes too so there is no any restriction for the public public member like whatever whatever variables and Method we have created that is the public member previously what we created that was a public member protected member is providing some restriction there so you can see here the protected member are those members of the class that cannot be accessed outside of the class but can be access from within the class and its subclasses so it’s providing the uh some restriction but not the entire restriction right it you can access it you can access it within the class but outside of the class you can’t access it but when you’re talking about the last one which is a private member so a private member of a class are only accessible within the class even sub classes can also not be accessible so when I just summarize it everything let’s understand the simple way the summary of uh the public protected and private public member Public Access modifier can be accessed with the same class same packages even sub classes and other packages as well so when you’re talking about the protected so protected cannot be access with to other packages but it can be easily accessed with a sub packages sub uh sub classes and same classes as well private access modifier a private member can be accesses within a class only it cannot be accessed from the any other packages or same packages or or any other classes so we already discussed in the last video is that how can we make the um you know static method and how can we make the class method that is the way where we can just uh you know protect our our methods and and some variables so there is also one more topic is called as uh private variables that I’ll I’ll discuss in the practical way let me jump on the Practical implementation to discuss about that inbu attributes the last video we discuss about this instance function instance uh class function and static function so here uh we discuss in the details way and just try to access it some some variables and Method so you can see here when I just use it the object the object here FC FC is the object so when I just use this fscore uncore the dict uncore uncore obviously I have to use the dot do dict you can see here so whatever variable is present here the variable is uh the name actually the instance variable is showing only it’s not showing any kinds of uh the class variable so that is also here you can say it’s protected so so kind of the public private and protected is the category to achieve that category we have a different different uh topic is available so here uh so you can say the class variable class method and static variable static method is also one of the way to achieve the en encapsulation so you can see here when I just use the dict so here uh any any college name is not showing it’s showing only the name right so we have also I also Define some uh documentation so with the help of FC dot FC doore uncore yeah so we can also see the documentation as well so with the help of object we can easily find it out you know other things we can easily access it any kinds of documentation any variables or anything here so like I want to find it out what is the is it uh you know the main module is there or any other module is also there so underscore uncore module you can also check it okay sorry it’s not a DF it’s FC doore module so you can also say check that so I’m working with the same files that’s why it’s showing that U main is here I can also check that the classes as well FC doore class so yes it’s showing that my class name is a first class with the help of object I can find it out anything easier right so I can also check that uh you know there is the variable name is an variable name is name okay variable name is a name okay so I can also find it out has attribute is that attribute is available or not so object I have to Define it FC and name I’ll just pass it it’s saying that yes that attribute is available so I can find it out that variable get attribute I can just use it and pass the values as FC and uh uh what is the actual values of the name is showing that hurry so so you can see here so with the help of object I can find it out any information that I want to protect it okay so like uh a set attribute I can Define it set attribute so outside of the U class with the help of object I can also create one variables instance variable FC and I can Define it here uh any any variable name is like a ro number which is not there hope so which is not there uh yes there is no any role number yeah role number kind of variable is not there so I can make it role number and and Define it the role number is a one 12 one okay so I I set the one variable when I just check that the FC FC doore dict you can see here there is two variable is present previously it was only hurry now the role number is also present right so and and I can also delete it so FC dot FC sorry Del Del attribute delete attribute I just want to remove the FC have to pass it and just pass the role number okay and now it’s deleted hope so uh DF is not defined it’s FC and the next time when I just check this here so it’s showing only hurry it’s not showing other things so this way we can easily access any kinds of uh variables any kinds of methods we can easily access it in a continuation of encapsulation we we discuss about access mod fire where we discuss a public member we discuss a protected member we discuss the private member as well so here we discuss about a private variables how we can make it suppose if you have a class class name is uh College okay college and I Define The Constructor and here I Define the name is equal to uh Rahul so this this is the variable name that variable you can say is the instance variable okay so instead of name I’ll just use a self. name so that I can easily access it within a class and uh create a object object name is like um you know C is equal to college and when I just try to access it like a c do name so you can easily access it which is Rahul and here I just want to write it uh create one um object self dot college ID okay college ID I just want to write it IIT Bay 001 56 suppose this is the college ID is there and uh when I just try to access it the college ID we can easily access it right C do college ID so you can easily access it but what happened uh okay what happened if in case if I’m just writing here the double underscore so what will be happening you can’t access it here is showing that the college ID is uh the college object no attribute of college ID let me also use it under double underscore here still you can’t access it so that means this kind of Vari uh in case if you’re using the two underscore before the any variable you can’t access it but normally if you’re writing any variable a is equal to 5 it’s it can be accessible and print a yeah and if you just using a double underscore a and here if you’re using the double underscore a so that is also accessible here is not a issue but if you’re doing the same thing in your object oriented so it’s become a private variable private variable so private variable have a only only one way to find it out only one way to access that kind of variables which is you have to call the college so with the help of object you can’t access it so here when I just try to access only the name so you can easily access it but if I want to access the C doore uncore college ID so you can’t so the time you have to call the object object name is a college underscore College you have to write it then you can access it so the private variable cannot be accessed directly so again the encapsulation is the way encapsulation is is a techniques where we have a different different topic is available like private variable static method and static variable so that that topic will help you to achieve the encapsulation because in Absolution is a techniques to protect our variable and methods so let’s let’s discuss about the how data abstraction is working data abstraction and encapsulation are synonyms as data abstraction okay so you can just understand with this images so encapsulation is also protecting the method as a variable but abstraction is providing the complete restriction so that you can’t enter it so to re to reach abstraction we need need encapsulation so that means first you have to protect the variable as a method and then you can provide the complete Shield right so just abstraction is is totally give the Restriction okay so so here is the definition is also there let’s let me just read it so that you’ll get a better idea and after that definitely I will discuss about the Practical implementation substraction is used to hide the internal details and show only the functionalities abstracting something abstracting something means to give the names to things so that the name capture the basic idea of what a function or whole program does is give the just basic idea okay to achieve the abstraction so there is a two way so an abstraction abstract class can have both the normal method and Abstract method both can be present an abstract method yeah we cannot create an object of abstract class so how to achieve that abstraction let’s discuss about it so data abstraction let me just create uh the yeah heading data abstraction okay so data abstraction um let me create one a class the class name let me just write it here a computer okay computer and yeah inside a computer let me just Define one uh you know one method normal method is a processing okay and self is very very important and just write it the normal statement anything uh just pass okay so this is not abstract class or abstract method it’s not here so when we can have a abstract method normally whatever you writing here okay whatever you are writing here um print this is computer class okay and I can also write the object C is equal to computer so when you just uh call it C do processing and you can easily access it so now let me just create this this class as a abstract class so you have to import from ABC abstract Blaze class import uh let me just take the ABC Capital so which is the main class is there and Abstract method as well abstract method abstract method yeah so here I will just inherit the ABC so now now the computer become the abstract method so when I just here the abstract method is available okay and uh this class this uh computer become the abstract class but if I want to make the method so I have to use the decorator so abstract method so here so when you just make so when you just make this um processing as a abstract method and uh your class become become the completely abstract class so you here is saying that cannot Institute abstract class computer with abstract method processing you cannot use it okay so you can’t create object of any abstract class if when when we are calling the abstract class if you inherit from the ab ABC abstract Base Class and if you have a method which is the abstract method so that time we are we are calling it’s the abstract class an abstract method so if I want to just create any um any other you know I want to use it this is computer class I I just want to use it so I can also create a different um um different classes here let me just create a laptop okay simply laptop and this time I will inherit the computer so computer is inherit the abstract Base Class and laptop is inherit the computer and and simple I’ll just write it here the processing anything I can just use it now here what will be happen so here is kind of um overriding so because I just inherited that so overriding here just using self I’m just using it here and uh whatever things is there I’ll just pass it is high so instead of creating the object of a computer I will just create the object of a laptop so let me just comment it here lap L is equal to laptop L do processing when I just use the processing you’ll get high because it’s become completely inherited if it’s completely inherited the previous one will not be used okay but in case instead of processing if you have a processing one and if you want to inherit the then again is facing the same problem you cannot okay you cannot even not only the um not only the calling the methods so if you’re still running so you cannot create the object of the class the laptop class as well because laptop is inherited the a computer computer is a completely abstract class right because it’s inherited the abstract Base Class so here you cannot use it until unless you’re not overriding the abstract method so here I’m just overriding the abstract method now I can create object I can also call any method as well so this is the way to deal with any abstract class so again if you have any kinds of U uh method which you want to protect it you can just use abstract me abstract method with ABC abstract Base Class finally we reach the last topic of this entire python series that is multi- threading multi-threading is very very very important for a software development even um uh you’ll find it out the separate job for uh you know for multi- threading so even when you’re entering uh the multi- threading let’s first discuss about the multitasking how exactly it’s working because dayto day day-to-day life when you’re using the computer so different different task we are just doing it let’s say for example I’m just doing a task is a word processing and and sending some emails and doing web browser and uh our in virus is running so that entire thing is running on the operating system right and that operting system is is is on a CPU course so even so multi-threading is not only the software topic uh like if you are a programmer you should know that it’s not like that if if you’re using a computer the multitasking and multi- threading is running inside your computer so let’s let me first show you how exactly the multi trading and multitasking is running in your computer you can just go to the taskbar you uh shortcut keys control alt delete you’ll find it out the taskbar go there the taskbar will open here so in your computer it will be open and just go to the performance and let me just maximize it yeah you can see here uh yeah you can see I’m just running the 312 process with the threads so what exactly the threads thread is nothing but a lightweight process so I I’ll discuss in details let first understand that like if I’m just running the multiple process my computer is running the 312 process which handles the 177,000 1 lakh 73589 right and that how much core is there 10 core so core is nothing but how your whatever process you’re running is the Distributing in the different different core that is CPU core okay and every process have a different different threads that means small process is there inside one process for example you can go to the processes 312 processes running go to the processes you’ll find it out which 312 processes there so five is ongoing processes there five apps is running I just open the uh PowerPoint I open the taskbar WhatsApp Zoom is running so much things running is here and and another process is also running the background process because sometime you confuse that here is the 312 process where exactly is that see some background process is also there and other processes also consuming right so after uh the entire process is 312 is showing it here so let’s understand it like how trades is working threads is nothing but just a small process of the particular process it’s confusing let me show you how exactly is working let’s say for example I choose the uh normal things is is game okay in the game I choose the I just open one game so game is a one process okay game is one process but inside that the multiple process is running that is consu that is producing the sound that is Graphics that is U when a player is uh you know it’s a different different opponent is there the multiple prer is playing the games so kind of like the multiple Pro multiple small small processes running inside the game app your game process so simple here so what exactly the multitasking multitasking refer to the ability of operating system to perform a different task at the same time because here in the operating system I’m just running the multiple process at the same time right so as I said that uh when you’re going for a job so you’ll find it out the multi- threading is also very much required if you are entering the software development that can be the web development that can be the application development with a python not only the python if you are going with a Java that time is also required the multi-threading right so you can also search it on no.com I just took the screenshot here but yeah lots of job opening is there for multi-threading that is also required and uh the interviewer is asking the question right yeah so here I took the example is a word processor okay word processor one one example I just taking it here inside that so Graphics is there and responding to keystroke and grammatical check that is a small small process which is there inside a word processor right so that small small processor that small small process is called as a dats simple word what exactly the threads so thread is nothing but a lightweight process thread is a lightweight process which is independently flow up execution that means there is no dependent that when uh Graphics will complete then the cas keystroke will run no there is independently running so whenever you making the application so threading is playing the very very important role because we have to we have to achieve the independent iny right so here so there are two types of multitasking in operating system that is a process best and thir best right so what is a process best because the multiple threats running on the operating system simultaneously for example for example is listening the song and playing the game is is two different process running in the operating system but when you’re talking about the threats so thread is a single process consisting of the separate task right for example a FIFA game is a consisting of the multiple threads so one game is a consisting of multiple threads is there so now the question is what is threat even I already explain that thread is nothing but a lightweight process so inside the threads in inside inside the one process the multiple threats is there is this example is mentioned there so the question is where we can use it what is the purpose of thread when we required the threads is there so threads when we have a multiple task need to achieve you have multiple task and you want to independently running it so task don’t have interdependency right if I’m running the one particular function there is uh four function is there fun one and fun two and fun three and fun four okay so I so python is a procedural programming language and functional as well and objectoriented as well but usually is following the top to B bottom approach when the fun if in case if I call the first function second function third function fourth function accordingly it will run but there is no any relation between the function one to function two it can be independently run so in the time we required a mult the training so that is the mean of interdependency it should not be any kinds of interdependency between the two different function right so there is two way to create the threads in the Python programming language the first one is without creating a class directly with a function we can create it and with a class we can achieve the threads okay so there is the four things which is very very important to know about that how to perform the multi- threading task so run there is run method which is which method is entry point of the threads and start method which is start the thread when you call the run method it will start the trade and join method it will be uh wait for Threads to terminate it and is alive will check that your thread is still alive or not and get name get the get name will return the name of the threads so this five method will help you to perform the entire thre operation uh let’s take example suppose I have a two task the task number one read um read data from database and there is a 10 data I have to read it right and the second task I have um read um PDF file okay that is also 10 PDF I have so there is a two different task and uh this one is taking every every database every data is taking a 0.5 second that means it will taking okay 0.5 second one task will take 0.5 second one task will take so it will taking a 5 Second okay all right and the second one second one read the PDF so 0.3 second is taking so it will taking completely a 3 second okay so I’ll try to optimize it in this Pro this problem right so the complete if you if you’re running the entire task it will taking the completely 8 second I’ll try to reduce it to make it around U uh 5 Second okay let me take the four and this will be 4 second so total will be total will be 9 second great so let’s do the do the Practical implementation here def I’ll create one one uh function def um read data okay read data and simple I’ll just create of follow for I in range and yeah the 10 data I have to read it and print the normal statement read the data from database okay and uh I + 1 because it will start from zero right and let me also take the time import import time or I can yep and every time it will take time do slip 0.5 second 0.5 second I’m uh so every process is will taking a 0.5 second and then def read PDF for I in range 10 I will pass and time do sleep and 0.4 second and print the statement um read the data from uh PDF okay read the data from PDF and and then I plus one as well because it will start from zero all right great so yep I’ll just print it here start time strd start time is equal to uh time dot time I think time do time is there let me let me just print it time do time yeah so time. time it will starting time it will take and uh mhm start time and at the end when I just call it I’ll just call this function rate data and rate PDF okay and I will take it here the end time is equal to time. time time. time and uh process took time process time I can make it here end time minus start time okay so it will start the process so first it read the entire data from database and then uh the PDF will start and here it’s taking a 9 second why it’s taking the 9 second the reason behind that the reason behind that because the first one took the 5 Second and second one took the 4 second that is the reason it’s more than 9 second is taken here so how can I reduce it this time so we can use the multi-threading to reduce this particular time is here so there is a librar is called multi- threading from multi threading multi threading import I’m taking a everything like even I required here the thread so I’m taking the Trad here oh sorry uh better I can just take this libraries in the outside so that it will be oh sorry uh I can undo it yeah undo delete yeah here I can pass my library okay multi-threading spelling is wrong M ready okay it’s not a multi- Threading uh sorry it’s a Threading only sorry yeah threading import thread So currently whatever process I have it’s not inside the thread so I’ll try to make it the inside thread so so this one is not required this one is just taking the time this one I’ll just make it comment and I’ll make it a thread so T1 thread so inside a thread because there is no any class so you have to decide the target what is the target the target is uh read data the second one is T2 is equal to thread what is the target the target is read PDF and uh the simple one let’s start a T1 dot start uh start the U uh thread here t1. start and then t2. start when I start this two different threads so here the threads will run independently there is no relation between the read PDF and read data so the same time your data from the DAT reading data from database and reading the data from PDF will start the same time so you can save a lots of time is here you can sa then tar 4 second let me just run it oh what what’s the issues spelling is wrong seriously mhm d h r e a d hey it’s it’s correct oh okay spelling is wrong yeah sorry yeah so it started the time is started here the process time okay uh the problem is here it’s attached with um uh the completely this time is attached with our threads okay I have to also explain one more thing is here so there is always one thread is always active which called as a men thread so because of this because of this threading so this one is also considered as a Threading this one is also independently run this file right this is independently run this file in that situation what I have to do I have to just join it t1. join t2. join so what happen is here so T1 and T2 is joined it’s not joined with the men threate right so here this this entire this process this this two Lines line number 27 and 28 is not joined with T1 and T2 so T1 and T2 is running the independently so that is the reason you can see here it’s reading the PDF then database PDF database and sometimes the PDF two time as well the reason is taking only 2 second and the entire process is ending with 5 Second only previously it took a 9 second I save a 4 second so that means if you have the big process if you have a big process so and and imagine that imagine that uh currently I have only two process you have a 15 process and all the 15 process have independently running so what which process is taking more time inside that the other process can also be finished it so multi- threading is saving a lots of memory lots of time so that’s why it’s very very important for a software development so usually the software we are making with class class and object read data from database that it will take 10 second and the second one read PDF from read data from PDF yeah we can say read PDF files that is taking a 4 second there is a 10 files and every files is taking 0.4 second the total time is 9 second okay so I’ll try to create with the class here the multi-threading so simple uh class name is class of read data and uh make sure that if you’re if you’re using the multi trading so you have to inherit the thread so let me just use the prom threading import thread and from time UT C okay great so I have to import thread here okay all right and inside that you have to create a function yeah we can say method def run method okay run method self is very very important okay and after that give me a minute after that just we have to run the file for I in range and the 10 times and uh let’s apply the slip 0.5 second right this normal statement okay read data from database database right this is one threade I just created and the second one is class read PDF and thread colon def run and pass the self is here for I in range pass the values is 10 okay the same thing I’ll just use it here slip 0.4 second and print the statement read PDF data that’s PDF data all right and how it will be run just call create object of that particular thread T1 because the every class is already become the thread because it inherited from thread class is equal to read data okay so if you’re not using this a threat inheritance let me just show you okay let me just show you I’m not using inheritance of the thread and uh let’s create the object T2 do T2 is equal to read PDF so when I just run it and let’s run this file here T1 dot T1 dot run okay and t2. run and uh just just normally Define it here the timing okay start start time is equal to time dot okay time sleep and time let me just take both time and yeah just time you can just take it and uh at the last time this end time okay that is the end time and uh just print it here process time that is like uh end time and time minus start time okay so it will it will tell you like how much time it took to complete the entire process we know that here it will take uh the 9 second because the 5c first read data will take and the second one 4 second will take so yeah it’s took the 9 second yeah let me also just Define it the number which file is reading I + 1 because it’s starting from the zero so that’s why I’m just mentioning here the I + 1 great so let’s apply the inheritances here let’s apply the threading with inheritance uh um concept so we just inherit the thread and let me also inherit the thread so if you use the method is a run and uh you don’t need to call the run so now the entire process has become the complete thread right so this this entire classes become the thread this this one is a thread and this one is a thread so now I want to run it then t1. start that’s it t2. start that’s it now when you just start it the process will start again yeah so this one uh this print statement this is completely a separate threats that is the reason that is also being independent so that is it’s running first so let’s make it dependent there is if I’m asking that how many threads is running is here so there is a three thread is running the first one is read data second one is yeah we can say T1 T2 and the third one is men thread so men is always there so all menth is being independent so making the T1 and T2 is a dependent you can make it t1. join and t2. join so now you both will join and the men threate is independent so the line number 27 will be running dependently right when the T1 and T2 will finish then 20 line number 27 will run then you’ll find it out how much time it took it here the last time it took 9 second now it’s taking only a 5 Second so this is the beauty of multi-threading so let’s also discuss the other things um how many threats is there we can also check it and U uh yep so if if I’m just printing it here in in the next line I can just directly print it here print uh like a T1 do um um I can check it like is alive or not uh we can we can normally check it so it will tell you yes it’s it’s false because uh the process is end so it will tell you yes it’s a false so if you’re running inside that in inside that um uh threads like here if if I’m just after start if I’m just running so definitely give the answer is the the threads is running or not the T1 thread check all right 31 thread check it will check the true because the threads is running right so with the help of is alive we can check it the threads is running or not so we can also check the other things like um uh the active count okay so here when I just check it in between anywhere we can check check it here um number of threads we can check it number of thread so we can check it so simply we can just pass it here active count there is a method is called as active count okay so active count when I just run it it will tell you the number of threads is eight is running yeah like number threat is 8 is running because the complete active count is 8 is here okay and uh so the same time like here uh what is the thread name is I can also check that what is the exactly the thread name is here so at the same time I can also check it here the current thread dot get name okay current thread. getet name so we can also check it like which thread is running that uh particular line and here you can also check it right so when I just run it it will tell you okay so it’s showing that 32 3T like the thread number is showing that and the last one is a men thread so now here some somewhere like number of threads is there because the entire thread is not stopped that is the reason it’s showing that is a eight so when I just checking the outside how many threads is running outside here so it’s showing six so the six is running the two is not considered here so hope you understand how exactly this working right so active alive we can check that that particular thread is running or not how many uh active thread is there and what exactly the thread name is here you can easily check it with all the methods oh

By Amjad Izhar
Contact: amjad.izhar@gmail.com
https://amjadizhar.blog
Affiliate Disclosure: This blog may contain affiliate links, which means I may earn a small commission if you click on the link and make a purchase. This comes at no additional cost to you. I only recommend products or services that I believe will add value to my readers. Your support helps keep this blog running and allows me to continue providing you with quality content. Thank you for your support!

Leave a comment