{"id":171,"date":"2020-09-26T12:56:30","date_gmt":"2020-09-26T12:56:30","guid":{"rendered":"https:\/\/dft.wiki\/?p=171"},"modified":"2021-03-16T13:29:35","modified_gmt":"2021-03-16T13:29:35","slug":"working-with-lists","status":"publish","type":"post","link":"https:\/\/dft.wiki\/?p=171","title":{"rendered":"Working with Lists in Python"},"content":{"rendered":"<p>Lists and Arrays are a very powerful type of variable that can store big volumes of data. After storing, the data can be easily manipulated by native functions, as sorting, counting appending, etc.<\/p>\n<p>The program bellow input data into the lists and then it use the data:<\/p>\n<pre>fruit = []<br \/>initialstock = []<br \/>sold = []<br \/>instock = []<br \/>fruit.append(input(\"Enter the name of the 1st fruit: \"))<br \/>fruit.append(input(\"Enter the name of the 2nd fruit: \"))<br \/>print()<br \/>initialstock.append(input(\"Enter the amount of kg for \"+fruit[0]+\": \"))<br \/>initialstock.append(input(\"Enter the amount of kg for \"+fruit[1]+\": \"))<br \/>print()<br \/>sold.append(input(\"Enter the Kg that are sold for \"+fruit[0]+\": \"))<br \/>sold.append(input(\"Enter the Kg that are sold for \"+fruit[1]+\": \"))<br \/>print()<br \/>instock.append(float(initialstock[0]) - float(sold[0]))<br \/>instock.append(float(initialstock[1]) - float(sold[1]))<br \/>print(\"%-30s %15s %15s\" % (\"Fruit\", fruit[0], fruit[1]))<br \/>print(\"%-30s %15.2f %15.2f\" % (\"Initial Stock - Kg\", float(initialstock[0]), float(initialstock[1])))<br \/>print(\"%-30s %15.2f %15.2f\" % (\"Sold - Kg\", float(sold[0]), float(sold[1])))<br \/>print(\"%-30s %15.2f %15.2f\" % (\"In Stocl - Kg\", float(instock[0]), float(instock[1])))<\/pre>\n<p>Copy, paste, and run this code to get the output shown below:<\/p>\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" class=\"wp-image-133\" src=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2020\/09\/image-5-1.png\" alt=\"\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Lists and Arrays are a very powerful type of variable that can store big volumes [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-171","post","type-post","status-publish","format-standard","hentry","category-programming"],"_links":{"self":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/171","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=171"}],"version-history":[{"count":8,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/171\/revisions"}],"predecessor-version":[{"id":1007,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/171\/revisions\/1007"}],"wp:attachment":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=171"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=171"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=171"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}