Listing 04-08: Category x Price

##############################################################################
# Python From Scratch
# Autor: Nilo Ney Coutinho Menezes
# Editora Novatec (c) 2010-2024
# Site: https://pythonfromscratch.com
#
# File: listing\chapter 04\04.08 - Category x Price.py
# Description: Category x Price
##############################################################################

1 category = int(input("Enter the product category:"))
2 if category == 1:
3      price = 10
4  else:
5      if category == 2:
6          price = 18
7      else:
8          if category == 3:
9              price = 23
10         else:
11             if category = 4:
12                 price = 26
13             else:
14                 if category == 5:
15                     price = 31
16                 else:
17                      print("Invalid category, enter a value between 1 and 5!")
18                     price = 0
19 print(f"Product price is: ${price:6.2f}")
Click here to download the file