Python and my journey

 Python : My daily course

Day 1: Computational Thinking Computational thinking 1. Decomposition: Breaking down bigger problem to smaller ones 2. Pattern recognition : finding similar prolems and applying already solved questions 3. Abstraction: Identify the root cause and remove other factors 4. Algorithm design: We come out with step by step processes to solve the problem. Psedo code Flowcharts Blaise Pascal invented the first mechanical calculating machine, John Von Nuemann: Modern Computer Day 2: software anatomy 1.UI (User interface)- Client/ Front-end : Contains the Presentation logic(C,C++,HTML, CSS, JavaScript, Node, etc. If it is a mobile app, technologies such as Ionic, Swift, or Kotlin ) 2.Database: Stores the data(MySQL) 3. Server- Backend: The end( PHP, Ruby, Python, and Go) Day3: Programming Programming is the set of instructions given to a computer to follow using a language it understands Python uses interpreter Day 4: Python basics + Addition - Subtraction * Multiplication / Division ** Power % Remainder Power of precedence Parenthesis Power Multiplication Addition Left to Right Day 5:Bit more Complex = 5+10j 1.is operator and id() can be used to find the memory address 2.type() for the variable type 3.value for the value in the variable Mutability : value can change( list, set, dict ) Immutable : value cannot change ( int, float, bool, str, tuple ) Day 6:Seperator >>print(1,2,3,4, sep='-') 1-2-3-4 >>print(1,2,3,4, sep='*', end='#') 1*2*3*4# Day7: Functions A function is a block of organized ,reusable code used for a single related action. Gives Better Modularity High degree of code reuse Built in: print(), min(), max() Made up: what ever you want Syntax def functionname(): fucntionstuff return #((indentation required)) Docstrings The Docstrings are supposed to provide detailed documentation for a function. It can be composed of the function’s purpose, its list of arguments, its return values and any other information that the programmer thinks important to mention. A docstring is added as the first statement in the body of a Python function. These need to be within quotation marks and the recommended convention to use the triple-quotes (in double quotes) as “”” docstring “”” . These can be on a single line or be multi lined as well. If the docstring fits on a single line both the opening and closing quotes should be on the same line. We can also view the docstrings of built-in and user defined functions using the __doc___ attribute. def calc(quantity, price): """Returns the product of quantity and price""" return quantity*price print (calc.__doc__) Returns the prodcut of quantity and price >>> Day8: Errors 1. Syntax errors 2. Runtime errors NameError,IndexError,TypeError,ValueError,ImportError 3. Logical errors Try/Except : Just like in VB in SLIR Day 9 : Files open files using open() function -Gives a file handle which gives file operations like read,write example: fhandle = open("myfile.txt","r") We can use the read function too if you want to (read())

Comments

Popular Posts