Ejemplo n.º 1
0
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)
Ejemplo n.º 2
0
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))
Ejemplo n.º 3
0
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__)
Ejemplo n.º 4
0
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}")
Ejemplo n.º 5
0
"""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()
Ejemplo n.º 6
0
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'
    )
Ejemplo n.º 7
0
def run_raffle():
    """Run the weekly raffle."""

    people = customers.get_customers_from_file("customers.txt")
    pick_winner(people)
Ejemplo n.º 8
0
def raffle():
    """Run the weekly raffle."""

    customers = get_customers_from_file("customers.txt")
    random_winner(customers)
Ejemplo n.º 9
0
"""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()
Ejemplo n.º 10
0
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.")
Ejemplo n.º 11
0
def run_raffle():
    """Run the weekly raffle."""

    customers = get_customers_from_file("customers.txt")
    pick_winner(customers)
Ejemplo n.º 12
0
def run_raffle():
    """Run the raffle"""

    customers = get_customers_from_file("customers.txt")
    random_winner(customers)
Ejemplo n.º 13
0
"""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
Ejemplo n.º 14
0
def run_raffle():
    """Run the weekly raffle."""

    raffle_pool = customers.get_customers_from_file("customers.txt")
    pick_winner(raffle_pool)
Ejemplo n.º 15
0
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
Ejemplo n.º 16
0
"""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)
Ejemplo n.º 18
0
def run_raffel():
    customers = get_customers_from_file("customers.txt")
    pick_a_winner(customers)
Ejemplo n.º 19
0
def run_raffle():
    """Run the weekly raffle."""
    print("in run raffle fucntion")
    customers = get_customers_from_file("customers.txt")
    print("customers")
    pick_winner(customers)
Ejemplo n.º 20
0
def weekly_raffle():

    customers = get_customers_from_file('customers.txt')
    raffle_winner(customers)