Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import time
- import math
- import pyfiglet
- # clear the screen
- def clearScreen():
- if os.name == 'nt':
- os.system('cls')
- else:
- os.system('clear')
- def updateStock(remainingEggs):
- # open the file in read and write mode
- stockUpdated = False
- with open("Chk_Pjt.txt", "r+") as Chk_Pjt:
- lines = Chk_Pjt.readlines()
- for line in reversed(lines):
- if line.startswith('Number of eggs stock is :'):
- number = float(line.split(":")[1].strip())
- new_number = number + remainingEggs
- line = f'Number of eggs stock is :{new_number}\n'
- l = str(line)
- Chk_Pjt.write(l)
- stockUpdated = True
- continue
- if not stockUpdated:
- with open("Chk_Pjt.txt", "a") as Chk_Pjt:
- Chk_Pjt.write(f'Number of eggs stock is :{remainingEggs}\n')
- Chk_Pjt.write('<<--------------------------------------------------->>\n')
- name = pyfiglet.figlet_format('Chicken Project')
- print(name)
- Chk_Pjt=open('Chk_Pjt.txt','a')
- login = input('Enter your text : ')
- if login == 'log-info':
- Chk_Pjt.write('>> '+ str(time.ctime()))
- eggsCount = int(input('>>Enter Number of eggs Product :'))
- soldEggsCount = int(input('>>Enter Number of eggs sold :'))
- remainingEggs = eggsCount - soldEggsCount
- eggPrince = float(input('>>Enter egg unit price (dh) :'))
- eggsTotalPrice = eggPrince * eggsCount
- lostAmount = float(input('>>How much lost money of production that eggs :'))
- netProfit = eggsTotalPrice - lostAmount
- Chk_Pjt.write(f'\n\tNumber of eggs Product is : {str(eggsCount)}\n')
- Chk_Pjt.write(f'\tNumber of eggs sold is : {str(soldEggsCount)}\n')
- Chk_Pjt.write(f'\tone eggs price is : {str(eggPrince)} DH\n')
- Chk_Pjt.write(f'\tThe price of all eggs is : {str(eggsTotalPrice)} DH\n')
- Chk_Pjt.write(f'\tlost money of production that eggs is : {str(lostAmount)} DH\n')
- Chk_Pjt.write('\t-------------------------\n')
- Chk_Pjt.write(f'\tYour profits is : {str(netProfit)} DH\n')
- Chk_Pjt.write('\t-------------------------\n')
- Chk_Pjt.write('<<--------------------------------------------------->>\n')
- Chk_Pjt.close()
- # update the stock
- updateStock(remainingEggs)
- if netProfit<0:
- clearScreen()
- print (pyfiglet.figlet_format('00000'))
- elif netProfit>0:
- clearScreen()
- print (pyfiglet.figlet_format('1111'))
- elif netProfit==0:
- clearScreen()
- print (pyfiglet.figlet_format('----------'))
- elif login=='info-file':
- Chk_Pjt = open('file_chk-pjt','r')
- text = Chk_Pjt.read()
- Chk_Pjt.close()
- print (repr(text))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement