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(): 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 = raw_input("Please add your friend's name: ") new_friend.salutation = raw_input("Are they Mr. or Ms.?: ") 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 new_friend.age > 12 and new_friend.rating >= spy.rating: friends.append(new_friend) print 'Friend Added!' print_friends() 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 = 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(): #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)
def signup(): spy = Spy("","",0,0.0) #class for spy details spy.name = raw_input("Enter your name ") # name taken as input from user if spy.name.isspace(): # check for space input print ' Enter a valid name ' elif spy.name.isdigit(): print ' Enter a valid name ' elif len(spy.name) > 2: # checking for length of string print " welcome " + spy.name+" "+" Glad to have with us. " # concatenating strings spy.sal = raw_input("What do we call you (Mr. or Ms. or Mrs.)") if spy.sal == "Mr." or spy.sal == "Ms." or spy.sal == "Mrs.": # condition for checking input salutation spy_name = spy.sal+" "+spy.name print " Alright " + spy_name + " I\'d like to know little more about you......" spy.age = input('what\'s your age') if 55 <= spy.age <= 12: # nested if to check range of age print 'You are not eligible to be a spy' else: rating = input('enter your ratings ') if spy.rating > 5: print 'Great Spy!!!' elif spy.rating > 4: print 'Good Spy...!' elif spy.rating > 3.5: # elif is used for more than one condition print ' Average Spy ' elif spy.rating > 2.5: print ' Need To Work Hard !!! ' else: print ' Who Hired You...Get Out !!! ' spy_is_online = True print 'Authentication complete. Welcome ' + spy.name + ' age: ' + str(spy.age) + ' and your rating is : ' + str(spy.rating) # typecasting of integer to string spy_chat(spy.name, spy.age, spy.rating) # calling function spy_chat else: print ' Enter a valid salutation ' else: print ' Ooops!! Please enter a valid name. '
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 user selects option 6, then close the application else: show_menu = False else: print colored("sorry you are not of the correct age to be a spy", 'red') if question == "Y": start_chat(spy) else: #declaring empty values for spy spy = Spy('', 0, '', 0.0) #to know about the spy while asking all the details like name, salutation, age and rating spy.name = raw_input("welcome to spychat. tell me your name:") #to check if spy name is not empty if len(spy.name) > 0: spy.salutation = raw_input("what should we call you(Mr. or Ms.)?") spy.age = int(raw_input("what is your age:")) spy.rating = float(raw_input("what is your spy rating?")) start_chat(spy) else: print colored("a spy needs to have a valid name. please try again", 'blue')
else: show_menu = False print 'application closed' else: print 'Sorry you are not of the correct age to be a spy' if existing == "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 = 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' #APPLICATION CLOSED,,,,,,,,,,,,,,,,
print spy_ratting start_chat(spy) else: #enter the data for new user spy = Spy('', '', 0, 0.0) spy.name = str( raw_input("Welcome to spy chat, you must tell me your spy name first: " )) #username of new user if spy.name == str(spy.name): a = raw_input("what is ur gender (male. 0r female)") # input gender if a == "male": # nested if statement print "mr." + " " + spy.name + " welcome to spy chat" else: print "miss" + " " + spy.name + " welcome to spy chat" spy.age = int(raw_input( "What is your age?")) #check that the age of user is valid or not if spy.age > 16 and spy.age < 45: d = raw_input("may i know what is ur rating") # input ratting d = float(d) if d > 4.5: # nested if statement for ratting print "great" elif d > 3.5 and d <= 4.5: print "better" elif d > 2.5 and d <= 3.5: print "gud" elif d > 1.5 and d <= 2.5: print "bad" elif d > 1 and d <= 1.5: print "fuddu" else: print("you r not in the the age group")
spy = Spy('', '', 0, 0.0) spy.name = raw_input("what is your name?") #if user enter space in 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)