0

how can create a code that listing the lowest price between two items

i am currently trying to create a programme that is capable of listing the lowest price between two items

22nd Aug 2018, 10:56 PM
ali
ali - avatar
3 Antworten
+ 8
Have you already begun your attempt on this program? If so, what have you got so far? In what programming language? How would the prices be stored? You have to be more specific.
22nd Aug 2018, 11:28 PM
Eduardo Petry
Eduardo Petry - avatar
+ 8
ali You can use a list to store prices of products in different markets and then find the smallest price with the `min` function. For example, with apples: # list containing prices of apples in different markets apple_prices = [1.99, 2.15, 1.95, 2.05, 1.85, 1.9, 2] # smallest price apple_min_price = min(apple_prices) # output: 1.85 print(apple_min_price) Resources to learn Python: https://www.sololearn.com/Discuss/437973/?ref=app https://www.sololearn.com/Discuss/1466244/?ref=app
23rd Aug 2018, 5:05 PM
Eduardo Petry
Eduardo Petry - avatar
+ 1
I have started writing it in python 3 but i only know how to assign values to the items, i dont know how to store the prices. i am currently looking online for formulas that would help allow the program to find the lowest price and add it to a list. ex of code: apple from market A price = 1.99 apple from market B price =1.95 if apple from market A price > apple from market B price: print("market B is cheaper") else: print("market A is cheaper") i know that i didn't include any formula, cause i don't have any, but this is what i have come up with so far. by the way do you know of any other places to learn python?
23rd Aug 2018, 6:30 AM
ali
ali - avatar