Skip to content

Commit 60401ed

Browse files
authored
Week 1 Assignments complete.
1 parent 122fdd4 commit 60401ed

File tree

13 files changed

+120
-0
lines changed

13 files changed

+120
-0
lines changed

Assessment/WK1/breakeven.jpg

103 KB
Loading

Assessment/WK1/breakeven.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# calculate break even point for business
2+
3+
# Params
4+
dbl_cost = 20.00
5+
dbl_sale = 40.00
6+
dbl_fixed_costs = 50000.00
7+
8+
# Calculate profit
9+
dbl_profit = dbl_sale - dbl_cost
10+
11+
# Get sale count to meet fixed costs
12+
int_BE_sales = int( dbl_fixed_costs / dbl_profit )
13+
14+
# check if there is a residual amount and if so increase the min qty
15+
# by one as you can't sell a fraction of a product
16+
if ( ( dbl_profit * int_BE_sales ) < dbl_fixed_costs ) :
17+
int_BE_sales +=1
18+
19+
# Output the results
20+
print ( "Welcome to the Widget Factory break even calculator" )
21+
print ( "-" * 55 )
22+
print( f'Widgets cost £{dbl_cost:.2f} and sell for £{dbl_sale:.2f}')
23+
print( f'We make a profit of {dbl_profit:.2f} per widget.' )
24+
print( f'Our fixed costs are £{dbl_fixed_costs:.2f}.' )
25+
print( f'Therefore we need to sell {int_BE_sales} items to break even.')

Assessment/WK1/cans_of_paint.jpg

184 KB
Loading

Assessment/WK1/cans_of_paint.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Calculate paint coverage and can box amounts.
2+
3+
# import packages
4+
import math
5+
6+
# params
7+
fl_coverage = 5.1 # m2 of wall
8+
# I'm using a dictionary as an array of dimensions, I mused on a list or a tuple too, but went for dict for clarity
9+
t_can_dims = { "Diameter": 15, "Height" : 30 } # cm
10+
t_box_dims = { "Length": 0.60, "Width": 0.30, "Height": 0.35 } # meters (I assume).
11+
t_hall_dims = { "Length": 40, "Width": 30, "Height": 3.4 } # meters
12+
13+
# ASSUMPTIONS
14+
# The hall has no doors
15+
# The hall has no windows
16+
# The floor and ceiling aren't being painted
17+
18+
# Calculate amount of paint required
19+
# ( 2 x length + 2 x width ) * height
20+
int_hall_wall_area = ( (( t_hall_dims["Length"] * 2 ) + (t_hall_dims["Width"] * 2)) * t_hall_dims["Height"] )
21+
int_cans_required = math.ceil ( int_hall_wall_area / fl_coverage )
22+
t_cans_per_box = { "ByLength" : math.floor ( t_box_dims["Length"] / ( t_can_dims["Diameter"] / 100 ) ),
23+
"ByWidth" : math.floor ( t_box_dims["Width"] / ( t_can_dims["Diameter"] / 100 ) ),
24+
"ByHeight" : math.floor ( t_box_dims["Height"] / ( t_can_dims["Height"] / 100 ) )
25+
}
26+
int_cans_per_box = t_cans_per_box["ByWidth"] * t_cans_per_box["ByLength"] * t_cans_per_box["ByHeight"]
27+
int_full_boxes = math.floor ( int_cans_required / int_cans_per_box )
28+
int_loose_cans = int_cans_required % int_cans_per_box
29+
30+
print ( 'Welcome to the Shaggy Dog Paint calculator')
31+
print ( '-' * 42 )
32+
print ( f'Using paint cans with diameter {t_can_dims["Diameter"]}cm and height {t_can_dims["Height"]}cm providing coverage of {fl_coverage}m2.')
33+
print ( f'Painting a hall with length {t_hall_dims["Length"]}m, width {t_hall_dims["Width"]}m and height {t_hall_dims["Height"]}m.')
34+
print ( f'This will require {int_cans_required} cans of paint.')
35+
print ( f'Supplying {int_cans_per_box} cans per box this will require {int_full_boxes} boxes and {int_loose_cans} loose cans.')

Assessment/WK1/datatypes.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
a.A company’s profit
2+
Decimal - Because this allows for the correct level of precision for
3+
4+
b.A person’s weight
5+
It depends on what unit of measure you're using to weigh the individual.
6+
If KG or LB: Float would work due to the decimal values.
7+
If ST & LB: 1 String or 2 Integers due to the need to store 2 values.
8+
9+
c.A book title
10+
String - It's a text value that can contain the widest range of characters.
11+
12+
d.Average rainfall in September
13+
Float - Because this allows for decimal numeric values to be recorded.
14+
15+
e.Number of runs scored by a cricketer
16+
Integer - A numeric value with no need to a decimal component.
17+
18+
f.A telephone number, including area code
19+
String - Because it makes formatting and storing the numbers far safer than a numerical variable type.
20+
21+
g.A dress size
22+
Depends on the sizing scheme.
23+
If its a numerical scheme, (8, 10, 12), then an integer will work.
24+
If its a text based scheme, (S, M, L), then a string will be required.

Assessment/WK1/debug.jpg

51.4 KB
Loading

Assessment/WK1/debug.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# exercise to debug code
2+
name = "John Smith" # remove one character
3+
occupation = "Student" # replace one character
4+
location = 'Stoke-on-Trent' # replace one character
5+
activity_level = "moderate" # replace one character (too many spaces)
6+
7+
print("My name is", name) #add one character
8+
print("I am a student in " + location) # no errors in this line
9+
age = 21 # remove a character
10+
11+
print("I am " + str(age) + " years of age with a", activity_level, "activity level")
12+
# add one character and replace one character

Assessment/WK1/hello_world.jpg

10.1 KB
Loading

Assessment/WK1/hello_world.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# output Hello World
2+
print("Hello World")
3+
print("Welcome to Python")

Assessment/WK1/simple_math.jpg

24.6 KB
Loading

0 commit comments

Comments
 (0)