# Tutor profile: Aniket M.

## Questions

### Subject: Web Development

Create an object named 'Triangle' with variables 'length' and 'height'. Create a method inside it for taking input for 'length' and 'height'. Also, create a method for printing the area of a triangle.

In order to solve this problem, we need to understand Javascript objects JavaScript objects are containers for named values called properties or methods. We need to create two properties - length and height We also need 2 methods - one for taking the input and one for calculating the area. We know that the area of a Triangle is 1/2 * length * height or 0.5*length*height. First, we will create the object, and then to test it we will be calling its methods. CODE var Traingle={ length:0, width:0, take_input: function(len,wid) { this.length=len; this.width=wid; }, area:function() { console.log(0.5*this.length*this.width); } } Traingle.take_input(2,3); Traingle.area();

### Subject: Python Programming

Take 20 integer inputs from the user and print the following: list of positive numbers list of negative numbers list of odd numbers list of even numbers list of 0s.

In order to solve this problem, we need to first take user input for 20 numbers in a while loop, and then segregate the numbers on the basis of type. All the numbers > 0 will be added to the list of positive numbers. All the numbers < 0 will be added to the list of negative numbers. All the numbers whose remainder is 0, when divided by 2 will be added to the list of even numbers. All the numbers whose remainder is not 0, when divided by 2 will be added to the list of odd numbers. All the numbers = 0 will be added to the list of 0s CODE i=0 l0=[] leven=[] lodd=[] lneg=[] lpos=[] while i<20: a=int(input("Enter the number : ")) if a==0: l0.append(a) if a>0: lpos.append(a) if a<0: lneg.append(a) if a%2==0 and a!=0: leven.append(a) if a%2!=0 and a!=0: lodd.append(a) i=i+1 print(l0) print(leven) print(lodd) print(lneg) print(lpos)

### Subject: Java Programming

Create functions for the Calculator class that can do the following: Add two numbers. Subtract two numbers. Multiply two numbers. Divide two numbers. Notes The functions should return the result of the calculation.

To solve this problem, we need to create a Calculator class that contains 4 functions. Each of the functions must be independent and must return a value. eg -> add(int num1,int num2) takes 2 integers as parameters and returns the sum. In the Main class, we also have to create an object of Calculator class in order to test these methods. Note: In the case of division, we have to consider the scenario when number2 is 0. That means in Main class, we will check if number2 is 0, then we will be printing Error. CODE: class Calculator { public int add (int num1, int num2) { int add = num1 + num2; return add; } public int subtract (int num1, int num2) { int sum = num1 - num2; return sum; } public int multiply (int num1, int num2) { int prod= num1 * num2; return prod; } public int divide (int num1, int num2) { int div= num1 / num2; return div; } } public class Main{ public static void main(String[] args) { Calculator calc = new Calculator(); System.out.println(calc.add(10,5)); System.out.println(calc.subtract(10,5)); System.out.println(calc.multiply(10,5)); int a=10; int b=5; if (b!=0) System.out.println(calc.divide(10,5)); else System.out.println("Error"); } }