Python Program 1 : Login Program



import pandas as pd

List_username = []
List_password = []
List_Id = []
dict1 = {'Id': List_Id, 'Username': List_username, 'Password': List_password}


def CheckID(Y):
    users_Data = pd.read_csv("UserData.csv")
    for p, q in users_Data.iterrows():
        if Y == str(q['Id']):
            return True
            break
    else:
        return False



programrunning = True
while programrunning:
    print('---------------------------------------------------------------------')
    print("Choose your operation ")
    print("1.Login")
    print("2.New User")
    print("0.Exit")
    oper_Code = str(input("Enter Operation code : "))

    if oper_Code == '1':
        print('---------------------------------------------------------------------')
        Id = str(input("Enter your Id : "))
        if CheckID(str(Id)):
            users_Data = pd.read_csv("UserData.csv", index_col='Id')
            username = str(input("Username : "))
            password = str(input("Password : "))
            if username == str(users_Data.Username[int(Id)]) and password == str(users_Data.Password[int(Id)]):
                print('---------------------------------------------------------------------')
                print("Login successful ")

            else:
                print('-----------------------------WARNING---------------------------------')
                print("invalid Username or Password ")

        else:
            print('-----------------------------WARNING---------------------------------')
            print("UserID is invalid")

        programrunning = True
    elif oper_Code == '2':

        print('---------------------------------------------------------------------')
        Id = str(input("Enter your Id(11 digits) : "))

        if len(str(Id)) == 11:

            users_Data = pd.read_csv("UserData.csv", index_col='Id')
            if not CheckID(str(Id)):
                username = input("Username : ")
                password = input("Password : ")
                List_Id.append(int(Id))
                List_username.append(username)
                List_password.append(password)
                users_Data1 = pd.DataFrame(dict1)
                users_Data = pd.read_csv("UserData.csv")
                users_Data = pd.concat([users_Data, users_Data1], ignore_index=True)
                users_Data.to_csv("UserData.csv", index=False)
                print('---------------------------------------------------------------------')
                print("Account registered Successfully with ")
                print("UserID : ", Id)
                print("Username :", username, "Password : ", password)
            elif CheckID(str(Id)):
                print('-----------------------------WARNING---------------------------------')
                print("User registered already")

        elif len(str(Id)) > 11:
            print('-----------------------------WARNING---------------------------------')
            print("Number of digits in UserID is more than specified limit")
        elif len(str(Id)) < 11:
            print('-----------------------------WARNING---------------------------------')
            print("Number of digits in UserID is less than specified limit")
        else:
            print('-----------------------------WARNING---------------------------------')
            print("invalid UserID entered")

        programrunning = True
    elif oper_Code == '0':
        print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
        print("Thank you for using our service ")
        print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")

        programrunning = False
    else:
        print('-----------------------------WARNING---------------------------------')
        print("Please select right option ")