def pick_winner(customer_file_path): """Choose a random winner from list of customers.""" customers_obj = customers.get_customers_from_file(customer_file_path) chosen_customer = random.choice(customers_obj) print "Tell {name} at {email} that they've won".format( name=chosen_customer.name, email=chosen_customer.email)
def run_raffle(): """Randomly pick customer and print customer info""" customers_list = customers.get_customers_from_file('customers.txt') chosen_customer = choice(customers_list) print("Tell {name} at {email} that they've won".format( name=chosen_customer.name, email=chosen_customer.email))
def print_random_customer(customers_file_path): """Take txtfile of customers and print random customer's info""" # Generate list of all customer objects from file customers_list = customers.get_customers_from_file(customers_file_path) # Choose random customer object from list rand_customer = choice(customers_list) # Print all of random customer's attributes print(rand_customer.__dict__)
def print_winner(): """ Run and print the winner """ lst_customers = customers.get_customers_from_file("customers.txt") winner = get_random_customer(lst_customers) print(f"Name: {winner.name}") print(f"Email: {winner.email}") print(f"Street: {winner.street}") print(f"City: {winner.city}") print(f"Zipcode: {winner.zipcode}")
"""Randomly pick customer and print customer info""" from random import choice from customers import get_customers_from_file customers = get_customers_from_file("customers.txt") def pick_winner(customers): """Choose a random winner from list of customers.""" chosen_customer = choice(customers) print "Tell {name} at {email} that they've won.".format( name=chosen_customer.name, email=chosen_customer.email ) def run_raffle(): """Run the weekly raffle.""" pick_winner(customers) run_raffle()
def pick_winner(filename): all_customers = customers.get_customers_from_file(filename) winner = choice(all_customers) print( f'{winner.name} with email {winner.email} who lives at {winner.street}, {winner.city}, {winner.zipcode} won' )
def run_raffle(): """Run the weekly raffle.""" people = customers.get_customers_from_file("customers.txt") pick_winner(people)
def raffle(): """Run the weekly raffle.""" customers = get_customers_from_file("customers.txt") random_winner(customers)
"""Randomly pick customer and print customer info""" # Add code starting here # Hint: remember to import any functions you need from # other files or libraries from customers import get_customers_from_file from random import choice customers_list = get_customers_from_file('customers.txt') def pick_winner(customers): """Choose a random winner from list of customers.""" chosen_customer = choice(customers) print("Tell {name} at {email} that they've won".format( name=chosen_customer.name, email=chosen_customer.email)) def run_raffle(): """Run the weekly raffle.""" customers = get_customers_from_file("customers.txt") pick_winner(customers) #To make the raffle run when run as a script if __name__ == "__main__": run_raffle()
def choose_winner(): winner = choice(get_customers_from_file("customers.txt")) print(f"Tell {winner.name} at {winner.email} that they have won the raffle.")
def run_raffle(): """Run the weekly raffle.""" customers = get_customers_from_file("customers.txt") pick_winner(customers)
def run_raffle(): """Run the raffle""" customers = get_customers_from_file("customers.txt") random_winner(customers)
"""Randomly pick customer and print customer info""" import customers import random file_path = 'customers.txt' customer_list = customers.get_customers_from_file(file_path) #print(customer_list) random_customer = int(random.random() * len(customer_list)) #print(random_customer) print(customer_list[random_customer].display()) # Add code starting here # Hint: remember to import any functions you need from # other files or libraries
def run_raffle(): """Run the weekly raffle.""" raffle_pool = customers.get_customers_from_file("customers.txt") pick_winner(raffle_pool)
def run_raffle(): """Run the weekly raffle.""" customers = get_customers_from_file("customers.txt") # nested function to recall return customers pick_winner(customers) # nested function to choose and print winner
"""Randomly pick customer and print customer info""" # Add code starting here # Hint: remember to import any functions you need from # other files or libraries import random from customers import get_customers_from_file def pick_winner(customers): choosen_customer = random.choice(customers) print(f"Tell {choosen_customer.name} at {choosen_customer.email}" " that they've won.") def run_raffle(): """Run the weekly raffle.""" customers = get_customers_from_file("customers.txt") pick_winner(customers) if __name__ == '__main__': run_raffle print(pick_winner(get_customers_from_file("customers.txt")))
def run_raffle(): """#runs other functions, main file""" contestants = get_customers_from_file("customers.txt") choose_customer(contestants)
def run_raffel(): customers = get_customers_from_file("customers.txt") pick_a_winner(customers)
def run_raffle(): """Run the weekly raffle.""" print("in run raffle fucntion") customers = get_customers_from_file("customers.txt") print("customers") pick_winner(customers)
def weekly_raffle(): customers = get_customers_from_file('customers.txt') raffle_winner(customers)