Skip to main content

Python Sales Management By Nishad TK


import re
class shop:
    def __init__(self):
        self.stock=[]
        self.sales=0
        self.purchase=0

        
    def addStock(self):
        name=raw_input("Enter the product name")
        while not re.match(re.compile(r'[a-zA-Z]+'),name):
                       name=raw_input("Invalid product name , Please try again")
        price=raw_input("Enter the product price")
        while not re.match(re.compile(r'[0-9]+'),price):
                       price=raw_input("Invalid product price , Please try again")
        quantity=raw_input("Enter the product quantity")
        while not re.match(re.compile(r'[0-9]+'),quantity):
                       quantity=raw_input("Invalid product quantity , Please try again")
        ele=[name,price,quantity]
        self.stock.append(ele)

        
    def sales(self,product):
        for i in range(0,len(self.stock)):
            if re.match(product[0],self.stock[i][0]):
                self.stock[i][2]=int(self.stock[i][0])-int(product[2])
                flag=True
        if flag!=True:
            return False

        
    def purchase(self,product):
        for i in range(0,len(self.stock)):
            if re.match(product[0],self.stock[i][0]):
                self.stock[i][2]=int(self.stock[i][0])+int(product[2])
                flag=True
        if flag!=True:
            self.stock.append(product)


class customer:
    consumerno=0
    def __init__():
        cid=consumerno
        consumerno+=1
        name=raw_input("Enter the Consumer name")
        while not re.match(re.compile(r'[a-zA-Z]+'),name):
            name=raw_input("Invalid name , Please try again")
        phone=raw_input("Enter the consumer phone")
        while not re.match(re.compile(r'[0-9]+'),phone):
            phone=raw_input("Invalid  phone , Please try again")
        self.purchases=[]
        self.phone=phone
        self.name=name
                       
    def purchase(self,product):
        self.purchases.append(product)

while True:
    menu="""Choose an operation
    1.Add Stock
    2.Create Consumer
    3.Purchase
    4.Sell
    5.View Consumers
    6.View Purchases
    7.View Sales
    8.Exit\n"""
    ch=str(raw_input(menu))
    while not re.match(re.compile(r'[1-8]'),ch):
        ch=str(raw_input("Invalid choice , Try Again:"))
    if ch=='8':
        break
    else:
        switch(ch)

Comments

  1. import csv
    import math
    a=[]
    xvalues,yvalues=[],[]
    x=0
    y=0

    name=raw_input("\tEnter the CSV file Name :\n")
    with open(name) as cfile:
    reader = csv.reader(cfile)
    for row in reader:
    a.append(row)


    def next_point(length,angle) :

    y1 = int(length) * math.sin(math.radians(int(angle)))
    x1 = int(length) * math.cos(math.radians(int(angle)))

    return x1,y1


    for i in range (0,len(a)-1) :
    for j in range (0,1) :
    nexty,nextx=next_point(a[i][3],a[i][1])
    if(a[i][0]=='S' and a[i][2]=='E') :
    x+=nextx
    y-=nexty
    elif(a[i][0]=='N' and a[i][2]=='E' ) :
    x+=nextx
    y+=nexty
    elif(a[i][0]=='S' and a[i][2]=='W') :
    x-=nextx
    y-=nexty
    elif(a[i][0]=='N' and a[i][2]=='W') :
    x-=nextx
    y+=nexty
    xvalues.append(x)
    yvalues.append(y)
    break
    print '[',
    for i in range (0,1) :
    for j in range(0,len(xvalues)) :
    print '(',xvalues[j],',',yvalues[j],')',"\n",
    print ']'









    ReplyDelete

Post a Comment

Popular posts from this blog

JavaScript:Magic Square

<html> <head> <title> Game:MagicalSquare. </title> </head> <style> table{ border-style: solid; border-color: white; border-width: 2px; width: 30%; height: 25%; text-align: center; padding-top: 20px; margin-top: 5px; padding-bottom: 20px; background-color:#00edff; } input[type=text]{ width:60px; height:60px; border: solid #063; border-radius:20px; font-size:16px; text-align:center; background-color:#55edff; color:white; } body{ border: solid #063; border-radius:20px; width=30%; height:70%; color:white; background-color:gray; } h2{ margin-top: 10px; border-color: white; border-width: 1px; border-style: solid; width: 30%; height: 40px; padding-top: 10px;; } div{ width:30%; height:12%; border-style:solid; border-color:white; border-width:2px; margin-top:5px; } input[type=button]:hover, input[type=button]:active { background-color: red; } input[type=button] {

Python Game By Nishad TK

from random import randint import re class game: def __init__(self): self.no_of_guesses =0 self.rabbit=0 self.portuga=0 self.inp=0 self.secret_no=self.rand() def addRabbit(self): self.rabbit+=1 def addPortuga(self): self.portuga+=1 def addGuess(self): self.no_of_guesses+=1 def rand(self): unique=[] while not (len(unique)>3): ran=[] for i in range(0,9): no=(randint(0,9)) ran.append(no) for j in range(0,9): if ran[j] not in unique: unique.append(ran[j]) return str(unique[0])+str(unique[1])+str(unique[2])+str(unique[3]) def checkDupe(self,inc): flag=0 for i in range(0,4): x=inc[:i]+inc[i+1:] if inc[i] in x: flag+=1 if flag==0: return False else: return True def play(se

JavaScript: Interactive Login form Using Cookie

Interactive Login form Using Cookie Good day guys,               Today I am here to have a discussion regarding a small program for Beginners with JavaScript and CSS. Even though it's a small program. I hope it will be pretty useful to everyone. First of all, let's have a look at what we are going to make: A screenshot from the latest version of Firefox. We can see that the page has a simple but beautiful user interface.I have accomplished this using simple HTML and CSS.Now , I would like describe the HTML in a few steps so that it can make this tutorial readable and easy to understand. Step 1 We have to make some containers to wrap the HTML elements(the text inputs , buttons etc.) so that it will be easy to manage.Here I use <div> tag to make the containers here.I have used three <div> elments which the first one contains the other two where the second one contains the username TextInput , Password the Heading and the Image.The third one ho