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 540c0c7..0000000 --- a/QuestionSets/PythonLanguage/BasicsAndArrays/Param_Kapur/Q3_Answer.py +++ /dev/null @@ -1,4 +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 cd425cd..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 d0206e3..0000000 --- a/QuestionSets/PythonLanguage/BasicsAndArrays/Rajat_Varma/Answer_1.py +++ /dev/null @@ -1,4 +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 4aa4b50..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 20a210c..0000000 --- a/QuestionSets/PythonLanguage/BasicsAndArrays/Rajat_Varma/Answer_3.py +++ /dev/null @@ -1,5 +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 2e0226f..0000000 --- a/QuestionSets/PythonLanguage/BasicsAndArrays/Rajat_Varma/Answer_4.py +++ /dev/null @@ -1,9 +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) 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..5c0f4c9 --- /dev/null +++ b/QuestionSets/PythonLanguage/ClassesAndObjects/Manan_Garg/main_classes.py @@ -0,0 +1,132 @@ +class Player(): + def __init__(self,w,x,y,z): + self.name = "" + self.age = w + self.movement_speed = x + self.health = y + self.money = z + + def move(self,speed): + if self.health < 0: + print (self.name + "is dead") + else: + self.movement_speed += speed + print (self.name + " is moving at " + str(self.movement_speed)) + + def stop(self): + if self.health < 0: + print (self.name + " is dead") + else: + self.movement_speed = 0 + print ("Movement speed of " + self.name + " is 0, it has stopped") + + 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 heal(self,hp): + self.health += hp + print ("Health of " + self.name + " is " + str(self.health)) + + def make_money(self,cash): + if self.health < 0: + print (self.name + " is dead") + else: + self.money += cash + print ("money of " + self.name + " is " + str(self.money)) + + def spend_money(self,cheque): + if self.health < 0: + print (self.name + " is dead") + else: + q = self.money - cheque + if q < 0: + print ("cant pay") + else: + self.money -= cheque + print ("money of " + self.name + " is " + str(self.money)) + + def stats(self): + if self.health < 0: + 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 + self.attack_power = z + + def move(self,speed): + if self.health < 0: + print (self.name + " is dead") + else: + self.movement_speed += speed + print (self.name + " is moving at " + str(self.movement_speed)) + + def stop(self): + if self.health < 0: + print (self.name + " is dead") + else: + self.movement_speed = 0 + print ("Movement speed of " + self.name + " is 0, it has stopped") + + def heal(self,hp): + self.health += hp + print ("health of " + self.name + " is " + str(self.health)) + + def booster(self,ammo): + if self.health < 0: + print (self.name + " is dead") + else: + self.attack_power += ammo + print ("attack power of " + self.name + " is " + str(self.attack_power)) + + def lessen_ammo(self,empty_ammo): + if self.health < 0: + print (self.name + " is 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 of " + self.name + " is " + str(self.attack_power)) + + def stats(self): + if self.health < 0: + 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 (self.name + " is dead") + else: + if Player = self.name: + print("Can't suicide") + 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) +