prices = {'apple': 0.75, 'egg': 0.50}
cart = {
'apple': 1,
'egg': 6
}
bill = sum(prices[item] * cart[item]
for item in cart)
print(f'I have to pay {bill:.2f}')
#> I have to pay 3.75Python Notes
Preface
NoteAbout
This is my Python notes (Last updated: 2025-05-11)
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.