Skip to content

Commit d5a2f2f

Browse files
authored
Merge pull request #30 from code-for-tomorrow/Citrus716-patch-6
Added number_mystery_1 solution
2 parents e4c5a98 + 2eb40ae commit d5a2f2f

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Number Mystery 1
2+
# Write a function called num_mystery that takes in 3 integers.
3+
# The function should calculate the sum of the 3 integers and
4+
# the difference between the largest integer and the smallest integer.
5+
# The function should return the product of these two integers you calculated.
6+
#
7+
# Hint: You may find it useful to use the max() and min() functions.
8+
#
9+
# Use the num_mystery function on 1, 2, 3 and print the result.
10+
# Use the num_mystery function on 5, 13, 7 and print the result.
11+
12+
13+
def num_mystery(first_int, second_int, third_int):
14+
# calculate the sum of the 3 numbers
15+
sum_of_three = first_int + second_int + third_int
16+
17+
# calculate the difference between the max and min
18+
largest = max(first_int, second_int, third_int)
19+
smallest = min(first_int, second_int, third_int)
20+
difference = largest - smallest
21+
22+
# return the product
23+
return sum_of_three * difference
24+
25+
26+
print(num_mystery(1, 2, 3)) # prints 12
27+
print(num_mystery(5, 13, 7)) # prints 200

0 commit comments

Comments
 (0)