コード例 #1
0
ファイル: main.py プロジェクト: piy15197/Python_Project
def add_friend():

    new_friend = Spy('', '', 0, 0.0)  #adding a new friend on account a spy

    #taking friend's details
    new_friend.name = raw_input("Please add your friend's name: ")
    new_friend.salutation = raw_input("Are they Mr. or Ms.?: ")

    new_friend.name = new_friend.salutation + " " + new_friend.name

    new_friend.age = raw_input("Age?")
    new_friend.age = int(new_friend.age)

    new_friend.rating = raw_input("Spy rating?")
    new_friend.rating = float(new_friend.rating)

    #checking for authenticity of a friend
    if len(new_friend.name
           ) > 0 and new_friend.age > 12 and new_friend.rating >= spy.rating:
        friends.append(new_friend)
        print 'Friend Added!'
    else:
        print 'Sorry! Invalid entry. We can\'t add spy with the details you provided'

    return len(friends)
コード例 #2
0
def add_friend():
    new_friend = Spy('', '', 0, 0.0)

    new_friend.name = raw_input("Please add your friend's name:")
    if len(new_friend.name) > 0 and new_friend.name.isspace(
    ) == False:  # isspace() function is set to false so that user doesnot enter blank spaces

        new_friend.salutation = raw_input("Are they Mr. or Ms.")
        if new_friend.salutation == "Mr." or new_friend.salutation == "Ms.":

            new_friend.name = new_friend.salutation + " " + new_friend.name
            new_friend.age = int(raw_input("age?"))
            new_friend.rating = float(raw_input("Enter rating"))

            if new_friend.age > 18 and new_friend.rating >= spy.rating:
                friend.append(
                    new_friend
                )  # adding new friends to old list using append function
                print "ADD friend!!"
            else:
                print "Sorry!! not eligible"
        else:
            print "enter valid salutation!!"

    else:
        print "sorry! invalid entry....."
    return len(friend)  # to count number of friends in friend[] list
コード例 #3
0
def add_friend():
    new_friend = Spy('', '', 0, 0.0)

    new_friend.name = raw_input("enter your name")
    # len function checks the length text to prevent from empty input to the name
    if len(new_friend.name) > 0 and new_friend.name.isspace(
    ) == False:  #isspace() checks whether the string consists of whitespace
        new_friend.salutation = raw_input("Are they Mr. or Miss.?: ")
        if new_friend.salutation == "Mr." or new_friend.salutation == "Miss.":

            new_friend.name = new_friend.salutation + " " + new_friend.name
            new_friend.age = int(raw_input("enter your age"))
            new_friend.rat = float(raw_input("enter your rating"))

            if new_friend.age > 12 and new_friend.rat > spy.rating:
                friends.append(new_friend)
                print "friend added"

            else:
                print "please enter valid age or rating"

        else:
            print "please enter valid salutation"

    else:
        print "Sorry!!we can't move further please enter valid spy name"

    return len(friends)  # it returns no of friends which are added in the fri
