These are chat archives for andela/andela-21-lite

26th
May 2016
mayreeh
@mayreeh
May 26 2016 07:59
@andela-egichuri Awesome . Now Clear. I now very understand. Thank You Thank You.
Eric G
@egichuri
May 26 2016 11:46
@mayreeh :+1:
DennoKip
@DennoKip
May 26 2016 15:10
Another example of inheritance.....

```class Car(object):
condition = "new"
def init(self, model, color, mpg):
self.model = model
self.color = color
self.mpg = mpg
def display_car(self):
return "This is a "+my_car.color+" "+my_car.model+" with "+str(my_car.mpg)+" MPG."
def drive_car(self):
self.condition = "used"

class ElectricCar(Car):
def init(self,model,color,mpg,battery_type):
Car.init(self,model,color,mpg)
self.battery_type = battery_type

my_car = ElectricCar("BMW","Blue",99,'molten salt')
print my_car.display_car() ```

Eric G
@egichuri
May 26 2016 15:16
@DennoKip try wrap your code in one ` for single line and three ``` for multiline.
Note its (`) not (')
DennoKip
@DennoKip
May 26 2016 15:20
This message was deleted
DennoKip
@DennoKip
May 26 2016 15:34
class Car(object):
    condition = "new"
    def __init__(self, model, color, mpg):
        self.model = model
        self.color = color
        self.mpg   = mpg
    def display_car(self):
        return "This is a "+my_car.color+" "+my_car.model+" with "+str(my_car.mpg)+" MPG."
    def drive_car(self):
        self.condition = "used"

class ElectricCar(Car):
    def __init__(self,model,color,mpg,battery_type):
        Car.__init__(self,model,color,mpg)
        self.battery_type = battery_type

my_car = ElectricCar("BMW","Blue",99,'molten salt')
print my_car.display_car()
Beatrice
@Waihenya
May 26 2016 15:48
This message was deleted
mayreeh
@mayreeh
May 26 2016 15:48
Awesome @DennoKip , Thank you for this example.
@Waihenya ?? what kind of help :smile:
Beatrice
@Waihenya
May 26 2016 15:51
units = {
       'CS001': {'unit_name': 'Computer Literacy', 'core': True},
       'CS002': {'unit_name': 'Communication Skills', 'core': False},
       'CS003': {'unit_name': 'Introduction to Programming', 'core': False},
       'CS004': {'unit_name': 'Introduction to Computers', 'core': True},
       'CS005': {'unit_name': 'Discrete Mathematics', 'core': True} 
          }
how can i check whether the a certain key above holds a True value?
@mayreeh :point_up:
Beatrice
@Waihenya
May 26 2016 16:03
I mean am looking for a condition to check whether 'core ' holds a True or not
mayreeh
@mayreeh
May 26 2016 16:07
waaah thats a challenging one
but i would handle it this way
for key , value  in units.items():
    for k , v in value.items():
        if v is True:
            print key
where
from ur units , its a dictionary that has another dictionary in it, thats why i have looped twice
Beatrice
@Waihenya
May 26 2016 16:11
yeah, its nested.Let me try it out that way.Thanks.
Are you done with the exercise?
mayreeh
@mayreeh
May 26 2016 16:13
cool welcome.... am done halfway :( mine is returning funny results
Beatrice
@Waihenya
May 26 2016 16:22
@mayreeh that concept works..the items() func..Keep at it, am also halfway...you get funny results before you get the not funny ones.Maybe we can try it out together
:sweat_smile:
mayreeh
@mayreeh
May 26 2016 16:25
hahahaha "You get fuuny results before you get the not funny ones" you have made my night :smile:
:sweat_smile: :sweat_smile:
Beatrice
@Waihenya
May 26 2016 16:32
:laughing: :laughing:
mayreeh
@mayreeh
May 26 2016 16:37
@Waihenya ooh was wondering why you asked about getting core as True, (i hadn't even applied that to my exercise) after reading the instructions once again, now i get. Lemme apply, maybe no wonder my funny results...Thank you for the question :D
Beatrice
@Waihenya
May 26 2016 17:08
am not sure am trying out.Hope I will finally work it out @mayreeh
DennoKip
@DennoKip
May 26 2016 18:11
@Waihenya I used this code to check if core is true:
units[unit_code]["core"]==True
The unit_code above is a parameter for the enroll_unit method.
Beatrice
@Waihenya
May 26 2016 18:19
hmmmm ...trying to digest that @DennoKip .Thanks
have you seen that condition? :point_up: @mayreeh
mayreeh
@mayreeh
May 26 2016 18:45
@Waihenya , @DennoKip Waah , ... :+1: , wait , so u pass the parameter at unit_code everytime one feeds in a course to the method?