Congratulations. You have been selected for the second round in the Bletchley application process. In this test, we ask you to complete two Python assignments. One asks for your general knowledge of the Python syntax. The other one asks for a bit of knowledge on numpy and vectors. Remember: Using google is okay!. We don't expect you to know everything by heart, we just want to make sure you can solve a problem somehow.
You can run all code that is required for this assignment on either Microsoft Azure Notebooks or by installing Python and all required libraries yourself from Anaconda.
Write a program which will find all numbers divisible by 17 but not a divisible of 5, between 1337 and 2412 inclusively. For example 1343 is divisible by 17 and not by 5 so it should be added. 2040 is divisible by 17 and by five so it should not be added.
How many numbers fit the specifications?
What is the sum of the numbers?
You can complete this assignment without any third party library. Consider using:
In [ ]:
# Define function
In [ ]:
# Print out number of found answers
In [ ]:
# Print out sum of found numbers
Import numpy. Create two vectors containing the numbers 0 to 23 inclusively in order. 0,1,2,3,4... etc.
What is the inner product (dot product) of the two vectors?
Now multiply the two vectors element wise. What is the seventh element of the new vector?
Consider using:
Remember, indexes start counting at zero.
In [ ]:
# import numpy
In [ ]:
# create vectors
In [ ]:
# Calculate and print dot product
In [ ]:
# Calculate element wise multiplication
# Print the 7th element