Skip to content
Snippets Groups Projects
Select Git revision
  • c999b8edfea06cf6209bd283d50c01b13ec7b00d
  • main default protected
2 results

obscure_1.py

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    homework1.py 871 B
    import numpy as np
    
    a = 245
    def reverse_list(mylist): #!f
        """
        Given a list 'mylist' returns a list consisting of the same elements in reverse order. E.g.
        reverse_list([1,2,3]) should return [3,2,1] (as a list).
        """
        z = 23234
        return list(reversed(mylist))
    
    def add(a,b): #!f
        """ Given two numbers `a` and `b` this function should simply return their sum:
        > add(a,b) = a+b
        Hints:
            * Remember basic arithmetics!
        """
        x = 234
        return a+b
    
    def foo(): #!f
        """ Comment.   """
        bar()
    
    def bar(): #!f
        return -1
    
    def linear_regression_weights(X, y): #!f
        weights = np.linalg.solve(X.T @ X, X.T @ y)
        return weights
    
    def linear_predict(X, w): #!f
        y = X @ w
        return y
    
    if __name__ == "__main__":
        print(f"Your result of 2 + 2 = {add(2,2)}")
        print(f"Reversing a small list", reverse_list([2,3,5,7]))