fb pixel

Introduction to Python

  • Profound Academy

    • Status
      • 1
        Input and Output
      • 2
        Variables and Integer Arithmetic
      • 3
        Conditional Operators
      • 4
        Advanced Conditions - Nesting
      • 5
        Types and Variables
      • 6
        Strings
      • 7
        Lists
      • 8
        For Loops
      • 9
        While Loops
      • 10
        continue, break, while...else
      • 11
        String and List methods
      • 12
        Nested Loops
      • 13
        List Comprehension
      • 14
        Tuples and Sets
      • 15
        dict
      • 16
        Functions
      • 17
        Functions 2
      • 18
        Lambda and higher-order functions
      • 19
        Files

  • Advanced arithmetic

    Some of the more complex formulas require some operations to be performed first, and others afterward. In math, we prioritize them with parentheses.
    In this formula, a + b - c needs to be performed before the multiplication, and the subtraction of 2 needs to happen in the end.
    In math, the top priority is given to parentheses, then exponentiation, then multiplication or division, then addition or subtraction.
    Python follows the same priority order. The order of priorities for arithmetic operations is:
    1. Parentheses
    1. Exponentiation
    1. Multiplication and division
    1. Addition and subtraction
     
    Knowing this, your task is to calculate a complex formula, given a and b integers as an input:
    Print the value of y in the output.
    Input
    Output
    3 4
    16
     
    To check your solution you need to sign in
    Sign in to continue