Change language

# Python | Min. / Max. The value in a floating point list of strings

|

Method: Using ` min () / max () + float () `
This problem can be solved with the ` min function ` or ` max ` in which we first convert strings to floating point, and then pass this logic to functions in the corresponding min / max function.

 ` # Python3 code to demonstrate how it works ` ` # Min. / Max. Value in floating point string list ` ` # using min () / max () + float () + generator `   ` # initialize lists ` ` test_list ` ` = ` ` [` ` ’4.5’ ` ` , ` ` ’7.8’ ` `, ` `’ 9.8’ ` `, ` ` ’10.3’ ` `] `   ` # print original list ` ` print ` ` (` ` "The original list is:" ` ` + ` ` str ` ` (test_list)) ` ` `  ` # Min. / Max. Value in floating point string list ` ` # using min () / max () + float () + generator ` ` res_min ` ` = ` ` min ` ` (` ` float ` ` (sub) ` ` for ` ` sub ` ` in ` ` test_list) ` ` res_max ` ` = ` ` max ` ` (` ` float ` ` (sub) ` ` for ` ` sub ` ` in ` ` test_list) ` ` `  ` # print result ` ` print ` ` (` `" The min value of list: "` ` + ` ` str ` ` ( res_min)) ` ` print ` ` (` ` "The max value of list: "` ` + ` ` str ` ` (res_max)) `

Output:

` The original list is: [’4.5’,’ 7.8’, ’9.8’,’ 10.3’] The min value of list: 4.5 The max value of list: 10.3 `

## Shop

Learn programming in R: courses

\$

Best Python online courses for 2022

\$

Best laptop for Fortnite

\$

Best laptop for Excel

\$

Best laptop for Solidworks

\$

Best laptop for Roblox

\$

Best computer for crypto mining

\$

Best laptop for Sims 4

\$

Latest questions

NUMPYNUMPY

Common xlabel/ylabel for matplotlib subplots

NUMPYNUMPY

How to specify multiple return types using type-hints

NUMPYNUMPY

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

NUMPYNUMPY

Flake8: Ignore specific warning for entire file

NUMPYNUMPY

glob exclude pattern

NUMPYNUMPY

How to avoid HTTP error 429 (Too Many Requests) python

NUMPYNUMPY

Python CSV error: line contains NULL byte

NUMPYNUMPY

csv.Error: iterator should return strings, not bytes

## Wiki

Python | How to copy data from one Excel sheet to another

Common xlabel/ylabel for matplotlib subplots

Check if one list is a subset of another in Python

How to specify multiple return types using type-hints

Printing words vertically in Python

Python Extract words from a given string

Cyclic redundancy check in Python

Finding mean, median, mode in Python without libraries