Python Classroom Series – 27/Feb/2020

Programming Languages based on Typing

  • Static-Type:
    • Developers need to specify data type before using variables
    • Eg: C, C++, Java etc
  • Dynamic-Type:
    • Developers need not specify data type, data types are decided by interpreter/compiler depending on data passed to it.
    • Eg: Shell, Ruby, Python

Program1: Calculate compound intrest

  • Python program to calculate compound intrest
principle = 10000.0
time = 10
rate_of_intrest = 10
compound_intrest = principle * ( 1+(rate_of_intrest/100))**time
  • Getting one level deeper with the execution. Open Python shell and execute the above program line by line and also add few stuff in between every statement
    • Check value
    • Check type (type())
    • Check memory location (id())

Memory layout of the following statements

  • Initial Lines
time = 10
rate_of_intrest = tim


  • Lets make some changes
time = time + 1


  • Now lets execute
message = 'hello'


  • one more change
message = 'hi'


Learnings from above experiments

  • In python basic data types such as int, float, str, bool are immutable i.e. whenever you change value a new memory is allocated and variable will point to new memory location.


  • Two kinds of operators

    • Binary Operators
      • Require two operands
    • Unary Operators
      • Require one operand
  • Google ‘python operators’ and pick any page you want

  • Operators might change the behavior depending on type of data which we use or operate on

value = 5
value * 2
# 10

value = 'hi'
value * 2
# 'hihi'
  • Experiment with Arthimetic , Assignment and comparision operators from here

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About learningthoughtsadmin