def add_friend(): new_friend = Spy('','',0,0.0) #added in the spy class new_friend.name = raw_input("Please add your friend's name: ") if set('[~!@#$%^&*()_+{}":;\']+$ " "').intersection(new_friend): print "Invalid entry." else: print new_friend new_friend.salutation = raw_input("Formal Salutation: Mr. or Ms. or Mrs. ") 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) if len(new_friend.name) > 2 and new_friend.age > 15 and new_friend.rating >= spy.rating: friends.append(new_friend) print 'New Friend Added!' else: print 'Sorry! Invalid entry. We can\'t add spy with the details you provided!!' return len(friends)
def add_friend(): frnd = Spy("", "", 0, 0.0) firstname = raw_input("enter your friends name ") frnd.sal = raw_input("enter friend salutation:") frnd.age = input("enter age of friend::") frnd.rating = input("enter rating:") frnd.name = frnd.spy + " " + frndname if len(frnd.name ) >= 2 and 12 < frnd.age < 60 and frnd.rating >= spy.rating: friends.append(frnd) else: print "Sorry enter Valid Details" return len(friends)
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 print 'Alright ' + spy_name + '. I\'d like to know a little bit more about you...' spy.age = input('What\'s your age : ') if 50 <= spy.age <= 12: # nested if statement to check range of age print 'You are not eligible to be a spy.' else: spy.rating = input( 'What are your ratings : ') # taking ratings as input if spy.rating > 5: print 'Great Spy!!' elif spy.rating > 3.5: # elif statement for more than one condition print 'Average Spy.' elif spy.rating > 2.5: print 'Need to work hard!!' else: print 'Who hired you' spy_is_online = True print 'Authentication complete. Welcome ' + spy_name + '.Your age is ' + str( spy.age) + ' and your rating is ' + str( spy.rating) # typecasting of integer to string # writing details in login file with open("login.csv", "ab") as login: 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) # calling function spy_chat else: print 'Enter a valid salutation' else: print 'Ooops! Enter a valid name '
def add_friend(): new_friend = Spy('', '', 0, 0.0) new_friend.name = raw_input('Please add your friend\'s name :') new_friend.salu = raw_input('are they Mr or Miss ? :') new_friend.age = int(raw_input('age:')) new_friend.rating = float(raw_input('spy rating')) if (new_friend.name.isalpha() ) and new_friend.age > 12 and new_friend.rating >= spy.rating: #add friend into friend list friends.append(new_friend) else: print 'Sorry! invalid entry.We can\'t add spy with the detalis you provided ' return len(friends)
def add_friend(): # function to add friend # taking friend detail as input frnd = Spy("","",0,0.0) # class for details of friend frnd.name = raw_input("What is your friend's name :") frnd.sal = raw_input("What is your friends salutation") frnd.age = input("What is the age :") frnd.rating = input("What are the rating :") frnd.is_online = True if len(frnd.name)>0 and 12<frnd.age<50 and frnd.rating > spy.rating: # adding the details in the respective lists with open('friend.csv','ab')as friend_data: writer = csv.writer(friend_data) writer.writerow([frnd.sal,frnd.age,frnd.rating,frnd.is_online]) print "Your frnd is added" friends.append(frnd) # appending friend details in friend list else: print "The friend cannot be added " return len(friends) # retuning length of list friend_name
def add_friend(): new_friend = Spy('','',0,0.0) new_friend.name = raw_input("\nPlease 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.rating >= spy.rating: friend_list.append(new_friend) print 'Friend Added!' else: print '\nSorry! Invalid entry. We can\'t add spy with the details you provided' return len(friend_list)
def add_friend(): new_friend = Spy('', '', 0, 0.0) new_friend.name = raw_input("Enter friends 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) new_friend.chats = [] if len(new_friend.name) > 0 and new_friend.age > 12: friends.append(new_friend) print colored('\nFriends Added', 'yellow', attrs=['bold']) else: print 'Sorry! Invalid entry. We can\'t add spy with the details you provided' return len(friends)
def add_friend(): new_friend = Spy('', '', 0, 0.0) new_friend.name = input("please ! add your friends name ? ") name = new_friend.name new_friend.salutation = input("Are they MR OR MS") new_friend.name = new_friend.salutation + " " + name new_friend.age = int(input("enter age ?")) new_friend.rating = float(input("spy rating ?")) if len(new_friend.name) > 0: print("spy name is not empty") if (name_vali(name) is True) and age_val(new_friend.age): friends.append(new_friend) else: print( "sorry invalid entry . we can't add spy with details you provided") # return the no of friends in dictionary return len(friends)
def add_friend(): #define friend fxn to add new 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 = raw_input("Age?") new_friend.age = int(new_friend.age) new_friend.rating = raw_input("Spy rating?") new_friend.rating = float(new_friend.rating) if len(new_friend.name) > 0 and int( new_friend.age) > 12 and new_friend.rating >= float(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)
def add_friend(): #creating empty values for new friend new_friend = Spy('', 0, '', 0.0) #to evaluate all details of spy's new friend like name, age, rating and salutation new_friend.name = raw_input("add your friends name:") new_friend.salutation = raw_input("are they Mr. or Ms.:?") new_friend.name = new_friend.name + " " + new_friend.salutation new_friend.age = int(raw_input("age?")) new_friend.rating = float(raw_input("spy rating?")) #to check the spy's friend's age, rating and the name that should not be empty if len(new_friend.name ) > 0 and new_friend.age > 12 and new_friend.rating >= spy.rating: friends.append(new_friend) print colored('Friend Added!', 'red') else: print colored( 'sorry! invalid entry. we can\'t add spy with the details you provided', 'blue') return len(friends)
if answer == "Y": start_chat(spy) else: 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 = int(raw_input("What is your age?")) spy.rating = float(raw_input("What is your spy rating?")) if spy.rating > 4.5: print "You have a great ace.\n" elif spy.rating >= 3.5 and spy.rating <= 4.5: print "You can do better.\n" else: print "We can use someone from the office.\n" start_chat(spy) else: print 'Please add a valid spy name'
if spy.name.isspace(): print 'enter valid name' #if user enter digit in spy_name elif spy.name.isdigit(): print "enter valid name" # Name condition elif len(spy.name) >= 2: print 'Welcome ' + spy.name + ' Glad to have back with us' spy.sal = raw_input("What should we call you (Mr. or Ms.)") if spy.sal == 'Mr.' or spy_salutation == 'Ms.': spy_name = spy.sal + " " + spy.name print "Alright " + spy_name + " I\'d like to know a little more about you before we proceed..." spy.age = input("enter your age") #Age condition and rating if 12 < spy.age < 60: spy.rating = input("enter spy rating::") if spy.rating > 4.5: print "Great SPY" elif 3.5 < spy.rating <= 4.5: print "A good one SPY" elif 2.5 <= spy.rating <= 3.5: print "can do better" else: print "NOT AT ALL A GOOD SPY WHAT ARE YOU DOING HERE Do Hard Wok" spy_is_online = True #integer converted into string using typecasting print "Authentication complete. Welcome " + spy_name + " age::" + str( spy.age) + " and rating of spy is::" + str(spy.rating) #function calling spy_chat(spy.name, spy.age, spy.rating) #if age is not in the range