I have a task where I must ***calculate the price of a basket*** while being given an external txt file with one price on each line like so: ``` 1.25 3.75 1.70 2.30 1.10 ``` and an external csv file with an item number and quantity (in that order) per line, like so: ``` 1,3 2,1 0,1 ``` The instruction is to prompt the user for each file, one at a time, then "***Calculate the price of the basket by summing each price multiplied by quantity"*** then printing the total. Having not been shown how to do arithmetic between external files after having read them, as well as specifically choosing a certain value in a position in one to perform it with, I'm not sure how to go about this. I have the base format of my code, as shown below, but beyond this it's like I stated, not sure what's next def main(): prices = input('Price File? ') print() baskets = input('Basket File? ') print() print('Basket will cost $' + ) if __name__ == '__main__': main()
I have a task where I must ***calculate the price of a basket*** while being given an external txt file with one price on each line like so:
```
1.25
3.75
1.70
2.30
1.10
```
and an external csv file with an item number and quantity (in that order) per line, like so:
```
1,3
2,1
0,1
```
The instruction is to prompt the user for each file, one at a time, then "***Calculate the price of the basket by summing each price multiplied by quantity"*** then printing the total.
Having not been shown how to do arithmetic between external files after having read them, as well as specifically choosing a certain value in a position in one to perform it with, I'm not sure how to go about this. I have the base format of my code, as shown below, but beyond this it's like I stated, not sure what's next
def main():
prices = input('Price File? ')
print()
baskets = input('Basket File? ')
print()
print('Basket will cost $'
+ )
if __name__ == '__main__':
main()
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 3 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)