Posts

Showing posts from December 9, 2020

Python 3.6 - Points to remember

  Points to remember ·          A variable is any location in the computer’s memory which holds a value. ·          Python is memory efficient when dealing with variables as compared to other programming languages. ·          An identifier is a name given to a variable, function, class, list, tuple etc. Identifiers are used to identify things in Python. ·          Keywords are reserved words in Python that have some special meaning and they can only be used for pre-defined purpose. ·          Comments are always used to describe the features of a program and ignored by Python compiler and interpreter. ·          ‘#’ symbol is used to create a single line comment.    ·          Python does not recommend Triple double quotes (“””) or triple single quotes (‘’’) as multi line comment. ·          If triple double quotes (“””) or triple single quotes (‘’’) are written as the first statement of a class, function, module etc., then they are called Docstrings and can be used t

Python 3.5 - Constants and literals

Image
  Constants A constant is a variable whose value can never be changed during the execution of program. We know that, the value of a variable can be changed anytime in a program. But if the variable is a constant and if once we assigned a value to it, then its value can never be changed later in the program. In languages like C, C++ and Java, you may have worked with constants but Python does not have concept of constants. We cannot create constants in Python. But you can indicate a variable as constant by writing its name in all capital letters so that you will remember that it is a constant and I should not change the value of it. But again you can change its value. This is just so that you remember that it is a constant. You can indicate a variable as constant. For example – MAX_VALUE, PIE etc. can be treated as constants. age = 28 # a variable PIE = 3.14 # we indicate the variable as constant but we can change its value later  You can use a variable as constant when you th