Tradex Cs Project MF

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 35

COMPUTER SCIENCE PROJECT

2019-2020

TRADEX (ONLINE TRADING PLATFORM)

SUBMITTED BY : HAVINASH IYER H


CLASS : XI
SRIMATHI SUNDARAVALLI MEMORIAL SCHOOL
CHENNAI-600063
INDEX :

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 :

Python - Overview. Python is a high-level, interpreted, interactive and object-


oriented scripting language. Python is designed to be highly readable. It uses
English keywords frequently where as other languages use punctuation, and it
has fewer syntactical constructions than other languages.

It is an object-oriented programming language created by Guido Rossum in


1989. It is ideally designed for rapid prototyping of complex applications. ...
Python programming is widely used in Artificial Intelligence, Natural Language
Generation, Neural Networks and other advanced fields of Computer Science.

− Python is processed at runtime by the interpreter. You do not need to


compile your program before executing it. This is similar to PERL and PHP.

− You can actually sit at a Python prompt and interact with the interpreter
directly to write your programs.

− Python supports Object-Oriented style or technique of programming that


encapsulates code within objects.

− Python is a great language for the beginner-level programmers and supports


the development of a wide range of applications from simple text processing to
WWW browsers to games.

1
SYNOPSIS / SUMMARY:

TITLE - TRADEX (online trading platform)

−Users can first login/register into their accounts (dictionary accommodates


many users by storing key-username and value-password).

−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.

In Python, a Dictionary can be created by placing sequence of elements within


curly {} braces, separated by ‘comma’.

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 :

print: print to console

not: negates a Boolean value

import: import other modules into a Python script

def: used to create a new user defined function

global: access variables defined outside functions

try: specifies exception handlers

except: catches the exception and executes codes

upper() : converts a string to uppercase

clear() : clears the screen

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('Welcome to TRADEX. To use the site please login.')

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')

l_username=input('Enter your username:')

l_password=input('Enter your password:')

if l_username in users and users[l_username]['pass']==l_password:

print('\n\n.................LOGIN SUCCESSFUL................')

login_status=True

time.sleep(3)

6
clear()

break

else:

print('Invalid username or password')

time.sleep(3)

clear()

elif l_r=='2':

print('\nREGISTRATION PAGE:\n')

r_username=input("Enter a username:")

if r_username in users:

