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

  • Too many arguments

    Keyword arguments are very useful in big projects. It’s especially recommended to use keyword arguments for functions that have many (3+) arguments.
    Yet, sometimes one might have confusing situations when dealing with both positional and keyword arguments. A company has developed software and they’ve written the following code, but they can’t easily run it and ask for your help.
    What will be the output of the following program?
    def print_gift(name, price, size):
    	print(f'{name} - $${price} of size {size}')
    
    print_gift('Lego', 100, price=200, size='3x4')
    To check your solution you need to sign in
    Sign in to continue