Saturday, July 4, 2020

Жишээ №3: Бичвэрийг хэлбэржүүлэх өргөн

# Хэлбэржүүлэн хэвлэх жишээ
width = int(input("Хэлбэржүүлэх өргөнийг оруул: "))
price_with = 10
item_width = width - price_with
header_format = '%-*s%*s'
format = '%-*s%*.2f'
print('=' * width)
print(header_format % (item_width, 'Item', price_with, 'Price'))
print('-' * width)
print(format % (item_width, 'Apples', price_with, 0.4))
print(format % (item_width, 'Pears', price_with, 0.5))
print(format % (item_width, 'Cantaloupes', price_with, 1.92))
print(format % (item_width, 'Prunes (4 lbs)', price_with, 12))
print('=' * width)




No comments:

Post a Comment