forked from denisecase/datafun-01-getting-started
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bonus1_solomon_stevens.py
70 lines (50 loc) · 2.18 KB
/
bonus1_solomon_stevens.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
"""
Purpose: Calculate basic statistics on three numbers.
Author: Solomon Stevens
This scrip uses the built-in function round().
When we install Python, it comes with the Python standard library.
Nearly all scripts will import at least one module from the standard library.
We can install additional, third-party modules using pip.
We'll do that later.
All scripts in this repository use only the standard library.
@ uses statistics module for descriptive stats
"""
# ----------------- INSTRUCTOR GENERATED CODE -----------------
# Use this handy logger to document your work automatically
# import setup_logger function from instructor-generated module
from util_logger import setup_logger
# setup the logger using the current file name (a built-in variable)
logger, logname = setup_logger(__file__)
# ----------------- END INSTRUCTOR GENERATED CODE -----------------
# Import statistics from Python Standard Library
import statistics
# Get three numbers from user from the user - input result is always a string
# Use \n to add a blank new line to the terminal before we ask for input
num1 = input("\nEnter the first number: ")
num2 = input("\nEnter the second number: ")
num3 = input("\nEnter the third number: ")
# Convert the inputs to a integer values
int_num1 = int(num1)
int_num2 = int(num2)
int_num3 = int(num3)
num_list = [int_num1, int_num2, int_num3]
# Calculate basic statistics on these three numbers
# -> sum
total_sum = int_num1 + int_num2 + int_num3
# -> average
average_value = statistics.mean(num_list)
# --> Round average to 2 decimal places
average_value = round(average_value, 2)
# -> product
total_product = int_num1 * int_num2 * int_num3
# -> min
lowest_value = min(int_num1, int_num2, int_num3)
# -> max
highest_value = max(int_num1, int_num2, int_num3)
# Log the results
logger.info(f"The numbers you selected were {int_num1}, {int_num2}, and {int_num3}.")
logger.info(f"1. The SUM of these numbers is {total_sum}")
logger.info(f"2. The AVERAGE of these numbers is {average_value}")
logger.info(f"3. The PRODUCT of these numbers is {total_product}")
logger.info(f"4. The MINIMUM of these numbers is {lowest_value}")
logger.info(f"5. The MAXIMUM of these numbers is {highest_value}")