= {'apple': 0.75, 'egg': 0.50}
prices = {
cart 'apple': 1,
'egg': 6
}
= sum(prices[item] * cart[item]
bill for item in cart)
print(f'I have to pay {bill:.2f}')
#> I have to pay 3.75
Python Notes
Preface
About
This is my Python notes
I am an R user who is learning Python. I’m building my reference for Python. Also, It has some R code as well.
Warning
Note that this is a work in progress book, so the content is imperfect and subject to change.
Last updated: 2023-10-07