Professional Documents
Culture Documents
Tradex Cs Project MF
Tradex Cs Project MF
Tradex Cs Project MF
2019-2020
1. OVERVIEW OF PYTHON -1
2. SYNOPSES/SUMMARY -2
3. REQUIREMENTS -3
4. DICTIONARIES -4
5. BUILT IN FUNCTIONS -5
6. SOURCE CODE -6
7. OUTPUT - 26
8. CONCLUSION - 31
9. FUTURE ENHANCEMENT - 32
10. BIBLIOGRAPHY - 33
OVERVIEW OF PYTHON :
− You can actually sit at a Python prompt and interact with the interpreter
directly to write your programs.
1
SYNOPSIS / SUMMARY:
−Items can be placed on sale just like any other online trading app and
moreover there is complete information of the seller stored in a dictionary so
that it would be useful for the buyer.
−Sellers can sell different products which would leave a diversified amount of
choice for the buyers.
−People can write their reviews and even change them so that others would
have an idea about TRADEX.
−There is an inbuilt admin account for logging in and it stays secured with a
password.
−10% of each sale goes to the admin and 90% goes to the seller.
2
REQUIREMENTS :
HARDWARE :
Processors: Intel Atom® processor or Intel® Core™ i3 processor
Disk space: 1 GB
For developing web applications, Back-end services, and other types of
applications, you can do the job with a Single Core 1.0 Ghz, 64Mb Graphics
Card, 1Gb of Ram and 40Gb, using a graphical Operating System like
Lubuntu (Lightweight Ubuntu, which works fine).
SOFTWARE :
Operating systems: Windows* 7 or later, macOS, and Linux
Python version: 3.6.5 (64 bit)
Project size: 400KB
3
DICTIONARIES :
Dictionaries are containers that associate keys to values. this is, in a way,
similar to lists, you must remember index value of an element from the list, but
with the case of dictionaries, you’ll have to know the key to find the element in
the dictionaries.
Dictionary holds a pair of values, one being the Key and the other
corresponding pair element being its Key: value.
users{} : This is the main dictionary in the project which stores all the details of
the buyers and sellers and is supported/nested by various keys and values.
l_username: Key for users{ } which stores logged in usernames and l_password
is the value for each username which is logged in.
r_username: Key for users{ } which stores a registered username and helps the
user to log in to their account and has r_password , the registered password as
its value.
4
BUILT IN FUNCTIONS :
5
SOURCE CODE :
import time
import random
import math
users={}
used_item_ids=()
exit_program=False
login_status=False
def Login_Register():
global l_username,login_status
print('\n')
l_r=None
while l_r!='3':
print('1.Login\n2.Register\n3.Back to Homepage')
l_r=input("Choose an option:")
clear()
if l_r=='1':
print('\nLOGIN PAGE:\n')
print('\n\n.................LOGIN SUCCESSFUL................')
login_status=True
time.sleep(3)
6
clear()
break
else:
time.sleep(3)
clear()
elif l_r=='2':
print('\nREGISTRATION PAGE:\n')
r_username=input("Enter a username:")
if r_username in users:
clear()
else:
r_pass1=input('Enter a password:')
if r_pass1!=r_pass2:
time.sleep(3)
clear()
else:
if len(r_phno)!=10:
time.sleep(3)
clear()
7
else:
print('\n\t\t\t\tEmail id is invalid.')
time.sleep(3)
clear()
else:
try:
users[r_username]={'pass':r_pass1,'ph':r_phno,'email':r_email,'add':r_add,'count
ry':r_country.upper(),'pincode':r_pincode,'sales':[],'buys':[],'tradowallet':{}}
clear()
print('\n\t\t\t\t\tUSER SUCCESFULLY
REGISTERED...........PLEASE LOGIN.')
time.sleep(3)
clear()
except:
print('\n\t\t\t\tInvalid pincode!!')
def loggedin():
global l_username,login_status,used_item_ids,users
loggedin=True
ch_loggedin='0'
8
if not users[l_username]['tradowallet']:
while login_status:
ch_loggedin=input('Select a choice:')
clear()
if ch_loggedin=='1':
if not confirm:
if users[l_username]['tradowallet']:
clear()
for i in range(5):
time.sleep(2)
print('$',end='')
clear()
x=True
while x:
9
sell_id=random.randint(100000,999999)
used_item_ids+=(str(sell_id),)
x=False
users[l_username]['sales']+=[{'item_id':str(sell_id),'item':sell_item,'quantity':sell_q
uantity,'price':sell_price,'description':sell_description}]
finish=False
ch=input()
if ch=='1':
clear()
print('HAPPY MONEY$$$$!!!')
10
clear()
elif ch=='2':
finish=True
clear()
else:
print('Invalid choice')
else:
time.sleep(3)
clear()
elif ch_loggedin=='2':
print('Catalogue:')
x=1
for i in users:
if len(users[i]['sales']):
y=1
for j in users[i]['sales']:
if j['quantity']==0:
disp_quantity='No Stock'
else:
disp_quantity=j['quantity']
print(x,'.',y,'Product:',j['item'],sep='')
print('Price:',j['price'])
11
print('Stock left:',disp_quantity)
print('Description:',j['description'])
print('Item id:',j['item_id'])
print()
y+=1
print('\n')
x+=1
print()
ch=input()
clear()
if not ch:
pass
elif ch in used_item_ids:
flag=0
for i in users:
for j in range(len(users[i]['sales'])):
if users[i]['sales'][j]['item_id']==ch:
flag=1
seller=i
product_no=j
break
if flag==1:
12
break
print('Product Details:')
print('\tProduct:',users[seller]['sales'][product_no]['item'])
print('\tPrice:',users[seller]['sales'][product_no]['price'])
print('\tStock left:',disp_quantity)
print('\tDescription:',users[seller]['sales'][product_no]['description'])
print('\tItem id:',users[seller]['sales'][product_no]['item_id'])
print('\nSeller Details:')
print('\tSeller:',seller)
print('\tPhone number:',users[seller]['ph'])
print('\tAdress:',users[seller]['add'])
print('\tCountry:',users[seller]['country'])
print('\tPincode:',users[seller]['pincode'])
buy_ch=input()
clear()
if buy_ch=='1':
continue_=False
decline=False
buy_ch2=input()
clear()
if buy_ch2=='1':
13
print('1.The final sale of product is only at the seller\'s
discretion')
clear()
elif buy_ch2=='2':
continue_=True
buy=True
elif buy_ch2=='3':
continue_=True
buy=False
else:
print('Invalid choice!!')
time.sleep(2)
clear()
if buy:
if users[l_username]['tradowallet']:
14
flag=0
try:
except:
time.sleep(3)
clear()
flag=1
if qty<=users[seller]['sales'][product_no]['quantity'] and
flag==0:
ch=input()
if not ch:
clear()
for i in '$$$$$':
time.sleep(3)
print(i,end='')
time.sleep(2)
clear()
print('Your Tradowallet
balance:',users[l_username]['tradowallet']['balance'])
print('Total price of
product:',users[seller]['sales'][product_no]['price']*qty)
if users[l_username]['country']==users[seller]['country']:
delivery=0
else:
15
delivery=20/100*users[seller]['sales'][product_no]['price']*qty
print('Delivery/Shipping charges:',delivery)
total_cost=users[seller]['sales'][product_no]['price']*qty+delivery
ch=input()
clear()
if not ch:
if
users[l_username]['tradowallet']['balance']>=total_cost:
for i in '$$$$$':
time.sleep(3)
print(i,end='')
clear()
users[l_username]['tradowallet']['balance']-
=total_cost
users[seller]['sales'][product_no]['quantity']-=qty
users[seller]['tradowallet']['balance']+=90/100*total_cost
finish=False
ch=input()
16
clear()
if ch=='1':
print('HAPPY MONEY!!!!!')
clear()
elif ch=='2':
clear()
break
else:
print('Invalid choice!!')
time.sleep(3)
clear()
else:
print('Terminating')
time.sleep(3)
clear()
else:
print('Terminating')
time.sleep(3)
clear()
17
else:
print('Terminating')
time.sleep(3)
clear()
else:
time.sleep(3)
clear()
elif ch_loggedin=='3':
if users[l_username]['tradowallet']:
ch=input()
if ch=='1':
flag=0
try:
except:
print('Invalid amount!!')
flag=1
if flag==0:
clear()
if ch=='':
18
print('Processing')
for i in '$$$$$':
time.sleep(2)
print(i,end='')
clear()
users[l_username]['tradowallet']['balance']+=amt
print('Your account
balance:',users[l_username]['tradowallet']['balance'])
clear()
elif ch=='2':
print('Your wallet
balance:',users[l_username]['tradowallet']['balance'])
clear()
else:
ch=input()
clear()
if ch=='1':
print('Processing')
for i in '$$$$$':
print(i,end='')
time.sleep(2)
19
clear()
users[l_username]['tradowallet']['name']=l_username
users[l_username]['tradowallet']['balance']=0
clear()
elif ch_loggedin=='4':
print('\t\t\tYOUR SALES:')
x=1
for i in users[l_username]['sales']:
print(i)
print('\n')
clear()
if ch in used_item_ids:
for i in range(len(users[l_username]['sales'])):
if users[l_username]['sales'][i]['item_id']==ch:
product_no=i
break
print(users[l_username]['sales'][i])
ch=input()
clear()
if ch=='1':
20
a=input('Enter the new name:')
users[l_username]['sales'][i]['item']=a
clear()
elif ch=='2':
users[l_username]['sales'][i]['description']=a
clear()
elif ch=='3':
users[l_username]['sales'][i]['price']=a
clear()
elif ch=='4':
users[l_username]['sales'][i]['quantity']=a
clear()
elif ch=='5':
if a=='':
del users[l_username]['sales'][i]
21
clear()
else:
clear()
elif ch_loggedin=='5':
x=0
try:
if rate>10 or rate<1:
print('Invalid Rating')
x=1
time.sleep(2)
clear()
except:
print('Invalid rating')
print('hi')
x=1
time.sleep(2)
clear()
if x==0:
ch=input()
clear()
if ch=='':
users[l_username]['review']=[rate,review]
22
print('Review succesfully added!!')
clear()
else:
clear()
elif ch_loggedin=='6':
login_status=False
clear()
time.sleep(3)
clear()
else:
print('Invalid choice')
time.sleep(2)
clear()
def clear():
print('\n'*49)
print(i,end='')
time.sleep(0.07)
time.sleep(3)
clear()
print('\nLoading:')
23
for i in range(5):
time.sleep(1)
print('$',end=' ')
clear()
while exit_program==False:
print('\n\n\t\t\t\t\t\t*********HOMEPAGE*********')
hp_choice=input('Choose an option:')
clear()
if hp_choice=='1':
print('\n\t\t\t\t\t\t#######Tradex News#######')
clear()
elif hp_choice=='2':
Login_Register()
if login_status:
loggedin()
elif hp_choice=='3':
print('\t\t\t\tABOUT')
24
clear()
elif hp_choice=='4':
print('\n\t\t\t\tReviews\n\n')
for i in users:
print(i,':')
print('Rating:',users[i]['review'][0])
print('Review:',users[i]['review'][1])
clear()
elif hp_choice=='5':
exit_program=True
25
OUTPUT :
26
27
28
29
30
CONCLUSION :
- The whole program was created using one single main dictionary and several
nested elements contained in it, so it was quite tough sorting them
appropriately.
- The whole program had to be given lots of features which made the source
code too long.
31
FUTURE ENHANCEMENT :
-The data stored inside the dictionaries could be saved externally using data
files (Ex: JSON, etc.).
-SQL Databases can be used to organise, store and manage the data in a
proper structured form.
-Maybe TRADEX would be the best online trading platform with high rated
reviews of the customers.
32
BIBLIOGRAPHY:
BOOKS:
Computer Science with Python - Sumita Arora , published by Dhanpat Rai
LINKS:
https://www.geeksforgeeks.org/python-dictionary/
https://www.programiz.com/python-programming
https://www.w3schools.com/python/python_dictionaries.asp
https://www.geeksforgeeks.org/python-os-system-method/
33