5 BE C

2. A store charges ? 120 per item if you bu^ less than 10 items. If you buy between 10 and 99 items, the cost is ? 100 per item. If you buy 100 or more items, the cost is ^ 70 per item. Write a program that asks the user how many items they are buying and prints the total cost.

# Code items = int(input(‘Enter number of items : ‘)) if items < 10: cost = 120*items elif items < 100: cost = 100*items else: cost = 70*items print('Total Cost is Rs', cost)

2. A store charges ? 120 per item if you bu^ less than 10 items. If you buy between 10 and 99 items, the cost is ? 100 per item. If you buy 100 or more items, the cost is ^ 70 per item. Write a program that asks the user how many items they are buying and prints the total cost. Read More »

1. Write a Python script that asks the user to enter a length in centimetres. If the user enters a negative length, the program should tell the user that the entry is invalid. Otherwise, the program should convert the length to inches and print out the result. There are 2.54 centimetres in an inch.

# Code cm = int(input(‘Enter length in cm : ‘)) if cm < 0: print(‘invalid entry’) else: print(cm/2.54, ‘inches’)

1. Write a Python script that asks the user to enter a length in centimetres. If the user enters a negative length, the program should tell the user that the entry is invalid. Otherwise, the program should convert the length to inches and print out the result. There are 2.54 centimetres in an inch. Read More »