Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
Ad icon
Jobreceive.com for sale
Blogerwiki
Updated:
Yesterday at 8:55 PM
Post Your Vehicle for Sale — FREE! - https://libro.lk
Kalu_Puth
Updated:
Yesterday at 7:38 PM
ඔයාගෙ Assignment හෝ Thesis එක හරියට හදාගමු
ErMurazor
Updated:
Saturday at 10:52 PM
Ad icon
BlackWall V2ray servers
hu KANNA
Updated:
Sep 23, 2026
Peppa Pig Family Plush Toy Set – 5 Characters
anil1961
Updated:
Sep 19, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
Education
UoM Online Course 3 - Python Programming එක ඉවර කරපු අය...
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="SL MULTIMEDIA TUTORIAL" data-source="post: 27631055" data-attributes="member: 575597"><p>UoM Online Course 3 - Python Programming ඉවර කරපු අය...</p><p></p><p>course එක ඉවර කරපු කෙනෙක් ඉන්නවානම් කියන්න පුලුවන්ද Programming Assessment එකේ Code එක එන විදිහ Try කරලා බැලුවා .<img src="/styles/default/xenforo/smilies/default/sorry.gif" class="smilie" loading="lazy" alt=":sorry:" title="Sorry :sorry:" data-shortname=":sorry:" /><img class="smilie smilie--emoji" loading="lazy" alt="🥲" title="Smiling face with tear :smiling_face_with_tear:" src="https://cdn.jsdelivr.net/joypixels/assets/6.6/png/unicode/64/1f972.png" data-shortname=":smiling_face_with_tear:" /> කරගන්න බැරි නිසා help එකක් ඉල්ලලා බලන්න හිතුනේ..<img src="/styles/default/xenforo/smilies/default/rolleyes.gif" class="smilie" loading="lazy" alt=":rolleyes:" title="Rolleyes :rolleyes:" data-shortname=":rolleyes:" /></p><p></p><h3>Programming Assessment එක</h3><p></p><p>There are two online supermarkets which provide price of various products.</p><p></p><p>You need to write a program to acquire, extract and compare the price from these two suppliers, for a given product.</p><p></p><p>Example: Price of a coconut from the two different suppliers can be found in the following webpages.</p><p></p><p>laughs_coconut = '<a href="https://www.laugfssuper.com/index.php/coconut-105320.html" target="_blank">https://www.laugfssuper.com/index.php/coconut-105320.html</a>' (Please check the update note at the end of the question)</p><p>glomark_coconut = '<a href="https://glomark.lk/coconut/p/11624" target="_blank">https://glomark.lk/coconut/p/11624</a>'</p><p></p><p>The function def compare_prices(product_laughs,product_glomark) will take-in two similar products from two suppliers, and compare the prices to recommend you which option is cheaper on a given instance of time.</p><p></p><p>1. Visit the links in your web browser, and use the Inspect elements / View page source tools of the browser to understand the structure of the web pages given above.</p><p>2. Complete the compare_prices function which is pre-loaded in the answer box to acquire and extract the price values from two web pages.</p><p></p><p></p><p></p><p>When you submit your answer to be checked, be patient for a while (up to 20 seconds) until its been checked with multiple test cases.</p><p>Example expected output</p><p></p><p>Laughs COCONUT - Item#mr-2058 Rs.: 89.0</p><p>Glomark Coconut Rs.: 86.0</p><p>Glomark is cheaper: 3.0</p><p></p><p>Here are some more test cases for you to test in your own computer.</p><p></p><p>laughs_tissues = '<a href="https://www.laugfssuper.com/index.php/categories/household/flora-facial-tissues-2-x-160-box.html" target="_blank">https://www.laugfssuper.com/index.php/categories/household/flora-facial-tissues-2-x-160-box.html</a>'</p><p>glomark_tissues = '<a href="https://glomark.lk/flora-facial-tissues-160s/p/10470" target="_blank">https://glomark.lk/flora-facial-tissues-160s/p/10470</a>'</p><p>compare_prices(laughs_tissues,glomark_tissues)</p><p></p><p>laughs_bread = <a href="https://www.laugfssuper.com/index.php/crimson-bread-sliced-111452.html" target="_blank">https://www.laugfssuper.com/index.php/crimson-bread-sliced-111452.html</a>'</p><p>glomark_bread = '<a href="https://glomark.lk/top-crust-bread/p/13676" target="_blank">https://glomark.lk/top-crust-bread/p/13676</a>'</p><p>compare_prices(laughs_bread,glomark_bread)</p><p></p><p>**Update:Laugfs website seems to be slow and changing quite frequently. So a backup of the required web pages are available in the following links. Your answers will be validated against these pages.:</p><p></p><p><a href="https://scrape-sm1.github.io/site1/COCONUT%20market1super.html" target="_blank">https://scrape-sm1.github.io/site1/COCONUT market1super.html</a></p><p><a href="https://scrape-sm1.github.io/site1/FLORA%20FACIAL%20TISSUES%202%20X%20160%20BOX%20-%20HOUSEHOLD%20-%20Categories%20market1super.com.html" target="_blank">https://scrape-sm1.github.io/site1/... HOUSEHOLD - Categories market1super.com.html</a></p><p><a href="https://scrape-sm1.github.io/site1/COCA%20COLA%202L%20(PET)%20-%20BEVERAGES%20-%20Categories%20market1ssuper.com.html" target="_blank">https://scrape-sm1.github.io/site1/...BEVERAGES - Categories market1ssuper.com.html</a></p><p><a href="https://scrape-sm1.github.io/site1/Crimson%20Bread%20Sliced%20market1super.com.html" target="_blank">https://scrape-sm1.github.io/site1/Crimson Bread Sliced market1super.com.html</a></p><p></p><p>Stock Code eka <img src="/styles/default/xenforo/smilies/default/nerd.gif" class="smilie" loading="lazy" alt=":nerd:" title="Nerd :nerd:" data-shortname=":nerd:" /></p><p></p><p></p><p>[CODE=python]import requests</p><p>import json</p><p></p><p>import sys</p><p>sys.path.insert(0,'bs4.zip')</p><p>from bs4 import BeautifulSoup</p><p></p><p>#Imitate the Mozilla browser.</p><p>user_agent = {'User-agent': 'Mozilla/5.0'}</p><p></p><p></p><p>def compare_prices(product_laughs,product_glomark):</p><p> #TODO: Aquire the web pages which contain product Price</p><p></p><p> </p><p> </p><p> #TODO: LaughsSuper supermarket website provides the price in a span text.</p><p></p><p></p><p> #TODO: Glomark supermarket website provides the data in jason format in an inline script.</p><p> #You can use the json module to extract only the price</p><p> </p><p> </p><p> #TODO: Parse the values as floats, and print them.</p><p> </p><p> print('Laughs ',product_name_laughs,'Rs.: ' , price_laughs)</p><p> print('Glomark ',product_name_glomark,'Rs.: ' , price_glomark)</p><p> </p><p> if(price_laughs>price_glomark):</p><p> print('Glomark is cheaper Rs.:',price_laughs - price_glomark)</p><p> elif(price_laughs<price_glomark):</p><p> print('Laughs is cheaper Rs.:',price_glomark - price_laughs) </p><p> else:</p><p> print('Price is the same')[/CODE]</p></blockquote><p></p>
[QUOTE="SL MULTIMEDIA TUTORIAL, post: 27631055, member: 575597"] UoM Online Course 3 - Python Programming ඉවර කරපු අය... course එක ඉවර කරපු කෙනෙක් ඉන්නවානම් කියන්න පුලුවන්ද Programming Assessment එකේ Code එක එන විදිහ Try කරලා බැලුවා .:sorry:🥲 කරගන්න බැරි නිසා help එකක් ඉල්ලලා බලන්න හිතුනේ..:rolleyes: [HEADING=2]Programming Assessment එක[/HEADING] There are two online supermarkets which provide price of various products. You need to write a program to acquire, extract and compare the price from these two suppliers, for a given product. Example: Price of a coconut from the two different suppliers can be found in the following webpages. laughs_coconut = '[URL]https://www.laugfssuper.com/index.php/coconut-105320.html[/URL]' (Please check the update note at the end of the question) glomark_coconut = '[URL]https://glomark.lk/coconut/p/11624[/URL]' The function def compare_prices(product_laughs,product_glomark) will take-in two similar products from two suppliers, and compare the prices to recommend you which option is cheaper on a given instance of time. 1. Visit the links in your web browser, and use the Inspect elements / View page source tools of the browser to understand the structure of the web pages given above. 2. Complete the compare_prices function which is pre-loaded in the answer box to acquire and extract the price values from two web pages. When you submit your answer to be checked, be patient for a while (up to 20 seconds) until its been checked with multiple test cases. Example expected output Laughs COCONUT - Item#mr-2058 Rs.: 89.0 Glomark Coconut Rs.: 86.0 Glomark is cheaper: 3.0 Here are some more test cases for you to test in your own computer. laughs_tissues = '[URL]https://www.laugfssuper.com/index.php/categories/household/flora-facial-tissues-2-x-160-box.html[/URL]' glomark_tissues = '[URL]https://glomark.lk/flora-facial-tissues-160s/p/10470[/URL]' compare_prices(laughs_tissues,glomark_tissues) laughs_bread = [URL]https://www.laugfssuper.com/index.php/crimson-bread-sliced-111452.html[/URL]' glomark_bread = '[URL]https://glomark.lk/top-crust-bread/p/13676[/URL]' compare_prices(laughs_bread,glomark_bread) **Update:Laugfs website seems to be slow and changing quite frequently. So a backup of the required web pages are available in the following links. Your answers will be validated against these pages.: [URL='https://scrape-sm1.github.io/site1/COCONUT%20market1super.html']https://scrape-sm1.github.io/site1/COCONUT market1super.html[/URL] [URL='https://scrape-sm1.github.io/site1/FLORA%20FACIAL%20TISSUES%202%20X%20160%20BOX%20-%20HOUSEHOLD%20-%20Categories%20market1super.com.html']https://scrape-sm1.github.io/site1/... HOUSEHOLD - Categories market1super.com.html[/URL] [URL='https://scrape-sm1.github.io/site1/COCA%20COLA%202L%20(PET)%20-%20BEVERAGES%20-%20Categories%20market1ssuper.com.html']https://scrape-sm1.github.io/site1/...BEVERAGES - Categories market1ssuper.com.html[/URL] [URL='https://scrape-sm1.github.io/site1/Crimson%20Bread%20Sliced%20market1super.com.html']https://scrape-sm1.github.io/site1/Crimson Bread Sliced market1super.com.html[/URL] Stock Code eka :nerd: [CODE=python]import requests import json import sys sys.path.insert(0,'bs4.zip') from bs4 import BeautifulSoup #Imitate the Mozilla browser. user_agent = {'User-agent': 'Mozilla/5.0'} def compare_prices(product_laughs,product_glomark): #TODO: Aquire the web pages which contain product Price #TODO: LaughsSuper supermarket website provides the price in a span text. #TODO: Glomark supermarket website provides the data in jason format in an inline script. #You can use the json module to extract only the price #TODO: Parse the values as floats, and print them. print('Laughs ',product_name_laughs,'Rs.: ' , price_laughs) print('Glomark ',product_name_glomark,'Rs.: ' , price_glomark) if(price_laughs>price_glomark): print('Glomark is cheaper Rs.:',price_laughs - price_glomark) elif(price_laughs<price_glomark): print('Laughs is cheaper Rs.:',price_glomark - price_laughs) else: print('Price is the same')[/CODE] [/QUOTE]
Insert quotes…
Verification
Payakata winadi keeyak tibeda?
Post reply
Top
Bottom