def account_no_gen(user_name): d = data() alphabets = 'abcdefghijklmnopqrstuvwxyz' acc_no = '' acc_no += str(len(d.keys()) + 10) for alpha in user_name: if (len(acc_no) < 12): if alpha in alphabets: index = alphabets.rfind(alpha) acc_no += str(index + 1) else: acc_no += '0' else: break if len(acc_no) > 12: final_acc_no = '' for index in acc_no: if len(final_acc_no) < 12: final_acc_no += index acc_no = final_acc_no return acc_no if len(acc_no) < 12: remain_index = 12 - len(acc_no) for index in range(remain_index): acc_no += str(randint(0,9)) return acc_no else: return acc_no
def del_account(): d = data() filename = join() os.system('cls' if os.name == 'nt' else 'clear') acc_name = input("Delete Account\nEnter Full Name : ") if acc_name in d.keys(): acc_pin = str(input("Enter 4-Digit Pin : ")) if acc_pin == d[acc_name][0]: os.system('cls' if os.name == 'nt' else 'clear') print("Delete Account :", acc_name) confirm = input("Please Confirm \n1. Yes \n2. No \n") if (confirm == '1') or (confirm.lower().startswith('y')): os.system('cls' if os.name == 'nt' else 'clear') del d[acc_name] #over_writing of existing file with open(filename, "w") as rd: r = csv.writer(rd) r.writerow(['Name', 'PIN', 'Amount', 'History']) rd.close() with open(filename, "a") as ow: for item in d.keys(): items = rot13(item) over_write = [ items, d[item][0], str(d[item][1]), str(d[item][2]) ] o = csv.writer(ow) o.writerow(over_write) ow.close() print("Account Deleted Successfully! \n") return login_user() elif (confirm == '2') or (confirm.lower().startswith('n')): os.system('cls' if os.name == 'nt' else 'clear') print("Account Not Deleted!") return login_user() else: os.system('cls' if os.name == 'nt' else 'clear') print("Account Not Deleted!") return login_user() else: os.system('cls' if os.name == 'nt' else 'clear') print("Pin Did Not Match!") return login_user() else: os.system('cls' if os.name == 'nt' else 'clear') print("Account Does Not Exist!") return login_user()
def del_account(): d = data() filename = join() os.system('cls' if os.name == 'nt' else 'clear') acc_name = input("Delete Account\nEnter Full Name : ") if acc_name in d.keys(): acc_pin = str(input("Enter 4-Digit Pin : ")) if acc_pin == d[acc_name][0]: os.system('cls' if os.name == 'nt' else 'clear') print("Delete Account :", acc_name) confirm = input("Please Confirm \n1. Yes \n2. No \n") if (confirm == '1') or (confirm.lower().startswith('y')): os.system('cls' if os.name == 'nt' else 'clear') if d[acc_name] == d['abc xyz']: del d[acc_name] else: del d[acc_name], d['abc xyz'] #over_writing of existing file with open(filename, "w") as rd: rd.write('nop klm:1234,0.0') rd.close() with open(filename, "a") as ow: for item in d.keys(): items = rot13(item) over_write = '\n' + items + ':' + d[item][ 0] + ',' + str(d[item][1]) ow.write(over_write) ow.close() print("Account Deleted Successfully! \n") return login_user() elif (confirm == '2') or (confirm.lower().startswith('n')): os.system('cls' if os.name == 'nt' else 'clear') print("Account Not Deleted!") return login_user() else: os.system('cls' if os.name == 'nt' else 'clear') print("Account Not Deleted!") return login_user() else: os.system('cls' if os.name == 'nt' else 'clear') print("Incorrect Pin!") return login_user() else: os.system('cls' if os.name == 'nt' else 'clear') print("Account Does Not Exist!") return login_user()
def login_user(): clear = ('cls' if os.name == 'nt' else 'clear') #data funtion is called to check or make changes in it d = data() user = input( "Select One : \n1. Login \n2. Create New Account \n3. Activate Account \n4. De-Activate Account \n0. Exit \n" ) os.system(clear) if not str(user).isdigit(): print("Invalid Selection!") return login_user() #login function called for further execution if int(user) == 1: os.system(clear) login(d) #new_account function called for further execution elif int(user) == 2: os.system(clear) new_account() elif int(user) == 3: os.system(clear) activate_account() elif int(user) == 4: os.system(clear) de_active_account() #exit the main funtion elif int(user) == 0: print("Good Bye!") print("About:") with open('About.txt', 'r') as infile: show = infile.read() print(show) #in case any other number is entered except those listed above #recursion(main function called again) else: print("Invalid Selection! '", user, "'") return login_user() return
def login_user(): #data funtion is called to check or make changes in it d = data() user = input( "Select One : \n1. Login \n2. Create New Account \n3. Delete Existing Account \n0. Exit \n" ) os.system('cls' if os.name == 'nt' else 'clear') if not str(user).isdigit(): print("Invalid Selection!") return login_user() #login function called for further execution if int(user) == 1: os.system('cls' if os.name == 'nt' else 'clear') login(d) #new_account function called for further execution elif int(user) == 2: os.system('cls' if os.name == 'nt' else 'clear') new_account() elif int(user) == 3: os.system('cls' if os.name == 'nt' else 'clear') del_account() #exit the main funtion elif int(user) == 0: print("Good Bye!") #in case any other number is entered except those listed above #recursion(main function called again) else: print("Invalid Selection!") return login_user() return
cursor = db.getCursor() if db.findDataBase("testdb"): db.deleteDataBase("testdb") db.makeDataBase("testdb") db = db.connectTo("testdb") cursor = db.getCursor() db.execute("DROP TABLE IF EXISTS USERS") db.execute( "CREATE TABLE USERS(UserId INTEGER AUTO_INCREMENT PRIMARY KEY,Name VARCHAR(255),Age INTEGER(3),Email VARCHAR(255) DEFAULT NULL)" ) db.execute("SHOW TABLES") db.printCursor(["Tables"]) print data_set = data() cmd = "INSERT INTO USERS(Name,Age,Email) VALUES (%s, %s, %s)" db.execute(cmd, True, data_set) db.commit() db.execute("SELECT * FROM USERS") db.printCursor(["UserId", "Name", "Age", "Email"]) print db.execute("SELECT * FROM USERS WHERE Name like '%Smith%'") db.printCursor(["UserId", "Name", "Age", "Email"]) print db.execute("DROP TABLE IF EXISTS MOVIE") db.execute(
def admin_block(acc_no): clear = ('cls' if os.name == 'nt' else 'clear') d = data() pin = str(gp("Enter 4-Digit Pin : ")) if pin == d[acc_no][1]: del d[acc_no] os.system(clear) print(time.strftime('Date:%d-%b-%Y \nTime:%I:%M %p Today:%A\n')) print( "::: Welcome to YOB Admin Block! :::\n\n:: Select Option Provided Below ::" ) ad = input( "1. Number Of Users \n2. Active User Names \n3. Active Users Info. \n4. Users Acivity \n5. Find Account \n6. De-Activate Account\n0. Exit\n" ) while ad != '0': if ad == '1': os.system(clear) c_user, i_user = 0, 0 for users in d.keys(): if not users.startswith('#'): c_user += 1 else: i_user += 1 print(":: Users ::") print("Active Users :", c_user) print("Inactive Users :", i_user, '\n') elif ad == '2': os.system(clear) c_user = 0 print(":: Active User Names ::") for users in d.keys(): if not users.startswith('#'): c_user += 1 print("Active User", c_user, ':', d[users][0]) print('\n') elif ad == '3': os.system(clear) print(":: Users Info ::") for user_info in d.keys(): if not user_info.startswith('#'): print("Name =", d[user_info][0], ", Pin :", d[user_info][1], ", Amount :", "{:,}".format(d[user_info][2])) print('\n') elif ad == '4': os.system(clear) print(":: Users Acivity ::") for user_info in d.keys(): if not user_info.startswith('#'): print("Account Number :", user_info, "of Name :", d[user_info][0], "was previously logged in on", d[user_info][3]) print('\n') elif ad == '5': os.system(clear) acc_no_find = str(input('Enter 12-Digit Account Number : ')) if acc_no_find in d.keys(): print("Account Status : Active") print("Name :", d[acc_no_find][0]) print("Pin :", d[acc_no_find][1]) print("Amount :", "{:,}\n".format(d[acc_no_find][2])) elif ("#" + acc_no_find) in d.keys(): print("Account Status : Inactive") print("Name :", d[("#" + acc_no_find)][0]) print("Pin :", d[("#" + acc_no_find)][1]) print("Amount :", "{:,}\n".format(d[("#" + acc_no_find)][2])) else: os.system(clear) print("Account Not Found!") elif ad == '6': os.system(clear) return de_active_account() ad = input( "1. Number Of Users \n2. Active User Names \n3. Active Users Info. \n4. Users Acivity \n5. Find Account \n6. De-Activate Account\n0. Exit\n" ) os.system(clear) return login_user() else: os.system(clear) return login_user()
def de_active_account(): clear = ('cls' if os.name == 'nt' else 'clear') d = data() filename = join() os.system(clear) acc_no = input("Account De-activate\nEnter Account Number : ") if acc_no in d.keys(): acc_pin = str(gp("Enter 4-Digit Pin : ")) if acc_pin == d[acc_no][1]: os.system(clear) print("De-activate Account :", d[acc_no][0]) confirm = input("Please Confirm \n1. Yes \n2. No \n") if (confirm == '1') or (confirm.lower().startswith('y')): os.system(clear) d[('#' + acc_no)] = d.pop(acc_no) #over_writing of existing file with open(filename, "w") as rd: r = csv.writer(rd) r.writerow([ 'Account Number', 'Name', 'PIN', 'Amount', 'Time', 'Email Address' ]) rd.close() with open(filename, "a") as ow: for item in d.keys(): items = rot13(d[item][0]) over_write = [ item, items, str(d[item][1]), str(d[item][2]), str(d[item][3]), str(d[item][4]) ] o = csv.writer(ow) o.writerow(over_write) ow.close() print("Account De-Activated Successfully! \n") return login_user() elif (confirm == '2') or (confirm.lower().startswith('n')): os.system(clear) print("Account Not De-Activated!") return login_user() else: os.system(clear) print("Account Not De-Activated!") return login_user() else: os.system(clear) print("Pin Did Not Match!") return login_user() elif ("#" + acc_no) in d.keys(): os.system(clear) print("Account Is Already De-Active!") return login_user() else: os.system(clear) print("No match found!") return login_user()
def activate_account(): clear = ('cls' if os.name == 'nt' else 'clear') d = data() filename = join() user_acc_no = str(input('Enter 12-Digit Account Number : ')) os.system(clear) if not user_acc_no.isdigit(): print('Invalid Account!') return login_user() elif user_acc_no in d.keys(): print('Account Is Already Active!') return login_user() elif user_acc_no.isdigit(): ch_acc_no = str('#' + user_acc_no) if ch_acc_no in d.keys(): d[user_acc_no] = d.pop(ch_acc_no) print("Activate Account Name :", d[user_acc_no][0]) confirm = input("Please Confirm \n1. Yes \n2. No \n") if (confirm == '1') or (confirm.lower().startswith('y')): os.system(clear) #over_writing of existing file with open(filename, "w") as rd: r = csv.writer(rd) r.writerow([ 'Account Number', 'Name', 'PIN', 'Amount', 'Time', 'Email Address' ]) rd.close() with open(filename, "a") as ow: for item in d.keys(): items = rot13(d[item][0]) over_write = [ item, items, str(d[item][1]), str(d[item][2]), str(d[item][3]), str(d[item][4]) ] o = csv.writer(ow) o.writerow(over_write) ow.close() print("Account Activated Successfully! \n") return login_user() elif (confirm == '2') or (confirm.lower().startswith('n')): os.system(clear) print("Account Not Activated!") return login_user() else: os.system(clear) print("Account Not Activated!") return login_user() else: os.system(clear) print('Account Does Not Exist') return login_user()
def amount_transfer(account_no, balance, acc_no, address): import time, datetime clear = ('cls' if os.name == 'nt' else 'clear') os.system(clear) d = data() filename = join() amount = 0.0 print(":: Amount Transfer ::") Inactive_account = str('#' + account_no) if Inactive_account in d.keys(): os.system(clear) print(":: Provided Account Number Is Not Active! ::") return amount elif account_no in d.keys(): try: amount = input("Enter Amount In Rupees: ") if float(amount) < 0.0 or ('-' in amount): os.system(clear) print(":: Please Enter Right Amount! ::\n") return amount_transfer(account_no, balance, acc_no, address) elif float(amount) > float(balance): os.system(clear) print( ":: Amount Can Not Be Transferred! ::\n:: Your Acount Balance = Rs", balance, "::", "\n") return amount_transfer(account_no, balance, acc_no, address) else: os.system(clear) print(":: Account Number :", account_no, "::") print(":: Name :", d[account_no][0], "::") print(":: Amount Transfer = Rs", "{:,} ::".format(float(amount)), "\n") confirm = input("Please Confirm \n1. Yes \n2. No \n") if (confirm == '1') or (confirm.lower().startswith('y')): with open(filename, 'a+') as ap: #rot13() function is called for encoding enc = rot13(d[account_no][0]) current_balance = balance balance = str(float(d[account_no][2]) + float(amount)) Message = str( "Amount of 'Rs " + str(amount) + "' was received on " + str(time.strftime('%d-%b-%Y at %I:%M %p')) + ", through Account Number: " + str(acc_no)) re_new = [ account_no, enc, d[account_no][1], balance, d[account_no][3], d[account_no][4], Message ] w = csv.writer(ap) w.writerow(re_new) ap.close() os.system(clear) MSG_from = "You Have Successfully Transferred An Amount Of Rs " + str( amount) + " To A/C #" + str( account_no ) + "\n\nYour Net Account Balance Is Rs " + str( float(current_balance) - float(amount)) MSG_to = "You Have Received An Amount Of Rs " + str( amount) + " From A/C #" + str( acc_no ) + "\n\nYour Net Account Balance Is Rs " + str( float(balance)) sendmail(address, MSG_from) msg2 = sendmail(d[account_no][4], MSG_to) os.system(clear) if not (msg2 == True): print(msg2) print(":: Amount Transferred Successfully! ::") return amount else: amount = 0 os.system(clear) print(":: Amount Transfer Unsuccessful! ::") return amount except ValueError as err: os.system(clear) print("Error :", err) print(":: Please Enter Right Amount! ::\n") return amount_transfer(account_no, balance, acc_no, address) else: os.system(clear) print(":: No Match Found! ::") return amount
import Schedule from Data import data from random import random data=data() class GenticAlgo: def __init__(self,population): #list gdwal self.population = population self.selected_schedule = [] self.mutate_rate=1 self.schedules_conflict=[] def selection(self): schedules = self.population schedules_conflicts = [] for i in range(len(schedules)): schedules[i].calculate_conflicts() schedules_conflicts.append(schedules[i].get_conflict()) schedules_conflicts.sort() selection1=schedules_conflicts[0] selection2=schedules_conflicts[1] #print(schedules_conflicts) self.selected_schedule.clear() for i in range (len(schedules)): if schedules[i].get_conflict() == selection1 or schedules[i].get_conflict() == selection2: self.selected_schedule.append(schedules[i]) self.schedules_conflict.clear() self.schedules_conflict.extend(schedules_conflicts)