© 2019 BrainStemSchool.com

December 13, 2016

December 9, 2016

December 7, 2016

Please reload

Math (built-in)

December 7, 2016

 

https://youtu.be/xQAax3rL92o

 

Basic Math in Python works as you expect it will:

 

+ adds

- subtracts

* multiplies

/ divides

x**y raises x to the exponent y

( ) work like they should

% modulo - gives remainder of division

 

Also works as expected

PEMDAS:

 

  1. Parentheses

  2. Exponents (or unary operators)

  3. Multiplication and Division

  4. Addition and Subtraction

  5. Left to Right

 

3*(4+5) is not the same as (3*4)+5, as you’d expect.

 

Don’t forget that you have to use * to multiply

For instance, in math: 3(4+5) is fine… in programming, you need 3*(4+5)

 

Use math in any expression where a numeric is expected.

 

Share on Facebook
Share on Twitter
Please reload

Please reload

Recent Posts
Tags