<jupyter_start><jupyter_text>9-1 Restaurant<jupyter_code>class Restaurant:
  def __init__(self, restaurant_name, cuisine_type):
    self.restaurant_name = restaurant_name
    self.cuisine_type = cuisine_type

  def open_restaurant(self):
    print(f"The Restaurant {self.restaurant_name.title()} with a cuisine type of {self.cuisine_type.title()} is now open!.")

restaurant_1 = Restaurant('los pollos hermanos', 'fast-food')


restaurant_1.open_restaurant()<jupyter_output>The Restaurant Los Pollos Hermanos with a cuisine type of Fast-Food is now open!.<jupyter_text>9-2 Three Restaurants<jupyter_code>class Restaurant:
  def __init__(self, restaurant_name, cuisine_type):
    self.restaurant_name = restaurant_name
    self.cuisine_type = cuisine_type

  def describe_restaurant(self):
    print(f"{self.restaurant_name.title()} is a {self.cuisine_type.title()} restaurant.")



jollibee = Restaurant('Jabi', 'fast-food')

mcdo = Restaurant('macdo', 'fast-food')

seoul = Restaurant('samgyup', 'korean')

jollibee.describe_restaurant()

mcdo.describe_restaurant()

seoul.describe_restaurant()<jupyter_output>Jabi is a Fast-Food restaurant.
Macdo is a Fast-Food restaurant.
Samgyup is a Korean restaurant.<jupyter_text>9-3 Users<jupyter_code>class User:
  def __init__(self, first_name, last_name):
    self.first_name = first_name
    self.last_name = last_name

  def describe_user(self):
    print(f"{self.first_name.title()}'s last name is {self.last_name.title()}.")

  def greet_user(self):
    print(f"\nHello Good Day! {self.first_name.title()} {self.last_name.title()}, How are you today? ")

user_1 = User('nemuel', 'palomo')

user_1.describe_user()
user_1.greet_user()<jupyter_output>Nemuel's last name is Palomo.

Hello Good Day! <NAME>, How are you today?<jupyter_text>9-4 Number Served<jupyter_code>class Restaurant:
  def __init__(self, restaurant_name, cuisine_type):
    self.restaurant_name = restaurant_name
    self.cuisine_type = cuisine_type
    self.number_served = 0

  def open_restaurant(self):
    print(f"The Restaurant {self.restaurant_name.title()} with a cuisine type of {self.cuisine_type.title()} is now open!.")

class restaurant(Restaurant):

  def set_number_served(self, served):
    self.number_served = served 

  def show_number_served(self):
    print(f"\nThe number of customers that were served is: {self.number_served}")
  

restaurant_1 = restaurant('los pollos hermanos', 'fast-food')


restaurant_1.open_restaurant()

restaurant_1.set_number_served(25)

restaurant_1.show_number_served()<jupyter_output>The Restaurant Los Pollos Hermanos with a cuisine type of Fast-Food is now open!.

The number of customers that were served is: 25<jupyter_text>9-5 Login Attempts<jupyter_code>class User:
  def __init__(self, first_name, last_name):
    self.first_name = first_name
    self.last_name = last_name
    self.login_attempts = 1

  def increment_login_attempts(self):
    self.login_attempts += 1

  def reset_login_attempts(self):
    self.login_attempts = 0

  def describe_user(self):
    print(f"{self.first_name.title()}'s last name is {self.last_name.title()}.")

  def greet_user(self):
    print(f"\nHello Good Day! {self.first_name.title()} {self.last_name.title()}, How are you today? ")



user_1 = User('nemuel', 'palomo')

user_1.describe_user()
user_1.greet_user()

print(f"\nAttempting to login 5 times...")
user_1.increment_login_attempts()
user_1.increment_login_attempts()
user_1.increment_login_attempts()
user_1.increment_login_attempts()

print(f"\n{user_1.first_name.title()} login attempts = {user_1.login_attempts}")

print(f"\n{user_1.first_name.title()} login is successful, resetting login attempts...")

user_1.reset_login_attempts()

print(f"\n{user_1.first_name.title()} login attempts = {user_1.login_attempts}")<jupyter_output>Nemuel's last name is Palomo.

Hello Good Day! <NAME>, How are you today? 

Attempting to login 5 times...

Nemuel login attempts = 5

Nemuel login is successful, resetting login attempts...

Nemuel login attempts = 0<jupyter_text>9-6 Ice Cream Stand<jupyter_code>class IceCreamStand(Restaurant):
  def __init__(self):
    self.flavors = ['vanilla', 'strawberry', 'caramel']

  def display_flavors(self):
    print(f"This ice cream stand have three different flavors which are: \n")
    for types in self.flavors:
      print(f"- {types.title()}")


yawastore = IceCreamStand()


yawastore.display_flavors()<jupyter_output>This ice cream stand have three different flavors which are: 

