Thursday, May 14, 2015

Python Class 109 - Kapil Sharma

1. while loop: Works till the time condition meet.

2. for loop: works for number of iterations.

3. function: Pre-fabricated code. 
    "def xyz(x): "

4. Class: It's a template of one or multi-functions features and variables.
    Classes can be inherit from super-class to child-class.
    First make class than make its objects to use it's resources.

5. Constructor: Special method in a class. As soon user create object.
    It executed it self, no need to call it.

6. Import: User can import python modules, by using import cmd.
    import xyz > xyz.abc()
    Also, any edit in the import module source file, user needs to,
    reload(xyz) cmd to update the import module in the source code.

7. dir(math) > help(math): This is the way to show help in details.

Monday, May 11, 2015

Python Class 108 - Kapil Sharma

Cheet Sheet: 

1. List = Arrays.

   List = ["One","Two","Three"];
   print List[2];

2. Tuple() = List, but its cannot be changed. (Unmutable)/xyz[2]


3. Sets = Are similar to list, un-ordered collection of unqiue elements.

   No, duplicates.

4. Dictionaries{} = Arrays. Un-order collections of key value pairs.

   dict = {"Key":"Value"}

5. __XYZ = Is declaring local variable by adding "__"


6. pop / remove: Both do the same thing.

   But implementation is different. In "pop" user needs
   to give index id: xyz.pop(1) / xyz.remove("abc")

7. xyz.find("abc"): Give the location index id of the text. 


8. "is": For same value, like one = two = [1,2,3] its true.


9. "in": For checking true values, "s" in "Kiwi" its false.


Python GitHub Repo: https://github.com/bornfreesoul/Python

Tuesday, January 20, 2015

Python Class 106 - Kapil Sharma

19) The continue statement - The continue statement is used to tell Python to skip the rest of the statements in the current loop block and to continue to the next iteration of the loop.

20) Defining a Function - Functions are reusable pieces of programs. They allow you to give a name to a block of statements and you can run that block using that name anywhere in your program and any number of times. This is known as calling the function. We have already used many built-in functions such as the ‘len and range’. Functions are defined using the def keyword. This is followed by an identifier name for the function followed by a pair of parentheses which may enclose some names of variables and the line ends with a colon.


21) Function Parameters - A function can take parameters which are just values you supply to the function so that the function can do something utilising those values. These parameters are just like variables except that the values of these variables are defined when we call the function and are not assigned values within the function itself.Parameters are specified within the pair of parentheses in the function definition, separated by commas. When we call the function, we supply the values in the same way. Note the terminology used - the names given in the function definition are called parameters whereas the values you supply in the function call are called arguments.


22) Local Variables - When you declare variables inside a function definition, they are not related in any way to other variables with the same names used outside the function i.e. variable names are local to the function. This is called the scope of the variable. All variables have the scope of the block they are declared in starting from the point of definition of the name.


23) Using the global statement - If you want to assign a value to a name defined outside the function, and then you have to tell Python that the name is not local, but it is global. We do this using the global statement. It is impossible to assign a value to a variable defined outside a function without the global statement.

You can use the values of such variables defined outside the function (assuming there is no variable with the same name within the function). However, this is not encouraged and should be avoided since it becomes unclear to the reader of the program as to where that variable's definition is. Using the global statement makes it amply clear that the variable is defined in an outer block.

24) Default Argument Values - For some functions, you may want to make some of its parameters as optional and use default values if the user does not want to provide values for such parameters. This is done with the help of default argument values. You can specify default argument values for parameters by following the parameter name in the function definition with the assignment operator (=) followed by the default value.

Note that the default argument value should be a constant. More precisely, the default argument value should be immutable - this is explained in detail in later chapters. For now, just remember this.

25) Keyword Arguments - If you have some functions with many parameters and you want to specify only some of them, then you can give values for such parameters by naming them - this is called keyword arguments - we use the name (keyword) instead of the position (which we have been using all along) to specify the arguments to the function.


26) There are two advantages - one, using the function is easier since we do not need to worry about the order of the arguments. Two, we can give values to only those parameters which we want, provided that the other parameters have default argument values.


27) The return statement - The return statement is used to return from a function i.e. break out of the function. We can optionally return a value from the function as well.


28) DocStrings - Python has a nifty feature called documentation strings which is usually referred to by its shorter name docstrings. DocStrings are an important tool that you should make use of since it helps to document the program better and makes it more easy to understand.


GitHub: https://github.com/bornfreesoul/Python/blob/master/FiveBox

Monday, January 19, 2015

Python Class 105 - Kapil Sharma

Python Information Cheat Sheet:

1) python –V   or  python –version  #This shows the current installed python version.

2) pip freeze will output a list of installed packages and their versions.

3) pip install django  #This will install django framework.
 pip install django –upgrade #For Django upgrade.

4) Literal Constants - An example of a literal constant is a number like 5, 1.23, 9.25e-3 or a string like 'This is a string' or "It's a string!". It is called a literal because it is literal - you use its value literally.

5) Numbers - In Python are of four types - integers, long integers, floating point and complex numbers.

6) Strings - A string is a sequence of characters. Strings are basically just a bunch of words.

7) Variables - Their value can vary i.e. you can store anything using a variable. 

8) Identifier Naming - Variables are examples of identifiers. Identifiers are names given to identify something.

9) Data Types - Variables can hold values of different types called data types. The basic types are numbers and strings.

10) Objects - Python refers to anything used in a program as an object. 

11) Logical and Physical Lines - A physical line is what you see when you write the program. A logical line is what Python sees as a single statement. Python implicitly assumes that each physical line corresponds to a logical line.

12) Indentation - Actually, whitespace at the beginning of the line is important. This is called indentation. Use a single tab.

13) Operators - Operators are functionality that do something and can be represented by symbols.

14) Operator Precedence – PMDAS order by which math operation executed.

15) The if statement - The if statement is used to check a condition and if the condition is true, we run a block of statements (called the if-block), else we process another block of statements (called the else-block). The else clause is optional.

16) The while statement - The while statement allows you to repeatedly execute a block of statements as long as a condition is true. A while statement is an example of what is called a looping statement. A while statement can have an optional else clause. 

17) The for loop - The for..in statement is another looping statement which iterates over a sequence of objects i.e. go through each item in a sequence. 

18) The break statement - The break statement is used to break out of a loop statement i.e. stop the execution of a looping statement, even if the loop condition has not become False or the sequence of items has been completely iterated over. An important note is that if you break out of a for or while loop, any corresponding loop else block is not executed.

19) The continue statement - The continue statement is used to tell Python to skip the rest of the statements in the current loop block and to continue to the next iteration of the loop.

GitHub: 
https://github.com/bornfreesoul/Python/blob/master/BasicOne

Blockchain: 101 (By - Kapil Sharma)

 https://testing-mines.blogspot.com/2021/10/blockchain-101-by-kapil-sharma.html Blockchain through the following attributes: Distributed:  T...