Below you will find programming exercises that we would like you to undertake. The goal is to demonstrate your thinking and your ability to reason around problems.
Answer as much as you can and please send your responses in a zip file with your functions and tests. You may be asked to explain your reasoning.
Hints and tips:
Write a function that, when given an int, prints a triangle like the one below
>>> print_triangle(size=6)
*
**
***
****
*****
******
>>> print_triangle(size=3)
*
**
***
>>> print_triangle(size=0)
>>> print_triangle(size=-4)
****
***
**
*
Write a function that, when given a triangle, returns its size.
The function should ignore empty lines.
>>> first_triangle = """
*
**
***
****
*****
******
*******
"""
>>> read_triangle(first_triangle)
Triangle size: 7
>>> second_triangle = """
**
*
"""
>>> read_triangle(second_triangle)
Triangle size: -2
>>> third_triangle = ""
>>> read_triangle(third_triangle)
Triangle size: 0
>>> not_a_triangle = """
***
***
"""
>>> read_triangle(not_a_triangle)
Shape is not a triangle
Write a function that, given a list, returns the sum of its three largest items.
>>> sum_three_largest_items([2, 8, -56, 100, 7])
115
Write a function that, given a list, returns the sum of its three largest absolute value items.
>>> sum_three_largest_absolute_value_items([2, 8, -56, 100, 7])
52
Write a function that, given a game of RPS7, determines the winner.
The function should accept the seven keyword arguments rock, fire, water, air, sponge, scissors, paper, as booleans.
Read more about RPS7 here: http://www.umop.com/rps7.htm
>>> winner_rps7(rock=true, fire=true)
rock
>>> winner_rps7(water=true, sponge=true)
sponge
>>> winner_rps7(water=true, air=true, paper=true)
Error: invalid arguments
>>> winner_rps7(water=true, air=true, paper=false)
air
Write a function that, given a large map of a field with rocks (represented with “o”) draws the largest square possible on the map.
Note: if several squares are possible, draw the one to the top left.
>>> map_of_field = """
--------------------------
-----o-----o----------o---
-o------o------o-------o--
--------o---o--o---o--o---
---o--o-------o-o---------
---o----------------------
----------------------o---
---o------------o---------
-----o-----o--o--o--o----
-------o-----------o------
"""
>>> largest_square(map_of_field)
--------------------------
-----o-----o----------o---
-o------o------o-------o--
--------o---o--o---o--o---
---o--oxxxxx--o-o---------
---o---xxxxx--------------
-------xxxxx----------o---
---o---xxxxx----o---------
-----o-xxxxxo--o--o--o----
-------o-----------o------
A patient phones in and asks for your advice. He recently visited a friend in their home and they had dinner together. That was 5 days ago.
This morning he felt tired and had a headache when waking up. As he was getting some water he noticed that his puppy relieved herself in a corner at some point throughout the night. Unusually, he could not smell anything. However, the cleaning products made him cough and he has not stopped coughing for four hours now.
He is worried he breathed in some cleaning product and that he should visit a clinic to get help.
A patient comes into the clinic, with a heavy limp. She tells you that she fell over during a rugby game and hurt her right ankle.
She is worried it might be broken.
You ask the patient to sit down, ask for consent to examine her ankle, and palpate (touch) around the ankle. The patient does not react, or report any pain, except when you feel alongside the achilles tendon.
You are able to trace the bone and the space where the tendon sits offers no resistance.
In a consultation with a 58 year old woman, she presents a black skin lump with uneven edges. She reports that it appeared about two months ago and has been growing. A week ago she noticed that it bled and oozed a clear liquid.
You ask her about her previous medical history. There is nothing remarkable. She reports moving from Australia in her early 20s. Since coming to the UK she has been careful to apply plenty of sunscreen whenever she has gone outside. She has also eaten well and exercised regularly.
Please write the logic for taking a patient history where the patient presents with symptoms where the diagnosis is likely to be one of the following:
Include any appropriate tests, management and referrals, and any red flags they should consider.
You can use a structure such as the following, or write structured English, or pseudocode.