- Vanilla
- Strawberry
- Caramel<jupyter_text>9-7 Admin<jupyter_code>class User:
  def __init__(self, first_name, last_name):
    self.first_name = first_name
    self.last_name = last_name
    self.login_attempts = 1

  def increment_login_attempts(self):
    self.login_attempts += 1

  def reset_login_attempts(self):
    self.login_attempts = 0

  def describe_user(self):
    print(f"{self.first_name.title()}'s last name is {self.last_name.title()}.")

  def greet_user(self):
    print(f"\nHello Good Day! {self.first_name.title()} {self.last_name.title()}, How are you today? ")

class Admin(User):
  def __init__(self):
    self.privileges = Privileges()


    






admin = Admin()<jupyter_output><empty_output><jupyter_text>9-8 Privileges<jupyter_code>class User:
  def __init__(self, first_name, last_name):
    self.first_name = first_name
    self.last_name = last_name
    self.login_attempts = 0

  def increment_login_attempts(self):
    self.login_attempts += 1

  def reset_login_attempts(self):
    self.login_attempts = 0

  def describe_user(self):
    print(f"{self.first_name.title()}'s last name is {self.last_name.title()}.")

  def greet_user(self):
    print(f"\nGood Day {self.first_name.title()} {self.last_name.title()}!, How are you today? ")

class Admin(User):
  def __init__(self, first_name, last_name):
    super().__init__(first_name, last_name)
    self.privileges = Privileges()


class Privileges:
  def __init__(self, privileges=[]):
    self.privileges = privileges

  def show_privileges(self):
    print(f"\nPrivileges: \n")
    if self.privileges:
      for privilege in self.privileges:
        print(f"-{privilege}")
    else:
      print(f" - This user has no privileges.")


user0 = Admin('nemuel', 'palomo')

user0.describe_user()
user0.greet_user()

user0.privileges.show_privileges()

print("\nAdding user0 his admin privileges...\n")
user0.privileges.privileges = ['can ban', 'can kick', 'can mute']

user0.privileges.show_privileges()<jupyter_output>Nemuel's last name is Palomo.

Good Day <NAME>!, How are you today? 

Privileges: 

 - This user has no privileges.

Adding user0 his admin privileges...


Privileges: 

-can ban
-can kick
-can mute<jupyter_text>9-9 Battery Upgrade<jupyter_code>class Car:
     # A simple attempt to represent a car.
     def __init__(self, make, model, year):
         # Initialize attributes to describe a car.
         self.make = make
         self.model = model
         self.year = year
         self.odometer_reading = 0

     def get_descriptive_name(self):
         # Return a neatly formatted descriptive name.
         long_name = str(self.year) + " " + self.make + " " + self.model
         return long_name.title()

     def read_odometer(self):
         # Print a statement showing the car's mileage.
         print("This cas has " + str(self.odometer_reading) + " miles on it.")

     def update_odometer(self, mileage):
         # Set the odometer reading to the given value.
         # Reject the change if it attempts to roll the odometer back.
         if mileage >= self.odometer_reading:
             self.odometer_reading = mileage
         else:
             print("You can't roll back an odometer!")

     def increment_odometer(self, miles):
         # Add the given amount to the odometer reading.
         self.odometer_reading += miles

     def fill_gas_tank(self):
         print("This car needs a gas tank!")


class Battery:
    # A simple attempt to model a battery for an electric car.
    def __init__(self, battery_size=75):
        # Initialize the battery's attributes.
        self.battery_size = battery_size

    def describe_battery(self):
        # Print a statement describing the battery size.
        print("This car has a " + str(self.battery_size) + "-kWh battery.")

    def get_range(self):
        """Print a statement about the range this battery provides."""
        if self.battery_size == 75:
            range = 260
        elif self.battery_size == 100:
            range = 315
            
        message = f"This car can go approximately {range} miles on a full charge."
        print(message)

    def upgrade_battery(self):
        if self.battery_size == 75:
          self.battery_size = 100
        else:
          print(f"The battery is already upgraded!")


class ElectricCar(Car):
    # Represent aspects of a car, specific to electric vehicles.
    def __init__(self, make, model, year):
        # Initialize attributes of the parent class.
        # Then initialize attributes specific to an electric car.
        super().__init__(make, model, year)
        # self.battery_size = 70
        self.battery = Battery()

    # def describe_battery(self):
    #     # Print a statement describing the battery size.
    #     print("This car has a " + str(self.battery_size) + "-kWh battery.")

    def fill_gas_tank(self):
        # Electric cars don't have gas tanks.
        print("This car doesn\'t need a gas tank!")


car1 = ElectricCar('tesla', 'model n', '2027')

print(f"--- UPGRADING THE BATTERY TO 100-kWh ---")
car1.battery.upgrade_battery()


car1.battery.get_range()<jupyter_output>--- UPGRADING THE BATTERY TO 100-kWh ---
This car can go approximately 315 miles on a full charge.<jupyter_text>9-10 Imported Restaurant<jupyter_code>from restaurant import Restaurant

