American Young Coder (AYC)

AYC logo
Loading Events

« All Events

  • This event has passed.

5 PM – Python OOP – Bill

May 10, 2022 @ 5:00 pm - 6:00 pm

Today We:
  1. Reviewed HW and attributes of a class that have a default value
  2. Added a gas_tank attribute that also has a default value
  3. Made a fill_gas_tank method
  4. Added a drive method that lets the car use up gas
  5. Created a new empty list variable called garage
  6. Filled the garage list with a bunch of car instances
  7. Looped through each car in the garage and printed them out
  8. Learned how to only print out a car that meets specific criteria like printing out only toyota cars
Your HW:
  1. Open your restaurant class hw
  2. Do Page 167 – TRY IT YOURSELF
  3. Download and install latest Python from: https://www.python.org/downloads/
  4. Download and install latest Community Edition Pycharm: https://www.jetbrains.com/pycharm/download/
  5. Optional Practice On the Car Class:
    • Make a max_gas_tank atribute that needs to be in the __init__ function
    • Make it so the gas_tank default atribute cannot be greater than the max_gas_tank attribute in the fill_gas_tank method
    • Create another new atribute, miles_per_gallon, that also needs to be in the __init__ function
    • Make it so in the drive method, instead of dividing the distance by 50 for the gas_consumption variable, divide the distance by the miles_per_gallon attribute.
    • Make sure that anytime you created a new car to specify the new max_gas_tank attribute and the miles_per_gallon attribute.

Details

Date:
May 10, 2022
Time:
5:00 pm - 6:00 pm
Verified by MonsterInsights