From the course: Learning the Python 3 Standard Library
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Min and max - Python Tutorial
From the course: Learning the Python 3 Standard Library
Min and max
- [Instructor] So what do we know about minimum and maximum? Well, minimum is usually the least item or the lowest item and maximum is usually the greatest item. So say you're given zero, five, eight while your lowest item would be zero and your greatest eight. Well, we can do this exact thing with Python. So let's say we want to calculate the winner of a given game. While we can create a variable called playerOneScore, and say it's 10, and then, we'll create another variable called playerTwo Score and set that equal to four. Now to calculate which player actually won, say this is golf, and so, we want the minimum score. We could do print minimum playerOneScore and then playerTwoScore. And when we run this, we see the least score and the minimum score is four. And that is associated with playerTwo. And so, playerTwo would be the winner. You can do this with any number of numbers, and so, you could do minimum of say…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
Logical operators: And, or, not6m 6s
-
(Locked)
Comparison operators4m 1s
-
(Locked)
Calculating length3m 45s
-
(Locked)
Range and list3m 18s
-
(Locked)
Min and max3m 54s
-
(Locked)
Rounding, absolute value, and exponents6m 8s
-
(Locked)
Sorted function6m 39s
-
(Locked)
Type functions5m 34s
-
(Locked)
Solution: Count valid numbers1m 13s
-
-
-
-
-