Beispiel #1
0
def add_friend():
    frnd=Spy('','',0,0.0)  #to add a new friend
    frnd.name = raw_input('What is your friend \'s name? ')
    frnd.sal = raw_input("What should we call your friend?")
    frnd.age = input('What is your friend\'s age ? ')
    frnd.ratings = input('What is your friend\'s rating ?')
    frnd.is_online= True
    if len(frnd.name)>2 and 14<frnd.age<60 and frnd.ratings>spy.ratings:  # conditons for adding new friend
        friends.append(frnd) #adding this new friend in the list of already existing friends
        with open('friends.csv','a') as friends_data:
            writer = csv.writer(friends_data)
            writer.writerow([frnd.name, frnd.sal, frnd.ratings, frnd.age, frnd.is_online])
    else:
        print "Friend cannot be added."
    return len(friends)  # will return to add_friend()
Beispiel #2
0
def add_friend():
    frnd=Spy('','',0,0.0)
    frnd.sal=raw_input('what should we call you?')
    frnd.name=raw_input('Enter your name: ')
    frnd.age=input('what is your age? ')
    frnd.rating=input('what is your rating? ')
    frnd.is_online=True
    if len(frnd.name)>2 and 12<frnd.age<50 and frnd.rating>spy.rating:
        friends.append(frnd)
        with open('friends.csv','a') as friends_data:
            writer=csv.writer(friends_data)
            writer.writerow([frnd.name,frnd.sal,frnd.age,frnd.rating,frnd.is_online])
            print'Your friend is added successfully..'
    else:
        print'Friend cannot be added'
    return len(friends)
Beispiel #3
0
def add_friend():  # function to add friend
    # taking friends detail s input
    frnd = Spy ('','',0,0.0)
    frnd = {'name': "",'age':0,'ratings':0.0,'isonline':True,'chats':[]}  # dictionary for details of friend
    frnd.name =raw_input("What is your friend's name : ")
    frnd.sal = raw_input("What should we call you")
    frnd.age=input("What is the age :")
    frnd.rating=input("What are the ratings : ")
    frnd.is_online = True
    if len(frnd.name)>0 and 12<frnd.age<50 and frnd.rating>spy.rating: # checking for spy details
        # adding the details in the respective lists
        friends.append(frnd)
        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 "The friend cannot be added "
    return len(friends)  # returning length of list friend_name
Beispiel #4
0
def add_friend():  # defining function add_friend()
    frnd = Spy('', '', 0, 0.0)
    frnd.name = raw_input("What is your friend name? ")
    frnd.sal = raw_input("What should we call your friend? ")
    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 < 50 and frnd.rating > spy.rating:  #conditions for adding new friend
        with open('feiends.csv', 'a') as friends_data:
            writer = csv.writer(friends_data)
            writer.writerow([
                frnd.name, frnd.salutation, frnd.rating, frnd.age,
                frnd.is_online
            ])
    else:
        print "Friend cannot be added"
    return len(friends)  #will return to add friend()
Beispiel #5
0
def add_friends():

    frnd = Spy(' ', ' ', 0, 0.0)
    frnd.name = raw_input('WRITE YOUR FRND\'S NAME :')
    frnd_sal = raw_input('Mr. or Ms. :')
    frnd.name = frnd_sal + ' ' + frnd.name
    frnd.age = input('WRITE THE AGE OF FRND:')
    frnd.rating = input('write the rating of frnd:')
    frnd.is_online = True

    if len(frnd.name) > 2 and 50 > frnd.age > 12 and frnd.rating >= spy.rating:
        friends.append(frnd)
        with open('friends.csv', 'a') as friends_data:
            writer = csv.writer(friends_data)
            writer.writerow([frnd.name, frnd.age, frnd.rating, frnd.is_online])

    else:
        print 'frnd with these values can not be a0dded'

    return len(friends)
def add_friend():
    new_friend = Spy('', '', 0, 0.0)
    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 = int(raw_input("Age? "))

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

    if len(new_friend.name
           ) > 0 and new_friend.age > 12 and new_friend.age < 50:
        new_friend.is_online = True
        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)
