min()
The min()
function finds the minimum value of a string
, list
, tuple
, dictionary
or multiple values passed as a parameter. Let's find the minimum values of the string
, list
, tuple
and dictionary
created prior.
PYTHON
1print("The minimum value of string is", min(string))
2print("The minimum value of list is", min(Flowers_List))
3print("The minimum value of tuple is", min(Number_Tuple))
4print("The minimum value of dictionary is", min(General_Dictionary))
The output will be:
PYTHON
1The minimum value of string is M
2The minimum value of list is Daisy
3The minimum value of tuple is one
4The minimum value of dictionary is key1
Now if we pass multiple values in min()
function as parameter, let's see what happens
PYTHON
1min(1, 4, -5, 6, -10, 0)
The output will be:
PYTHON
1-10
xxxxxxxxxx
15
string = "Minahil"
Flowers_List = ["Tulip", "Jasmine", "Rose", "Lili", "Daisy"]
Number_Tuple = ("one", "two", "three")
General_Dictionary = {
"key1": "value1",
"key2": "value2",
"key3": "value3",
"key4": "value4",
}
print("The minimum value of string is", min(string))
print("The minimum value of list is", min(Flowers_List))
print("The minimum value of tuple is", min(Number_Tuple))
print("The minimum value of dictionary is", min(General_Dictionary))
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment