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 

Python | Min. / Max. The value in a floating point list of strings Python functions: Questions

Python | Min. / Max. The value in a floating point list of strings String Variables: Questions

Shop

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

$

Best laptop for Zoom

$499

Best laptop for Minecraft

$590

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers

News

Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method