Beispiel #7
0
def add_friend():  #define add friend function
    frnd = Spy("", "", 0, 0.0)
    frnd.name = raw_input(
        "What is your friend's name ? ")  #input friend's name
    frnd.sal = raw_input('Mr or Ms')
    frnd.age = input("What is your friend's age ?")  #input friend's age
    frnd.rating = input(
        "What is your friend's rating ?")  #input friend's rating
    frnd.is_online = True  #set friend is online
    if len(
            frnd.name
    ) > 2 and 12 < frnd.age < 50 and frnd.rating > spy.rating and frnd.name.isalpha(
    ):  #check condition for adding friend
        frnd.name = frnd.name.upper()
        frnd.sal = frnd.sal.upper()
        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])
            print 'your friend added successfully'

    else:
        print 'Friend cannot be added..'  #conditional statement
    return len(friends)  #return no of friends
Beispiel #8
0
def add_friend():

    frnd = Spy('', '', 0, 0.0)

    frnd.Name = raw_input("What is your name? ")
    frnd.sal = raw_input("What should we call you? ")

    frnd.Age = input("What is your age? ")

    frnd.Rating = raw_input("What is your Rating? ")
    frnd.is_online = True

    if len(frnd.Name) > 3 and 18 < frnd.Age < 50 and frnd.Rating > 3:
        with open('friends.csv', 'a') as friends_data:
            writer = csv.writer(friends_data)
            writer.writerow([
                frnd.Name, spy.saluation, frnd.rating, frnd.age, frnd.is_online
            ])

    else:

        print "Friend's Can't be added"

    return len(friends)
Beispiel #9
0
    spy.name = raw_input("Welcome to spy chat, you must tell me your spy name first: ")

    try:
        assert any([char not in string.ascii_letters for char in spy.name]) is False


        if len(spy.name) > 0:
            print "welcome " + spy.name
            spy.name = spy.name
            spy.salutation = raw_input("should i call u Mr.  or Miss? ")
            spy.name = spy.salutation + " " + spy.name
            print " Okay , Welcome " + spy.name
            spy.age = int(raw_input("what is your age? "))

            if (spy.age > 12 and spy.age < 50):
                print "age valid"
                spy.rating = float(raw_input("Enter the rating:"))
                spy.is_online = True

            else:
                print"invalid age"
            start_chat(spy)
        else:
            print" "

    except AssertionError:
        print"your name must contain letters only"


start_chat(spy)
Beispiel #10
0
if existing == "Y":
    start_chat(spy)
else:

    spy = Spy('', '', 0, 0.0)

    spy.name = raw_input("What is your name?")

    if len(spy.name) > 0:
        print "Welcome " + spy.name + ". Glad to have you back with us."
        spy.salutation = raw_input("What should we call you (Mr. or Ms.)?")
        spy.name = spy.salutation + " " + spy.name
        print "Alright " + spy.name + ". I'd like to know a little bit more about you before we proceed..."
        spy.age = 0
        spy.rating = 0.0
        spy.is_online = False
        spy.age = int(raw_input("What is your age?"))
        if 18 < spy.age < 65:
            spy.rating = float(raw_input("What is your spy rating?"))
            if spy.rating > 4.5:
                print "Great ace!"
            elif 3.5 < spy.rating <= 4.5:
                print "You are one of the good ones."
            elif 2.5 <= spy.rating <= 3.5:
                print "You can always do better"
            else:
                print "We can always use somebody to help in the office."
            spy.is_online = True
            start_chat(spy)

        else:
Beispiel #11
0
    new_user = Spy('', '', 0, 0.0)

    new_user.salutation = raw_input(
        "Should I call you Mister or Miss?: ")  # Salutation for new user

    new_user.name = raw_input("Your name is " +
                              new_user.salutation)  # Salutation for new user

    new_user.name = new_user.salutation + " " + new_user.name

    print "Alright " + " " + new_user.name + ". I'd like to know a little bit more about you before we proceed."

    new_user.age = 0
    new_user.rating = 0.0
    new_user.is_online = False

    new_user.age = int(raw_input("What is your age?"))  # age for new user
    if 50 > new_user.age > 12:
        new_user.rating = float(
            raw_input("What is your rating?"))  # rating for new user
        if 4.5 < new_user.rating:
            print 'Great ace!'
        elif 3.5 < new_user.rating <= 4.5:
            print 'You are one of the good ones.'
        elif 2.5 <= new_user.rating <= 3.5:
            print 'You can always do better'
        else:
            print 'We can always use somebody to help in the office.'
    else:
        print 'Sorry you are not of the correct age to be a spy. Authentication Failed.'