channel_club = Restaurant('the channel club', 'steak and seafood')
channel_club.describe_restaurant()
channel_club.open_restaurant()<jupyter_output><empty_output><jupyter_text>9-11 Imported Admin<jupyter_code>from user import Admin

eric = Admin('eric', 'matthes', 'e_matthes', '<EMAIL>', 'alaska')
eric.describe_user()

eric_privileges = [
    'can reset passwords',
    'can moderate discussions',
    'can suspend accounts',
    ]
eric.privileges.privileges = eric_privileges

print(f"\nThe admin {eric.username} has these privileges: ")
eric.privileges.show_privileges()<jupyter_output><empty_output><jupyter_text>9-12 Multiple Modules<jupyter_code>"""A collection of classes for modeling an admin user account."""

from user import User


class Admin(User):
    """A user with administrative privileges."""

    def __init__(self, first_name, last_name, username, email, location):
        """Initialize the admin."""
        super().__init__(first_name, last_name, username, email, location)
        
        # Initialize an empty set of privileges.
        self.privileges = Privileges()


class Privileges():
    """A class to store an admin's privileges."""

    def __init__(self, privileges=[]):
        self.privileges = privileges

    def show_privileges(self):
        print("\nPrivileges:")
        if self.privileges:
            for privilege in self.privileges:
                print(f"- {privilege}")
        else:
            print("- This user has no privileges.")
from admin import Admin

eric = Admin('eric', 'matthes', 'e_matthes', '<EMAIL>', 'al<PASSWORD>')
eric.describe_user()

eric_privileges = [
    'can reset passwords',
    'can moderate discussions',
    'can suspend accounts',
    ]
eric.privileges.privileges = eric_privileges

print(f"\nThe admin {eric.username} has these privileges: ")
eric.privileges.show_privileges()<jupyter_output><empty_output><jupyter_text>9-13 Dice<jupyter_code>from random import randint



class Die:

  def __init__(self, sides=6):
    self.sides = sides

  def roll_die(self):
    return randint(1, self.sides)

dice6 = Die()

results = []

for rolls in range(10):
  result = dice6.roll_die()
  results.append(result)

print("10 rolls of a 6 sided die: ")

print(results)<jupyter_output>10 rolls of a 6 sided die: 
[4, 5, 5, 1, 4, 1, 2, 5, 5, 2]<jupyter_text>9-14 Lottery<jupyter_code>from random import randint, choice


lotterynumbers = (2, 6, 3, 2, 5, 8, 9, 62, 99, 78)
results = []


while len(results) < 4:
  result = choice(lotterynumbers)

  if result not in results:
    print(f"We pulled the ticket {result}!")
    results.append(result)<jupyter_output>We pulled the ticket 2!
We pulled the ticket 5!
We pulled the ticket 99!
We pulled the ticket 78!<jupyter_text>9-15 Lottery Analysis<jupyter_code>from random import randint, choice

def get_winning_ticket(possibilities):
  """ Return a winning ticket from a set of possibilities."""

  winning_ticket = []

  while len(winning_ticket) < 4:
    pulled_item = choice(possibilities)

    if pulled_item not in winning_ticket:
      winning_ticket.append(pulled_item)

  return winning_ticket

def check_ticket(played_ticket, winning_ticket):
  # Check all elements in the played ticket. 
  # If they are not in the winning ticket, return False.
  for element in played_ticket:
    if element not in winning_ticket:
      return False

  
  return True


def make_random_ticket(possibilities):
  """ Return a random ticket from a set of possibilities. """

  ticket = []

  # We don't want to repeat numbers or letters, so we'll use a while loop.
  while len(ticket) < 4:
    pulled_item = choice(possibilities)

    # Only add the pulled item to the ticket if it hasn't already
    # been pulled.
    if pulled_item not in ticket:
      ticket.append(pulled_item)

  return ticket


possibilities = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 'a', 'b', 'c', 'd', 'e']
winning_ticket = get_winning_ticket(possibilities)

plays = 0
won = False

# Create a variable that sets a max number of tries

max_tries = 5000

while not won:
  new_ticket = make_random_ticket(possibilities)
  won = check_ticket(new_ticket, winning_ticket)
  plays += 1
  if plays >= max_tries:
    break

if won:
  print("We have a winning ticket!")
  print(f"Your ticket: {new_ticket}")
  print(f"Winning ticket: {winning_ticket}")
  print(f"It only took {plays} tries to win!")
else:
  print(f"Tried {plays} times, without pulling a winner. :( ")
  print(f"Your ticket: {new_ticket}")
  print(f"Winning ticket: {winning_ticket}")<jupyter_output>We have a winning ticket!
Your ticket: ['d', 'a', 1, 10]
Winning ticket: [10, 'a', 'd', 1]
It only took 2672 tries to win!<jupyter_text>9-16 Python Module of the Week<jupyter_code>""" One excellent resource for exploring the Python standard library is a site called 
Python Module of the Week. Goto https://pymotw.com/ and look at the table of contents. 
Find a module that looks interesting to you and read about it, perhaps starting with the random module """<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup