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(): # 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(): #ADD FRIEND frnd = Spy(" ", " ", 0, 0.0) frnd.Name = raw_input("What is your name ? ") frnd.sal = raw_input("What should we call u ? ") 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): friends.append(frnd) with open('friends.csv', 'a') as friends_data: writer = csv.writer(friends_data) writer.writerow( [spy.name, spy.saluation, spy.rating, spy.age, spy.is_online]) else: print "Friend cannot be added" 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. '
spy.age) + ' and your rating is ' + str(spy.rating) #function calling spy_chat(spy.name, spy.age, spy.rating) if spy_reply.upper() == 'Y': 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"