Posts

Showing posts from February, 2013

22nd February 2013 - LPTHW - Learnings

1. EX21 : return value of one function can be taken as an argument for another function.

2.  EX24: Inside the function the variable is temporary, and when you return it then it can be assigned to a variable for later.

3. EX25: Typing help(module) will give us. NAME of the module, DESCRIPTION which is all the comments prior to the start of the program (if any) and FUNCTIONS which are all the functions in the program.

4. EX25: We can put the desciption of the function in between """ and it will print the description of the function when help(module) is issued, within the FUNCTIONS heading. These are called documentation comment.

5.  EX26: If a module is used in a script and it is absent, just import it.

21st February 2013 - LPTHW - Learnings

1. EX16 :  'w' is used with open command, which expilictly tells that file is being opened for writing purpose.

2. EX 17:   exists is a command which returns TRUE if a file exists basis on its name in a string as an arguement. It returns FALSE if not.

3. EX17 : To write a new text file on windows we use the type  command.

4. EX17 : File can be open and read on the same line of code.

5. EX18: *args asterisk args is just like argv, only that it is used for functions. It needs to be put inside brackets to work.

6. EX18: After the function has been defined and named, arguments passed in the bracket, the line ended with : colon, the indeting starts after that. In Python the indentation is 4 spaces.

7. E18: Function Checklist as given by Zed Shaw in Learning Python The Hard Way

Write out a function checklist for later exercises. Write these on an index card and keep it by you while you complete the rest of these exercises or until you feel you do not need it:
Did you start your fun…

20th February 2013 - LPTHW - Learnings

On Windows to learn about any command of Python, to be typed -: python -m pydoc COMMAND NAME. This gives out the description of the command. To quit Pydoc, press "q"..py files can be simply called scripts.Adding new feature to a Python program is done by using "import" feature. The real name of theirs is modules and not features though. It adds the feature you have called for to the program. Instead of keeping all the features always, Python gives the option to call them, whenever needed. It keeps the program small and also acts as documentation later."argv" is the argument variable, which contains the argument which we pass while running the program."unpacking"argv is basically taking everything that has been passed in the argv and assigning them to the variables mentioned in the program. Like - : script, first, second, third = argvThe other name of modules is libraries.If the user has to give the input on command line then argv is used, otherw…

19th Feb 2013 - LPTHW - Learnings

EX2 - "%" is modulus and not percentage. So its like X divided by J with Z remaining. So Z is the modulus. So if 4%3 is, 4 divided by 3 and the remainder left after that, which is 1.  EX2 - Order of Operation in Python follows - PEMDAS , which stands for Parentheses Exponents Multiplication Divison Addition Subtraction.EX4 - Always put space around operators, makes the code more legible to read and is the correct manner.EX5 - If a variable contains a string, using %r formatter instead of %d or %s puts the string under single quote while printing them.EX6 - The formatter %r is used only for deigging purpose and contains the raw data of the variable, the other two formatter %d and %s are used for displaying to the users.EX7 - Any code line greater than 80 characters in a single line in Python is not good code style.EX7 - If you put comma after a code line, the next code line is printed on the same line with a space in between the two.EX7 - The comments need not start with capi…