Product Sale Problem in Python

In this class, we write a program for Product Sale Problem in Python.

For Complete YouTube Video: Click Here

Product Sale Problem

All these examples. Will help you a lot in improving your coding skill.

Read the question try to solve it on your own before you check for a solution.

The reader should have the basics of python. To solve these problems. Click here.

Q1) A company digicomparts manufactures 52 types of unique products for laptop and desktop computers.

It manufactures ten types of laptop products and 42 types of desktop products.

Each product manufactured by the company had unique id’s from a-z and A-Z.

The laptop products have product id’s (a,e,i,o,u,A,E,I,O,U).

The rest of the product id’s are assigned to desktop products.

The company manager wishes to find the sales data for desktop products.

Input: Integer N. This number shows the number of product id’s considered from the sales data.

A string of the last N product id’s sold given as input.

Output: Count the number of desktop products sold.

Example:

Input: 8

ajklAeqQ

Output: 6

Logic

All the laptop product ids are taken in a list [“a”,”e”,”i”,”o”,u”,”A”,”E”,”I”,”O”,”U”].

Take the input string and loop on the string, and take each character from the string.

Each character is taken. Suppose the character is in the list of laptop ids. Do not increment the count.

Otherwise, increment the count.

Program

list1=["a","e","i","o","u","A","E","I","O","U"]
count=0
N=int(input("enter the number > 0---"))
string=input("enter the last N products sold")
list2=list(string)
print(list2)
for j in list2:
    if j not in list1:
        count+=1
print(count)