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)
import csv
ReplyDeleteimport 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 ']'