コード例 #4
0
def signup():
    spy = Spy("", "", 0, 0.0)  # class for spydetails
    spy.name = raw_input(
        'Enter your username: '******'Enter a valid name '
    elif spy.name.isdigit():  # to check for digit input
        print 'Enter a valid name '
    elif len(spy.name) > 2:  # checking for length of the string name
        password = raw_input("Enter your password: "******" " + spy.name.upper(
            )  #Using + for string concatenation
            print spy.name  #home work
            print "Alright " + spy.name + ".I'd like to know a little bit more about you before we proceed...."  #home work
            spy.age = 0  #variable declaration ,integer type
            spy.rating = 0.0  #variable declaration for float number
            spy.age = input("What is your age?")
            if 65 > spy.age > 16:  # and operator is also a solution of this
                print "CONGRATS...You are eligible for spy."
            else:
                spy.rating = input("What is your rating?")
                if spy.rating >= 8.0:
                    print "GREAT SPY (*****)."  #5 star
                elif 8 > spy.rating > 5.0:  #elif used for mare than one condition
                    print "GOOD SPY (***)"  #3 star
                elif 3.5 < spy.rating <= 5.0:
                    print "AVERAGE SPY.YOU CAN ALWAYS DO BETTER (*)."  #1 star
                else:
                    print "WHO HIRED YOU?"
                spy_is_online = True  #this is boolean
                print "Authentication complete.Welcome %s your age " \
                          "is" + str(spy.age) + "and rating is"+ str(spy.rating) + ".Proud to have " \
                          "you on board." #we can also use placeholders
                with open("login.csv",
                          "ab") as login:  ## writing details in login file
                    writer = csv.writer(login)
                    writer.writerow([
                        spy.name, password, spy.sal, spy.age, spy.rating,
                        spy_is_online
                    ])

                spy_chat(spy.name, spy.age, spy.rating)

        else:
            print "Please check salutation."
    else:
        print "Ooopss please enter a valid name."
コード例 #5
0
ファイル: main.py プロジェクト: sagarkava/spychat
def add_friend():
    frnd = Spy('', '', 0, 0.0)
    frnd.name = raw_input('What is your friend name?-> ')
    frnd.sal = raw_input('what should we call you? ->')
    frnd.age = input('What is your friend age?->')
    frnd.rating = input('What is your friend rating-> ')
    frnd.is_online = True
    if len(frnd.name) > 2 and 12 < frnd.age < 60 and frnd.rating > spy.rating:
        with open('friends.csv', 'a') as (friends_data):
            writer = csv.writer(friends_data)
            writer.writerow(
                [frnd.name, frnd.sal, frnd.rating, frnd.age, frnd.is_online])

    else:
        print 'Friend cannot be added'
    return len(friends)
コード例 #6
0
def add_friend():
    frnd = Spy('', '', 0, 0.0)
    frnd.name = raw_input("enter the friend name: ")
    frnd.sal = raw_input("salutaion? Mr. or Ms.")
    frnd.age = input("friend age? ")
    frnd.rating = input("friend rating? ")
    frnd.is_online = True
    if len(frnd.name) > 0 and 65 > spy.age > 16 and frnd.rating > spy.rating:
        with open('friends.csv', 'ab') as friend_data:
            writer = csv.writer(friend_data)
            writer.writerow(
                [frnd.name, frnd.sal, frnd.rating, frnd.age, frnd.is_online])
            print "congrats...Now you have one more frirnd"
    else:
        print "friend cannot be added"
    return len(friends)
コード例 #7
0
ファイル: main.py プロジェクト: piy15197/Python_Project
                    read_message()
                elif menu_choice == 5:
                    read_chat_history()
                else:
                    show_menu = False
    else:
        print 'Sorry you are not of the correct age to be a spy'


if existing == "Y":  #if the spy already exist start chat directly
    start_chat(spy)
else:
    #taking the detail input of spy
    spy = Spy('', '', 0, 0.0)

    spy.name = raw_input(
        "Welcome to spy chat, you must tell me your spy name first: ")

    if len(spy.name) > 0:
        spy.salutation = raw_input("Should I call you Mr. or Ms.?: ")

        spy.age = raw_input("What is your age?")
        spy.age = int(spy.age)

        spy.rating = raw_input("What is your spy rating?")
        spy.rating = float(spy.rating)

        start_chat(spy)
    else:
        print 'Please add a valid spy name'

        ##End Of the CODE
コード例 #8
0
ファイル: main.py プロジェクト: sagarkava/spychat
            read_message()
        elif choice == 0:
            show_menu = False
        else:
            print 'invalid input'


spy_exist = raw_input('Are u new user? Y/N: ')
if spy_exist.upper() == 'N':
    print 'Welcome back ' + spy.name + ' age: ' + str(
        spy.age) + ' having rating of ' + str(spy.rating)
    start_chat(spy.name, spy.age, spy.rating)

elif spy_exist.upper() == 'Y':
    spy = Spy('', '', 0, 0.0)
    spy.name = raw_input('What is your spy name? ')
    if spy.name.isalpha() == False:
        print ' Please enter your name'
        exit(0)

    elif len(spy.name) > 2:
        print 'welcome ' + spy.name + ' glad to have you back with us .'
        spy_salutation = raw_input('what should we call you (Mr. or Ms.)?')
        if spy_salutation == 'Mr.' or spy_salutation == 'Ms.':
            spy.name = spy_salutation + ' ' + spy.name
            print 'Alright, ' + spy.name + ' I would like to know a little bit more about you.'
            spy.age = input('what is your age ')
            if 60 >= spy.age > 12:
                print 'your age is correct'
                spy.rating = input('what is your rating ')
                if spy.rating > 5.0:
コード例 #9
0
ファイル: main.py プロジェクト: dipak45/spychat
                elif menu_choice == 5:
                    read_chat_history()
                else:
                    show_menu = False
    else:
        print 'Sorry you are not of the correct age to be a spy'


if existing == "Y":
    password = raw_input("Enter your password:"******"Welcome to spy chat, Enter your spy_name: ")

    spy_len = len(spy.name)
    print spy.name
    print spy_len
    if spy_len <= 0:
        print "INVALID USER NAME"
        exit()
    else:
        print "VERIFIED"
        spy.salutation = raw_input("Enter your spy_gender?: ")
        if spy.salutation.upper() == "MALE":
            print "WELCOME MR " + spy.name
        else:
            print "WELCOME Mrs " + spy.name
コード例 #10
0
                    show_menu = False

    else:
        print "Sorry you are not of the correct age to be a spy"


# if spy wants to continue as default user
if (existing == "Y" or existing == "y"):
    print " Welcome you can continue with your existing account " + spy.name + " " + str(
        spy.age)
    spy_chat(spy)

#  For new user app should ask for the name of the user,age and for rating
else:
    spy = Spy('', '', 0, 0.0)
    spy.name = raw_input("welcm to the spy chat,plss enter your name first:")
    if len(spy.name) > 0 and spy.name.isspace() == False:

        spy.sal = raw_input("Should i call you Mr.or Miss.")

        if spy.sal == "Mr." or spy.sal == "Miss.":

            spy.age = int(raw_input("enter your age"))

            spy.rating = float(raw_input("enter spy rating"))

            spy_chat(spy)

        else:
            print "please enter the valid salutation"