From 5f601cf4cca81d4030a9b198dd7885d0bca34395 Mon Sep 17 00:00:00 2001 From: Manan1504 Date: Tue, 1 May 2018 21:38:50 +0530 Subject: [PATCH 1/8] added solution --- QuestionSets/PythonLanguage/BasicsAndArrays/manan garg/test.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 QuestionSets/PythonLanguage/BasicsAndArrays/manan garg/test.py diff --git a/QuestionSets/PythonLanguage/BasicsAndArrays/manan garg/test.py b/QuestionSets/PythonLanguage/BasicsAndArrays/manan garg/test.py new file mode 100644 index 0000000..8cde782 --- /dev/null +++ b/QuestionSets/PythonLanguage/BasicsAndArrays/manan garg/test.py @@ -0,0 +1 @@ +print("hello world") From 05223600ff4b1d730c73da0aa103477816e44c93 Mon Sep 17 00:00:00 2001 From: Manan1504 Date: Wed, 2 May 2018 10:20:45 +0530 Subject: [PATCH 2/8] added 3 solutions --- .../BasicsAndArrays/Manan_Garg/sol1_manan.py | 5 +++++ .../BasicsAndArrays/Manan_Garg/sol_2manan.py | 6 ++++++ .../BasicsAndArrays/Manan_Garg/sol_4manan.py | 8 ++++++++ .../PythonLanguage/BasicsAndArrays/manan garg/test.py | 1 - 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 QuestionSets/PythonLanguage/BasicsAndArrays/Manan_Garg/sol1_manan.py create mode 100644 QuestionSets/PythonLanguage/BasicsAndArrays/Manan_Garg/sol_2manan.py create mode 100644 QuestionSets/PythonLanguage/BasicsAndArrays/Manan_Garg/sol_4manan.py delete mode 100644 QuestionSets/PythonLanguage/BasicsAndArrays/manan garg/test.py diff --git a/QuestionSets/PythonLanguage/BasicsAndArrays/Manan_Garg/sol1_manan.py b/QuestionSets/PythonLanguage/BasicsAndArrays/Manan_Garg/sol1_manan.py new file mode 100644 index 0000000..bca3b55 --- /dev/null +++ b/QuestionSets/PythonLanguage/BasicsAndArrays/Manan_Garg/sol1_manan.py @@ -0,0 +1,5 @@ +Array = [] +A = range(0,1000) +for i in A: + Array.append(i+1) +print (Array) diff --git a/QuestionSets/PythonLanguage/BasicsAndArrays/Manan_Garg/sol_2manan.py b/QuestionSets/PythonLanguage/BasicsAndArrays/Manan_Garg/sol_2manan.py new file mode 100644 index 0000000..02fa899 --- /dev/null +++ b/QuestionSets/PythonLanguage/BasicsAndArrays/Manan_Garg/sol_2manan.py @@ -0,0 +1,6 @@ +x = 0 +A = range(0,1001) +for i in A: + x += i +print(x) + diff --git a/QuestionSets/PythonLanguage/BasicsAndArrays/Manan_Garg/sol_4manan.py b/QuestionSets/PythonLanguage/BasicsAndArrays/Manan_Garg/sol_4manan.py new file mode 100644 index 0000000..99d60e7 --- /dev/null +++ b/QuestionSets/PythonLanguage/BasicsAndArrays/Manan_Garg/sol_4manan.py @@ -0,0 +1,8 @@ +A = [1,2,3,4,5,6,7,8,9,10] +Ans = [] +for i in A: + O_i = [] + for x in A: + O_i.append(i*x) + Ans.append(O_i) +print (Ans) diff --git a/QuestionSets/PythonLanguage/BasicsAndArrays/manan garg/test.py b/QuestionSets/PythonLanguage/BasicsAndArrays/manan garg/test.py deleted file mode 100644 index 8cde782..0000000 --- a/QuestionSets/PythonLanguage/BasicsAndArrays/manan garg/test.py +++ /dev/null @@ -1 +0,0 @@ -print("hello world") From b4ceb2b91cf88720306939a292e47f3dc8565ffb Mon Sep 17 00:00:00 2001 From: Manan1504 Date: Sat, 5 May 2018 22:08:16 +0530 Subject: [PATCH 3/8] solution --- .../BasicsAndArrays/Manan_Garg/sol1_manan.py | 6 +----- .../BasicsAndArrays/Manan_Garg/sol_3manan.py | 3 +++ .../BasicsAndArrays/Param_Kapur/Q1_Answer.py | 1 - .../BasicsAndArrays/Param_Kapur/Q2_Answer.py | 8 -------- .../BasicsAndArrays/Param_Kapur/Q3_Answer.py | 3 --- .../BasicsAndArrays/Param_Kapur/Q4_Answer.py | 8 -------- .../BasicsAndArrays/Rajat_Varma/Answer_1.py | 3 --- .../BasicsAndArrays/Rajat_Varma/Answer_2.py | 4 ---- .../BasicsAndArrays/Rajat_Varma/Answer_3.py | 4 ---- .../BasicsAndArrays/Rajat_Varma/Answer_4.py | 8 -------- 10 files changed, 4 insertions(+), 44 deletions(-) create mode 100644 QuestionSets/PythonLanguage/BasicsAndArrays/Manan_Garg/sol_3manan.py delete mode 100644 QuestionSets/PythonLanguage/BasicsAndArrays/Param_Kapur/Q1_Answer.py delete mode 100644 QuestionSets/PythonLanguage/BasicsAndArrays/Param_Kapur/Q2_Answer.py delete mode 100644 QuestionSets/PythonLanguage/BasicsAndArrays/Param_Kapur/Q3_Answer.py delete mode 100644 QuestionSets/PythonLanguage/BasicsAndArrays/Param_Kapur/Q4_Answer.py delete mode 100644 QuestionSets/PythonLanguage/BasicsAndArrays/Rajat_Varma/Answer_1.py delete mode 100644 QuestionSets/PythonLanguage/BasicsAndArrays/Rajat_Varma/Answer_2.py delete mode 100644 QuestionSets/PythonLanguage/BasicsAndArrays/Rajat_Varma/Answer_3.py delete mode 100644 QuestionSets/PythonLanguage/BasicsAndArrays/Rajat_Varma/Answer_4.py diff --git a/QuestionSets/PythonLanguage/BasicsAndArrays/Manan_Garg/sol1_manan.py b/QuestionSets/PythonLanguage/BasicsAndArrays/Manan_Garg/sol1_manan.py index bca3b55..bdf5714 100644 --- a/QuestionSets/PythonLanguage/BasicsAndArrays/Manan_Garg/sol1_manan.py +++ b/QuestionSets/PythonLanguage/BasicsAndArrays/Manan_Garg/sol1_manan.py @@ -1,5 +1 @@ -Array = [] -A = range(0,1000) -for i in A: - Array.append(i+1) -print (Array) +print (range(1,1001)) diff --git a/QuestionSets/PythonLanguage/BasicsAndArrays/Manan_Garg/sol_3manan.py b/QuestionSets/PythonLanguage/BasicsAndArrays/Manan_Garg/sol_3manan.py new file mode 100644 index 0000000..9ba7122 --- /dev/null +++ b/QuestionSets/PythonLanguage/BasicsAndArrays/Manan_Garg/sol_3manan.py @@ -0,0 +1,3 @@ +import numpy as np +A = np.arange(0,6,1).reshape(3,2) +print (A) diff --git a/QuestionSets/PythonLanguage/BasicsAndArrays/Param_Kapur/Q1_Answer.py b/QuestionSets/PythonLanguage/BasicsAndArrays/Param_Kapur/Q1_Answer.py deleted file mode 100644 index 1253f69..0000000 --- a/QuestionSets/PythonLanguage/BasicsAndArrays/Param_Kapur/Q1_Answer.py +++ /dev/null @@ -1 +0,0 @@ -range(1000) diff --git a/QuestionSets/PythonLanguage/BasicsAndArrays/Param_Kapur/Q2_Answer.py b/QuestionSets/PythonLanguage/BasicsAndArrays/Param_Kapur/Q2_Answer.py deleted file mode 100644 index 1436637..0000000 --- a/QuestionSets/PythonLanguage/BasicsAndArrays/Param_Kapur/Q2_Answer.py +++ /dev/null @@ -1,8 +0,0 @@ -n = 1000 -i = 1 -total = 0 -while i <= n: - total += i - i += 1 - -print(total) diff --git a/QuestionSets/PythonLanguage/BasicsAndArrays/Param_Kapur/Q3_Answer.py b/QuestionSets/PythonLanguage/BasicsAndArrays/Param_Kapur/Q3_Answer.py deleted file mode 100644 index 9023cbe..0000000 --- a/QuestionSets/PythonLanguage/BasicsAndArrays/Param_Kapur/Q3_Answer.py +++ /dev/null @@ -1,3 +0,0 @@ -import numpy as np -foo = np.arange(1, 7).reshape(3, 2) -print(foo) diff --git a/QuestionSets/PythonLanguage/BasicsAndArrays/Param_Kapur/Q4_Answer.py b/QuestionSets/PythonLanguage/BasicsAndArrays/Param_Kapur/Q4_Answer.py deleted file mode 100644 index 3b251cb..0000000 --- a/QuestionSets/PythonLanguage/BasicsAndArrays/Param_Kapur/Q4_Answer.py +++ /dev/null @@ -1,8 +0,0 @@ -import numpy as np -doo = np.array([], dtype = int) -for i in np.arange(1, 11): - foo = np.array([np.arange(i, 11*i, i)]) - doo = np.append(doo, foo) -doo = doo.reshape(10,10) -print(doo) - diff --git a/QuestionSets/PythonLanguage/BasicsAndArrays/Rajat_Varma/Answer_1.py b/QuestionSets/PythonLanguage/BasicsAndArrays/Rajat_Varma/Answer_1.py deleted file mode 100644 index ca140ab..0000000 --- a/QuestionSets/PythonLanguage/BasicsAndArrays/Rajat_Varma/Answer_1.py +++ /dev/null @@ -1,3 +0,0 @@ -import numpy as np -x = np.arange(1, 1001) -print(x) diff --git a/QuestionSets/PythonLanguage/BasicsAndArrays/Rajat_Varma/Answer_2.py b/QuestionSets/PythonLanguage/BasicsAndArrays/Rajat_Varma/Answer_2.py deleted file mode 100644 index 19f6676..0000000 --- a/QuestionSets/PythonLanguage/BasicsAndArrays/Rajat_Varma/Answer_2.py +++ /dev/null @@ -1,4 +0,0 @@ -count = 0 -for i in range(1, 1001): - count+=i -print(count) diff --git a/QuestionSets/PythonLanguage/BasicsAndArrays/Rajat_Varma/Answer_3.py b/QuestionSets/PythonLanguage/BasicsAndArrays/Rajat_Varma/Answer_3.py deleted file mode 100644 index 146763c..0000000 --- a/QuestionSets/PythonLanguage/BasicsAndArrays/Rajat_Varma/Answer_3.py +++ /dev/null @@ -1,4 +0,0 @@ -import numpy as np -x = np.arange(1,6) -x = x.reshape(3,2) -print(x) diff --git a/QuestionSets/PythonLanguage/BasicsAndArrays/Rajat_Varma/Answer_4.py b/QuestionSets/PythonLanguage/BasicsAndArrays/Rajat_Varma/Answer_4.py deleted file mode 100644 index 8e0de71..0000000 --- a/QuestionSets/PythonLanguage/BasicsAndArrays/Rajat_Varma/Answer_4.py +++ /dev/null @@ -1,8 +0,0 @@ -import numpy as np -x = np.array([], dtype = int) -for i in range(1, 11): - for j in range(1, 11): - x = np.append(x, i*j) - -x = x.reshape(10,10) -print(x) From 5bca39ede868dc50be84463bf653b6ac25a59edd Mon Sep 17 00:00:00 2001 From: Manan 1504 Date: Thu, 17 May 2018 14:54:05 +0530 Subject: [PATCH 4/8] sorry for delay --- .../Manan_Garg/main_classes.py | 125 ++++++++++++++++++ .../ClassesAndObjects/Manan_Garg/run_code.py | 21 +++ 2 files changed, 146 insertions(+) create mode 100644 QuestionSets/PythonLanguage/ClassesAndObjects/Manan_Garg/main_classes.py create mode 100644 QuestionSets/PythonLanguage/ClassesAndObjects/Manan_Garg/run_code.py diff --git a/QuestionSets/PythonLanguage/ClassesAndObjects/Manan_Garg/main_classes.py b/QuestionSets/PythonLanguage/ClassesAndObjects/Manan_Garg/main_classes.py new file mode 100644 index 0000000..22673b1 --- /dev/null +++ b/QuestionSets/PythonLanguage/ClassesAndObjects/Manan_Garg/main_classes.py @@ -0,0 +1,125 @@ +class Player(): + def __init__(self,w,x,y,z): + self.age = w + self.movement_speed = x + self.health = y + self.money = z + + def move(self,speed): + if self.health < 0: + print ("you are dead") + else: + self.movement_speed += speed + print ("moving at " + str(self.movement_speed)) + + def stop(self): + if self.health < 0: + print ("you are dead") + else: + self.movement_speed = 0 + print ("movement speed is 0, you have stopped") + + def take_damage(self,damage): + self.health -= damage + if self.health <= 0: + print ("You are dead") + else: + print ("health is " + str(self.health)) + + def heal(self,hp): + self.health += hp + print ("health is " + str(self.health)) + + def make_money(self,cash): + if self.health < 0: + print ("you are dead") + else: + self.money += cash + print ("money is " + str(self.money)) + + def spend_money(self,cheque): + if self.health < 0: + print ("you are dead") + else: + q = self.money - cheque + if q < 0: + print ("cant pay") + else: + self.money -= cheque + print ("money is" + str(self.money)) + + def stats(self): + if self.health < 0: + print ("you are dead") + else: + print("age is " + str(self.age)) + print("health is " + str(self.health)) + print("speed is " + str(self.movement_speed)) + print("money is " + str(self.money)) + +class Enemy(): + def __init__(self,w,x,y,z): + self.age = w + self.movement_speed = x + self.health = y + self.attack_power = z + + def move(self,speed): + if self.health < 0: + print ("you are dead") + else: + self.movement_speed += speed + print ("moving at " + str(self.movement_speed)) + + def stop(self): + if self.health < 0: + print ("you are dead") + else: + self.movement_speed = 0 + print ("movement speed is 0, you have stopped") + + def take_damage(self,damage): + self.health -= damage + if self.health <= 0: + print ("You are dead") + else: + print ("health is " + str(self.health)) + + def heal(self,hp): + self.health += hp + print ("health is " + str(self.health)) + + def booster(self,ammo): + if self.health < 0: + print ("you are dead") + else: + self.attack_power += ammo + print ("attack power is " + str(self.attack_power)) + + def lessen_ammo(self,empty_ammo): + if self.health < 0: + print ("you are dead") + else: + q = self.attack_power - empty_ammo + if q <= 0: + print ("ammo finished") + self.attack_power = 0 + print ("ammo gone") + else: + self.attack_power -= empty_ammo + print ("attack power is" + str(self.attack_power)) + + def stats(self): + if self.health < 0: + print ("you are dead") + else: + print("age is " + str(self.age)) + print("health is " + str(self.health)) + print("speed is " + str(self.movement_speed)) + print("attack power is " + str(self.attack_power)) + + def attack(self,Player): + if self.health < 0: + print ("you are dead") + else: + Player.take_damage(self.attack_power) diff --git a/QuestionSets/PythonLanguage/ClassesAndObjects/Manan_Garg/run_code.py b/QuestionSets/PythonLanguage/ClassesAndObjects/Manan_Garg/run_code.py new file mode 100644 index 0000000..d43a98b --- /dev/null +++ b/QuestionSets/PythonLanguage/ClassesAndObjects/Manan_Garg/run_code.py @@ -0,0 +1,21 @@ +import main_classes as mc + +Modi = mc.Player(20,30,40,50) +Modi.move(30) +Modi.stop() +Modi.take_damage(50) +Modi.heal(50) +Modi.spend_money(60) +Modi.make_money(100) +Modi.stats() + +Rahul = mc.Enemy(20,30,40,50) +Rahul.move(30) +Rahul.stop() +Rahul.take_damage(50) +Rahul.heal(50) +Rahul.booster(60) +Rahul.lessen_ammo(100) +Rahul.stats() +Rahul.attack(Modi) + From b58c9d8736a315c386a742759da64500faa1d6bb Mon Sep 17 00:00:00 2001 From: Manan1504 Date: Tue, 1 May 2018 21:38:50 +0530 Subject: [PATCH 5/8] added solution --- QuestionSets/PythonLanguage/BasicsAndArrays/manan garg/test.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 QuestionSets/PythonLanguage/BasicsAndArrays/manan garg/test.py diff --git a/QuestionSets/PythonLanguage/BasicsAndArrays/manan garg/test.py b/QuestionSets/PythonLanguage/BasicsAndArrays/manan garg/test.py new file mode 100644 index 0000000..8cde782 --- /dev/null +++ b/QuestionSets/PythonLanguage/BasicsAndArrays/manan garg/test.py @@ -0,0 +1 @@ +print("hello world") From 6e7214a623c2ddc2b6e2ce2d187a65e84e3986ec Mon Sep 17 00:00:00 2001 From: Manan1504 Date: Wed, 2 May 2018 10:20:45 +0530 Subject: [PATCH 6/8] added 3 solutions --- .../BasicsAndArrays/Manan_Garg/sol1_manan.py | 5 +++++ .../BasicsAndArrays/Manan_Garg/sol_2manan.py | 6 ++++++ .../BasicsAndArrays/Manan_Garg/sol_4manan.py | 8 ++++++++ .../PythonLanguage/BasicsAndArrays/manan garg/test.py | 1 - 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 QuestionSets/PythonLanguage/BasicsAndArrays/Manan_Garg/sol1_manan.py create mode 100644 QuestionSets/PythonLanguage/BasicsAndArrays/Manan_Garg/sol_2manan.py create mode 100644 QuestionSets/PythonLanguage/BasicsAndArrays/Manan_Garg/sol_4manan.py delete mode 100644 QuestionSets/PythonLanguage/BasicsAndArrays/manan garg/test.py diff --git a/QuestionSets/PythonLanguage/BasicsAndArrays/Manan_Garg/sol1_manan.py b/QuestionSets/PythonLanguage/BasicsAndArrays/Manan_Garg/sol1_manan.py new file mode 100644 index 0000000..bca3b55 --- /dev/null +++ b/QuestionSets/PythonLanguage/BasicsAndArrays/Manan_Garg/sol1_manan.py @@ -0,0 +1,5 @@ +Array = [] +A = range(0,1000) +for i in A: + Array.append(i+1) +print (Array) diff --git a/QuestionSets/PythonLanguage/BasicsAndArrays/Manan_Garg/sol_2manan.py b/QuestionSets/PythonLanguage/BasicsAndArrays/Manan_Garg/sol_2manan.py new file mode 100644 index 0000000..02fa899 --- /dev/null +++ b/QuestionSets/PythonLanguage/BasicsAndArrays/Manan_Garg/sol_2manan.py @@ -0,0 +1,6 @@ +x = 0 +A = range(0,1001) +for i in A: + x += i +print(x) + diff --git a/QuestionSets/PythonLanguage/BasicsAndArrays/Manan_Garg/sol_4manan.py b/QuestionSets/PythonLanguage/BasicsAndArrays/Manan_Garg/sol_4manan.py new file mode 100644 index 0000000..99d60e7 --- /dev/null +++ b/QuestionSets/PythonLanguage/BasicsAndArrays/Manan_Garg/sol_4manan.py @@ -0,0 +1,8 @@ +A = [1,2,3,4,5,6,7,8,9,10] +Ans = [] +for i in A: + O_i = [] + for x in A: + O_i.append(i*x) + Ans.append(O_i) +print (Ans) diff --git a/QuestionSets/PythonLanguage/BasicsAndArrays/manan garg/test.py b/QuestionSets/PythonLanguage/BasicsAndArrays/manan garg/test.py deleted file mode 100644 index 8cde782..0000000 --- a/QuestionSets/PythonLanguage/BasicsAndArrays/manan garg/test.py +++ /dev/null @@ -1 +0,0 @@ -print("hello world") From d3af0c3e460528588616f45ecdd1207c7e2eea0e Mon Sep 17 00:00:00 2001 From: Manan 1504 Date: Thu, 17 May 2018 14:54:05 +0530 Subject: [PATCH 7/8] sorry for delay --- .../Manan_Garg/main_classes.py | 125 ++++++++++++++++++ .../ClassesAndObjects/Manan_Garg/run_code.py | 21 +++ 2 files changed, 146 insertions(+) create mode 100644 QuestionSets/PythonLanguage/ClassesAndObjects/Manan_Garg/main_classes.py create mode 100644 QuestionSets/PythonLanguage/ClassesAndObjects/Manan_Garg/run_code.py diff --git a/QuestionSets/PythonLanguage/ClassesAndObjects/Manan_Garg/main_classes.py b/QuestionSets/PythonLanguage/ClassesAndObjects/Manan_Garg/main_classes.py new file mode 100644 index 0000000..22673b1 --- /dev/null +++ b/QuestionSets/PythonLanguage/ClassesAndObjects/Manan_Garg/main_classes.py @@ -0,0 +1,125 @@ +class Player(): + def __init__(self,w,x,y,z): + self.age = w + self.movement_speed = x + self.health = y + self.money = z + + def move(self,speed): + if self.health < 0: + print ("you are dead") + else: + self.movement_speed += speed + print ("moving at " + str(self.movement_speed)) + + def stop(self): + if self.health < 0: + print ("you are dead") + else: + self.movement_speed = 0 + print ("movement speed is 0, you have stopped") + + def take_damage(self,damage): + self.health -= damage + if self.health <= 0: + print ("You are dead") + else: + print ("health is " + str(self.health)) + + def heal(self,hp): + self.health += hp + print ("health is " + str(self.health)) + + def make_money(self,cash): + if self.health < 0: + print ("you are dead") + else: + self.money += cash + print ("money is " + str(self.money)) + + def spend_money(self,cheque): + if self.health < 0: + print ("you are dead") + else: + q = self.money - cheque + if q < 0: + print ("cant pay") + else: + self.money -= cheque + print ("money is" + str(self.money)) + + def stats(self): + if self.health < 0: + print ("you are dead") + else: + print("age is " + str(self.age)) + print("health is " + str(self.health)) + print("speed is " + str(self.movement_speed)) + print("money is " + str(self.money)) + +class Enemy(): + def __init__(self,w,x,y,z): + self.age = w + self.movement_speed = x + self.health = y + self.attack_power = z + + def move(self,speed): + if self.health < 0: + print ("you are dead") + else: + self.movement_speed += speed + print ("moving at " + str(self.movement_speed)) + + def stop(self): + if self.health < 0: + print ("you are dead") + else: + self.movement_speed = 0 + print ("movement speed is 0, you have stopped") + + def take_damage(self,damage): + self.health -= damage + if self.health <= 0: + print ("You are dead") + else: + print ("health is " + str(self.health)) + + def heal(self,hp): + self.health += hp + print ("health is " + str(self.health)) + + def booster(self,ammo): + if self.health < 0: + print ("you are dead") + else: + self.attack_power += ammo + print ("attack power is " + str(self.attack_power)) + + def lessen_ammo(self,empty_ammo): + if self.health < 0: + print ("you are dead") + else: + q = self.attack_power - empty_ammo + if q <= 0: + print ("ammo finished") + self.attack_power = 0 + print ("ammo gone") + else: + self.attack_power -= empty_ammo + print ("attack power is" + str(self.attack_power)) + + def stats(self): + if self.health < 0: + print ("you are dead") + else: + print("age is " + str(self.age)) + print("health is " + str(self.health)) + print("speed is " + str(self.movement_speed)) + print("attack power is " + str(self.attack_power)) + + def attack(self,Player): + if self.health < 0: + print ("you are dead") + else: + Player.take_damage(self.attack_power) diff --git a/QuestionSets/PythonLanguage/ClassesAndObjects/Manan_Garg/run_code.py b/QuestionSets/PythonLanguage/ClassesAndObjects/Manan_Garg/run_code.py new file mode 100644 index 0000000..d43a98b --- /dev/null +++ b/QuestionSets/PythonLanguage/ClassesAndObjects/Manan_Garg/run_code.py @@ -0,0 +1,21 @@ +import main_classes as mc + +Modi = mc.Player(20,30,40,50) +Modi.move(30) +Modi.stop() +Modi.take_damage(50) +Modi.heal(50) +Modi.spend_money(60) +Modi.make_money(100) +Modi.stats() + +Rahul = mc.Enemy(20,30,40,50) +Rahul.move(30) +Rahul.stop() +Rahul.take_damage(50) +Rahul.heal(50) +Rahul.booster(60) +Rahul.lessen_ammo(100) +Rahul.stats() +Rahul.attack(Modi) + From 7576f323135379a09e29429be5a94a15ed5e26ec Mon Sep 17 00:00:00 2001 From: Manan 1504 Date: Sat, 2 Jun 2018 11:37:41 +0530 Subject: [PATCH 8/8] small change --- .../Manan_Garg/main_classes.py | 69 ++++++++++--------- 1 file changed, 38 insertions(+), 31 deletions(-) diff --git a/QuestionSets/PythonLanguage/ClassesAndObjects/Manan_Garg/main_classes.py b/QuestionSets/PythonLanguage/ClassesAndObjects/Manan_Garg/main_classes.py index 22673b1..5c0f4c9 100644 --- a/QuestionSets/PythonLanguage/ClassesAndObjects/Manan_Garg/main_classes.py +++ b/QuestionSets/PythonLanguage/ClassesAndObjects/Manan_Garg/main_classes.py @@ -1,5 +1,6 @@ class Player(): def __init__(self,w,x,y,z): + self.name = "" self.age = w self.movement_speed = x self.health = y @@ -7,58 +8,60 @@ def __init__(self,w,x,y,z): def move(self,speed): if self.health < 0: - print ("you are dead") + print (self.name + "is dead") else: self.movement_speed += speed - print ("moving at " + str(self.movement_speed)) + print (self.name + " is moving at " + str(self.movement_speed)) def stop(self): if self.health < 0: - print ("you are dead") + print (self.name + " is dead") else: self.movement_speed = 0 - print ("movement speed is 0, you have stopped") + print ("Movement speed of " + self.name + " is 0, it has stopped") def take_damage(self,damage): self.health -= damage if self.health <= 0: - print ("You are dead") + print (self.name + " is dead") else: - print ("health is " + str(self.health)) + print ("Health of " + self.name + " is " + str(self.health)) def heal(self,hp): self.health += hp - print ("health is " + str(self.health)) + print ("Health of " + self.name + " is " + str(self.health)) def make_money(self,cash): if self.health < 0: - print ("you are dead") + print (self.name + " is dead") else: self.money += cash - print ("money is " + str(self.money)) + print ("money of " + self.name + " is " + str(self.money)) def spend_money(self,cheque): if self.health < 0: - print ("you are dead") + print (self.name + " is dead") else: q = self.money - cheque if q < 0: print ("cant pay") else: self.money -= cheque - print ("money is" + str(self.money)) + print ("money of " + self.name + " is " + str(self.money)) def stats(self): if self.health < 0: - print ("you are dead") + print (self.name + " is dead") else: print("age is " + str(self.age)) print("health is " + str(self.health)) print("speed is " + str(self.movement_speed)) print("money is " + str(self.money)) + class Enemy(): def __init__(self,w,x,y,z): + self.name = "" self.age = w self.movement_speed = x self.health = y @@ -66,39 +69,32 @@ def __init__(self,w,x,y,z): def move(self,speed): if self.health < 0: - print ("you are dead") + print (self.name + " is dead") else: self.movement_speed += speed - print ("moving at " + str(self.movement_speed)) + print (self.name + " is moving at " + str(self.movement_speed)) def stop(self): if self.health < 0: - print ("you are dead") + print (self.name + " is dead") else: self.movement_speed = 0 - print ("movement speed is 0, you have stopped") - - def take_damage(self,damage): - self.health -= damage - if self.health <= 0: - print ("You are dead") - else: - print ("health is " + str(self.health)) + print ("Movement speed of " + self.name + " is 0, it has stopped") def heal(self,hp): self.health += hp - print ("health is " + str(self.health)) + print ("health of " + self.name + " is " + str(self.health)) def booster(self,ammo): if self.health < 0: - print ("you are dead") + print (self.name + " is dead") else: self.attack_power += ammo - print ("attack power is " + str(self.attack_power)) + print ("attack power of " + self.name + " is " + str(self.attack_power)) def lessen_ammo(self,empty_ammo): if self.health < 0: - print ("you are dead") + print (self.name + " is dead") else: q = self.attack_power - empty_ammo if q <= 0: @@ -107,19 +103,30 @@ def lessen_ammo(self,empty_ammo): print ("ammo gone") else: self.attack_power -= empty_ammo - print ("attack power is" + str(self.attack_power)) + print ("attack power of " + self.name + " is " + str(self.attack_power)) def stats(self): if self.health < 0: - print ("you are dead") + print (self.name + " is dead") else: print("age is " + str(self.age)) print("health is " + str(self.health)) print("speed is " + str(self.movement_speed)) print("attack power is " + str(self.attack_power)) + def take_damage(self,damage): + self.health -= damage + if self.health <= 0: + print (self.name + " is dead") + else: + print ("Health of " + self.name + " is " + str(self.health)) + def attack(self,Player): if self.health < 0: - print ("you are dead") + print (self.name + " is dead") else: - Player.take_damage(self.attack_power) + if Player = self.name: + print("Can't suicide") + else: + Player.take_damage(self.attack_power) +