Posts

Building blocks of Python: Indentation and statement

Image
4.  Indentations Unlike other programming languages, Python uses indentations to define a block of code A code block (body of a function, loop etc) starts with indentation and ends with the first unindented line. The amount of indentation is up to the user, but it must be consistent Generally four whitespaces are used for indentation and is preferred over tabs Leading whitespaces (spaces and tabs) at the beginning of a logical line is used to compute the indentation level of the line, which in turn is used to determine the grouping of statements. Indentation is a good way to keep the code readable 5. Python Statement Instructions that a Python interpreter can execute are called statements. For example, a = 1 is an assignment statement. if statement, for statement, while statement etc. are other kinds of statements which will be discussed later. Difference between statement and function Difference between statement and function

Building Blocks of Python: Comments

Image
 Building Blocks of Python 3. Comments Comments in Python are used to convey the ides behind the code  For single line comment: Use '#' in front of the line For multiple line comment: triple single quotes ('''   '''') or  triple double quotes ("""   """) Docstring Ref : https://www.datacamp.com/community/tutorials/docstrings-python It is a short form of Document string Used to define what a function or class does Docstrings are similar in spirit to commenting, but they are enhanced, more logical, and useful version of commenting. Docstrings act as documentation for the class, module, and packages. On the other hand, Comments are mainly used to explain non-obvious portions of the code and can be useful for comments on Fixing bugs and tasks that are needed to be done. Docstrings are represented with closing & opening quotes while comments start with a # at the beginning. Note that comments can not be accessed with the ...

Building Blocks of Python: Identifiers

Image
  Building Blocks of Python: 2. Identifiers An identifier is a name given given to entities like class, functions, variables, etc. It helps to differentiate one entity from another Rules for writing identifiers: Identifiers can be a combination of                              a. letters in lowercase (a to z), or                              b. letters in uppercase (A to z), or                              c. digits (0 to 9), or                              d. an underscore (_)             2. An identifier cannot start with a digit          3. Cannot use keywords as identifiers   ...

Building Blocks of Python: Keywords

Image
  Building blocks of Python 1. Python Keyword 2. Identifiers 3. Comments in Python 4. Python Indentation 5. Python Statement One of the most basic command used in Python is print command: 1. Python Keywords Python has a set of keywords that are reserved words that cannot be used as variable names, function names, or any other identifiers. Must be spelled exactly as they are written There are 35 keywords in Python 3.8.8 There were 33 keywords in Python 3.6 The list of keywords is as follows 1. False: Boolean value, result of comparison operations 2. None: Represents a null value 3. True; Boolean value, result of the comparison operation 4. and: a logical operator; boolean operator for and operation 5. as: to create alias 6. assert: for debugging 7. async: always used in couroutine function body. It’s used with asyncio module and await keywords. [ refer to: https://www.askpython.com/python/python-keywords and https://www.infoworld.com/article/3454442/get-started-with-a...

Beginning with Python

I am a dentist, switching to data science. This switch has been a journey in itself and I am still moving forward. I would like to start this blog with my learning journey of Python. This is technically the first language I am learning in a structured manner and feel that I can begin my path on blogging with it. Python is a programming language. It is so far, considered to be a language closest to English, thus easy to understand. However, despite being easy, it has high level data structure and has an effective approach to object-oriented programming. Platforms used for Python distribution are Anaconda and Google Colab Anaconda toolkit is an open source and easy to use. Anaconda uses local storage and can be subscribed for cloud services as well. Jupyter notebook is mostly used for Python and it is launched on your default browser.  On the contrary, Google Colab is completely cloud based. The extensions for Python notebooks is .ipynb