Skip to content

Commit

Permalink
Initial programming assessment
Browse files Browse the repository at this point in the history
  • Loading branch information
cab938 committed Sep 7, 2019
1 parent 734136f commit 5822d8c
Showing 1 changed file with 229 additions and 0 deletions.
229 changes: 229 additions & 0 deletions 190909_programming_assessment.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Programming Assessment\n",
"Answer the following questions using Python. You have 30 minutes, try and write something for each question. **There are no grades associated with this assessment**, this is only to help me better understand people's skills coming into this course! However, there is a prize for the best set of solutions. And this is all open network, go look things up if you need to, just no direct asking these questions or communication amongst yourselves."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Question 1\n",
"What is the difference between a class and an object?"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Question 2\n",
"Calculate the average of the list `[34,53,21,32,56,323,23,53,62,34,12,64,85,35,87,95]`"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Question 3\n",
"Write a function called `is_palindrome` which takes in one parameter as a string and returns `True` if the string is a palindrome and `False` otherwise. A palindrome is a string which is the same backwards as it is forwards, e.g. radar, wakaw, madam"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Question 4\n",
"Update the function to `is_any_palindrome` to also be able to take in any integer or floating point value and treat them the same (ignoring the decimal place in the case of floats). E.g. 12721 would be a palindrome."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Question 5\n",
"Fix the following code."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"classroom1=[\"Ollie\",\"Raven\",\"Jameson\",\"Puppy\",\"Sparky\",\"Blue\",\"Prince\",\"Sydney\",\"Ella\",\"Jake\",\"Gucci\",\"Lola\"]\n",
"classroom2=[\"Shiner\",\"Thor\",\"Bentley\",\"Raven\",\"Cody\",\"Piper\",\"Lexi\",\"Raven\",\"Astro\",\"Oreo\",\"Lucky\",\"Lucy\"]\n",
"\n",
"conflicts=[]\n",
"def detect_class_conflict(1, 2):\n",
" '''Returns the names of people who are in both classes and thus have a time conflict\n",
" '''\n",
" for name in range(0,len(1)):\n",
" for another in range(0,len(2))\n",
" if 1[name]==2[another]:\n",
" conflicts.append(name)\n",
" return conflicts\n",
"\n",
"detect_class_conflict(classroom1, classroom2)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Question 6\n",
"Generate a list of all even numbers up to 10000"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Question 7\n",
"Write a function called `whole_divisions` which takes two required parameters, `lower` and `upper` which represent two bounds as positive numbers (where `lower <= upper`), and an optional third parameter `divisor`, and returns a list of all numbers between (but not including) the two bounds which are exactly dividable by divisor. If divisor is not provided use a divisor of 2.\n",
"\n",
"`whole_divisions(3,9)` should return `[4, 6, 8]`\n",
"\n",
"`whole_divisions(2,10)` should return `[4, 6, 8]`\n",
"\n",
"`whole_divisions(3,9,divisor=3)` should return `[6]`"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Question 8\n",
"Write some code which downloads the wikipedia page on saskatchewn at `https://en.wikipedia.org/wiki/Saskatchewan` and prints out the capital city (you can see it listed on the right hand side of the page)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Question 9\n",
"\n",
"Imagine you are creating a list of all possible usernames from aaa, aab, aac, etc. through to zzz. How would you do that using the code below? Can you do it by adding only one line?"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import string\n",
"string.ascii_lowercase\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Question 10\n",
"Given the code `source_dict={1:10, 2:20, 3:30, 4:40}`, turn this into a dictionary where all of the keys are strings and all of the values associate with those keys are twice the current value. E.g. the output dictionary should be `{'1': 20, '2': 40, '3': 60, '4': 80}`."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"source_dict={1:10, 2:20, 3:30, 4:40}\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

0 comments on commit 5822d8c

Please sign in to comment.