Conditional Logic and Data Science¶
In data science, you’ll often use statistics to describe and summarize your data. Here, we begin by introducing several such descriptive statistics in Python, including:
• minimum—the smallest value in a collection of values. • maximum—the largest value in a collection of values. • range—the range of values from the minimum to the maximum.
Remember, measures of dispersion, such as range, help determine how spread out values are.
Let’s show how to determine the minimum of three values with a Python program. The following code prompts for and inputs three values, uses if statements to determine the minimum value, then displays it.
number1 = int(input('Enter first integer: ')) number2 = int(input('Enter second integer: ')) number3 = int(input('Enter third integer: ')) minimum = number1 if number2 < minimum: minimum = number2 if number3 < minimum: minimum = number3 print('Minimum value is', minimum)