Python Classroom Series – 27/Jul/2020

Python 3 intelligence about Numbers

  • What our Python3 knows/understands about numbers Preview
  • Python 3 has the following knowledge
    • Expression Operators: +,-,*,/,%,>>,** etc..
    • Built in functions: pow, abs, round, int, hex, bin etc..
  • We will explore this as we go along
  • For python 3 are variables names not places
  • When we use numbers we build expressions using variables and operators
x = 5
y = 6
z = x + y


  • What will python do if the operators are mixed Preview
  • What if you want to do addition first and then multiplication, then use parantesis () Preview
  • So lets try to speak with python to solve our simple intrest
    • Lets try in a shell Preview
    • create a file called as and in this file add some instructions with expressions.
    principal = 10000
    rate_of_intrest = 10
    time_in_years = 2
    simple_intrest = principal * rate_of_intrest * time_in_years /100
    • to execute this program. Open powershell/cmd/terminal
    python <path to your program>
    Preview Preview

Mixed Types are converted up

  • When python sees mixed types the result will be always the complex type Preview
  • But what will you do if you want the result to be simple type, then you need to tell python do conversions using built-in functions like int(), float() etc Preview

Leave a Comment

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

About learningthoughtsadmin