From f663a5a4f13038f80952dcc33c4a645554783d9d Mon Sep 17 00:00:00 2001
From: Yohaan <yozaam@gmail.com>
Date: Wed, 4 Nov 2020 02:42:06 +0000
Subject: [PATCH] Day 12 object constructor

---
 aptitude_quant.md        | 13 ++++++++++++-
 day12_list_of_objects.py | 19 +++++++++++++++++++
 main.py                  | 32 ++++++++++----------------------
 3 files changed, 41 insertions(+), 23 deletions(-)
 create mode 100644 day12_list_of_objects.py

diff --git a/aptitude_quant.md b/aptitude_quant.md
index 7454595..4814921 100644
--- a/aptitude_quant.md
+++ b/aptitude_quant.md
@@ -231,4 +231,15 @@ Q. a,b fill in 20,30 mins c can drain full tank in x mins
 sirs method:  
 `a = 15/20 = 75% `  
 `b = 15/30 = 50% `  
-`overflow = 25% in 15 mins, 100% in 15x4=60 mins :)`
\ No newline at end of file
+`overflow = 25% in 15 mins, 100% in 15x4=60 mins :)`
+
+## Day 5, Time Speed Distance
+
+`ST = D`  
+
+Case: T is constant: `S is directly proportional to D`  
+
+Case: S is constant: `T is directly proportional to D`
+
+Case D is constant:  `S is inversely proportional to T`
+
diff --git a/day12_list_of_objects.py b/day12_list_of_objects.py
new file mode 100644
index 0000000..f50b62f
--- /dev/null
+++ b/day12_list_of_objects.py
@@ -0,0 +1,19 @@
+# Required concepts: https://www.w3schools.com/python/python_intro.asp OOPS & list comprehension
+
+print('Question: Make a list of objects with different properties')
+
+class Bird:
+  def __init__(self,name,color):
+    # this constructor creates a Bird with name
+    self.name = name
+    self.color = color
+
+all_names = ['parrot', 'ostrich']
+all_colors = ['green', 'blue']
+# n: no. of birds
+n = len(all_names)
+
+all_birds = [Bird(all_names[i],all_colors[i]) for i in range(n)]
+
+for bird in all_birds:
+  print(bird.name, bird.color)
diff --git a/main.py b/main.py
index 5c83d18..febed81 100644
--- a/main.py
+++ b/main.py
@@ -1,27 +1,15 @@
-# Required concepts: https://www.w3schools.com/python/python_file_handling.asp file handling
-import os
+# Required concepts: https://www.w3schools.com/python/python_intro.asp OOPS & list comprehension
 
-print('Question: Find money owed to friends')
+print('Question: Make a list of objects with different names')
 
+class Bird:
+  def __init__(self,name):
+    # this constructor creates a Bird with name
+    self.name = name
 
-def update_file(name, amount):
-    path = 'tmp/' + name + '.txt'
-    # get current amount
-    reader = open(path, 'r')
-    current_amount = int('0'+reader.read())
-    # write the new amount
-    writer = open(path, 'w')
-    writer.write(str(current_amount + amount))
+all_names = ['parrot', 'ostrich']
 
+all_birds = [Bird(name) for name in all_names]
 
-names = ['raj', 'riya', 'raj']
-amounts = [1000, 200, 300]
-
-# # first make empty files for all :)
-for name in names:
-    open('tmp/'+name+'.txt','w')
-
-for name, amount in zip(names, amounts):
-    update_file(name, amount)
-
-print('Made the files with total debts')
+for bird in all_birds:
+  print(bird.name)
\ No newline at end of file