Giter VIP home page Giter VIP logo

dsc-chi-warmup-array_aggregation's Introduction

Import tests

from tests import MultiplyTest, ArrayTest

For today's warmup, please solve the following code problems:

Exercise #1

The function below doesn't work. Figure out why and fix the code.

def multiply(a, b):
    a * b

Run the cell below to see if your code is successful!

evaluate = MultiplyTest()
evaluate.run(multiply)

Once you have passed the above tests, run the cell below to test your code on 100 randomly generated tests

evaluate.run(multiply, random=True)

Extra Credit: Instead of summing individual numbers, see if you can edit your multiply function so that it is broadcasting two arrays.

This version of your function should receive two inputs:

  1. An array containing three numbers
  2. An array containing three numbers

The output of the array should contain three numbers

[1,2,3] * [4,5,6] ---> [4,10,18]```


```python
def multiply(arr1, arr2):
    pass
evaluate.run(multiply, random=True, broadcast=True)

Exercise #2

Please fill in the code for the array_plus_array function below.

The function should have two inputs:

  1. An array containing at least three numbers
  2. An array containing at least three numbers

The function should return a single digit that sums all digits within both arrays

def array_plus_array(arr1, arr2):
    pass

Run the following cell to test your function!

evaluate = ArrayTest()
evaluate.run(array_plus_array)

Once you have managed to pass all of the tests, run the cell above to see if you function can pass 100 randomly generated tests!

evaluate.run(array_plus_array, random=True)

Extra Credit: Instead of summing all numbers in your array, see if you can edit the array_plus_array function so that it is broadcasting two arrays.

[1,2,3] + [4,5,6] ----> [5,7,9]```


```python
def array_plus_array(arr1, arr2):
    pass

Test your code by running the cell below

evaluate = ArrayTest()
evaluate.run(array_plus_array, random=True, broadcast=True)

dsc-chi-warmup-array_aggregation's People

Contributors

joelsewhere avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.