print('\n\t\t\t\tUsername is already taken.....please login if it is


yours.')

clear()

else:

r_pass1=input('Enter a password:')

r_pass2=input('Confirm the password:')

if r_pass1!=r_pass2:

print('\n\t\t\t\tThe passwords dont match.....please try again.')

time.sleep(3)

clear()

else:

r_phno=input('Enter a valid phone number:')

if len(r_phno)!=10:

print('\n\t\t\t\t\tInvalid phone number')

time.sleep(3)

clear()

7
else:

r_email=input('Enter a valid email id:')

if '@' not in r_email or '.com' not in r_email:

print('\n\t\t\t\tEmail id is invalid.')

time.sleep(3)

clear()

else:

r_add=input('Enter your address:')

r_country=input('Enter your country:')

try:

r_pincode=int(input('Enter your pincode:'))

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

print('\n\nHello',l_username,'.Welcome to TRADEX--Your next marketing


destination')

ch_loggedin='0'

8
if not users[l_username]['tradowallet']:

print('\nConfigure your TradoWallet before buying or selling!!\n')

while login_status:

print('1.Sell an item\n2.Buy an item\n3.TradoWallet\n4.Edit/Check


Sales\n5.Add Review\n6.Logout')

ch_loggedin=input('Select a choice:')

clear()

if ch_loggedin=='1':

print('\t\t\t\t\t\t$$$$$$$TRADEX--Item Trading Hall:Sell a


good$$$$$$$$')

sell_item=input('Enter the item on sale:')

sell_quantity=int(input('Enter the quantity:'))

sell_price=int(input('Enter price per item in int:'))

sell_description=input('Describe the item:')

confirm=input('Press enter to continue:')

if not confirm:

if users[l_username]['tradowallet']:

clear()

print('Processing your request:')

for i in range(5):

time.sleep(2)

print('$',end='')

clear()

x=True

while x:

9
sell_id=random.randint(100000,999999)

if str(sell_id) not in used_item_ids:

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}]

print('Item successfully placed on sale!!!!!')

finish=False

while not finish:

print('1.Display formal procedures\n2.Finish')

ch=input()

if ch=='1':

clear()

print('1.The product placed on sale can be viewed by


everyone who wishes to see it.')

print('2.When the buyer decides to buy it he can select it


and pay the amount through his TradoWallet')

print('3.90% of the cost will be transferred to your


TradoWallet instantly. The rest 10% will go to the admin.')

print('4.You can always edit or remove the item from sale by


selecting the desired option in the main page.')

print('5.If a person buys the order, the TRADEX officials will


get in touch with you regarding the delivery.')

print('6.All delivery activities will be taken care of by


TRADEX delivery personnel and other officials')

print('HAPPY MONEY$$$$!!!')

input('<Press any key to continue>')

10
clear()

elif ch=='2':

finish=True

clear()

else:

print('Invalid choice')

else:

print('Configure your TradoWallet first')

time.sleep(3)

clear()

elif ch_loggedin=='2':

print('\t\t\t\t\t\t$$$$$$TRADEX--Item Trading Hall:Buy a product')

print('Catalogue:')

x=1

for i in users:

if len(users[i]['sales']):

print(x,'.','Items sold by',i,':',sep=' ')

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()

print('Enter item id to view the item.\nPress enter to go back to


homepage.')

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'])

print('1.Buy item\n2.Back to homepage')

buy_ch=input()

clear()

if buy_ch=='1':

continue_=False

decline=False

while not continue_:

print('1.Read Terms and Conditions\n2.Agree Terms and


Conditions\n3.Decline')

buy_ch2=input()

clear()

if buy_ch2=='1':

13
print('1.The final sale of product is only at the seller\'s
discretion')

print('2.TRADEX is not responsible for faulty response at the


seller\'s end')

print('3.Please make sure your TradoWallet is configured and


the necessary amount is present, else the payment will be declined')

print('4.20% of the cost will be added as shipping fee for


orders from another country')

print('5.Only in case of shipping damages, the amount will be


refunded by TRADEX')

print('6.Product defects are to be handled directly with the


seller.TRADEX is not responsible for this.')

print('7.By agreeing to the terms and conditions, you comply


by all the above terms.')

a=input('<Press any key to go back>')

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:

qty=int(input('Enter the quantity you want to purchase:'))

except:

print('Invalid quantity!!Process terminated....')

time.sleep(3)

clear()

flag=1

if qty<=users[seller]['sales'][product_no]['quantity'] and
flag==0:

print('Press enter to continue.')

ch=input()

if not ch:

clear()

print('Gathering information....please wait.')

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

print('Total cost to pay:',total_cost)

print('\nCheck the details and press enter to proceed')

ch=input()

clear()

if not ch:

if
users[l_username]['tradowallet']['balance']>=total_cost:

print('Purchasing the order.')

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

print('Your TradoWallet balance


is:',users[l_username]['tradowallet']['balance'])

finish=False

while not finish:

print('\n1.View Formal Procedures.\n2.Finish')

ch=input()

16
clear()

if ch=='1':

print('1.The product will be delivered to your


address within 7 days(within the country) or within 14 days(outside the
country)')

print('2.It is suggested to get in touch with


the suppliers regarding the sale, though it is not necessary')

print('3.Status of the delivery will be


constantly updated through messages to your mobile number')

print('HAPPY MONEY!!!!!')

a=input('<Press enter to continue>')

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:

print('Configure your TradoWallet first')

time.sleep(3)

clear()

elif ch_loggedin=='3':

if users[l_username]['tradowallet']:

print('1:Top up\n2:Check Balance\nEnter key:Back to Homepage')

ch=input()

if ch=='1':

flag=0

try:

amt=int(input('Enter the amount to top up:'))

except:

print('Invalid amount!!')

flag=1

if flag==0:

accno=input('Enter the account number:')

accpass=input('Enter the account password:')

ch=input('Press enter to continue')

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'])

input('<Press enter to continue>')

clear()

elif ch=='2':

print('Your wallet
balance:',users[l_username]['tradowallet']['balance'])

input('<Press enter to continue>')

clear()

else:

print('\t\t\tAttention!!You have not configured your


TradoWallet.Please configure it to buy and sell items!!')

print('\nTradoWallet is the medium of transactions in TRADEX.')

print('\n\nPress 1 to configure\nPress enter to go back')

ch=input()

clear()

if ch=='1':

print('Processing')

for i in '$$$$$':

print(i,end='')

time.sleep(2)
19
clear()

print('Done!!Your wallet has been configured.You can continue


on!')

users[l_username]['tradowallet']['name']=l_username

users[l_username]['tradowallet']['balance']=0

input('<Press enter to continue>')

clear()

elif ch_loggedin=='4':

print('\t\t\tYOUR SALES:')

x=1

for i in users[l_username]['sales']:

print(i)

print('\n')

ch=input('Enter item id to modify or enter key to go back:')

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])

print('\n1.Change Item name\n2.Change Description\n3.Change


Price\n4.Change Quantity\n5.Delete item\nEnter any other key to go back to
homepage')

ch=input()

clear()

if ch=='1':
20
a=input('Enter the new name:')

users[l_username]['sales'][i]['item']=a

input('Name changed!!Press enter to go back')

clear()

elif ch=='2':

a=input('Enter the new description:')

users[l_username]['sales'][i]['description']=a

input('Description changed!!Press enter to go back')

clear()

elif ch=='3':

a=int(input('Enter the new price:'))

users[l_username]['sales'][i]['price']=a

input('Price changed!!Press enter to go back')

clear()

elif ch=='4':

a=int(input('Enter the new quantity:'))

users[l_username]['sales'][i]['quantity']=a

input('Quantity changed!!Press enter to go back')

clear()

elif ch=='5':

a=input('Press enter to confirm')

if a=='':

del users[l_username]['sales'][i]

print('Item is successfully deleted from the inventory')

input('Press enter continue')

21
clear()

else:

clear()

elif ch_loggedin=='5':

x=0

try:

rate=math.ceil(int(input('Please rate us from 1 to 10:')))

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:

review=input('Add your review:')

print('Press enter to submit or any other key to cancel')

ch=input()

clear()

if ch=='':

users[l_username]['review']=[rate,review]

22
print('Review succesfully added!!')

print('<You can change it anytime by coming to this screen>')

input('Press enter to continue')

clear()

else:

clear()

elif ch_loggedin=='6':

login_status=False

clear()

print('Succesfully logged out.')

time.sleep(3)

clear()

else:

print('Invalid choice')

time.sleep(2)

clear()

def clear():

print('\n'*49)

print('\t\t\t\t\t\t TRADEX\n\t\t\t\t\t\t ',end='')

for i in '--Your Next Marketing Destination Ltd':

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*********')

print('\n\n1.View Tradex News\n2.Login/Register\n3.About\n4.View


Reviews\n5.Exit App')

hp_choice=input('Choose an option:')

clear()

if hp_choice=='1':

print('\n\t\t\t\t\t\t#######Tradex News#######')

print('Tradex is working on accomodating the best quality items and we


are looking forward in serving you with all our potential')

input('<Press any key to continue>')

clear()

elif hp_choice=='2':

Login_Register()

if login_status:

loggedin()

elif hp_choice=='3':

print('\t\t\t\tABOUT')

print('Tradex was found by two intellectuals named Vamsi Krishna and


Havinash recently in 2019 . The company is growing tremendously and has
high ratings too . We almost assure you that tradex is gonna be the best of all
:)')

input('<Press any key to continue>')

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])

input('<Press any key to continue>')

clear()

elif hp_choice=='5':

exit_program=True

25
OUTPUT :

26
27
28
29
30
CONCLUSION :

- It was quite challenging to program in order to meet the expectations of the


people.

- 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.

- We faced difficulty in making the project look as realistic as possible.

- The problem of LOGICAL ERRORS was a major headache but we managed


them.

- 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.

-The user interface can be Improved.

-The Code can be made more simpler by adding comments.

-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

You might also like