Enable contrast version

# Tutor profile: Piyush A.

Piyush A.
Teaching mathematics, python/django, java, ruby/rails and web development

## Questions

### Subject:Python Programming

TutorMe
Question:

Find the output of the below program and state the reason. a=[1, 2, 3, 4] b=a b=5 print(a)

Piyush A.

Let's start by understanding the python statement given in the question. a=[1, 2, 3, 4] # list of numbers from 1 to 4 b=a # We are assigning value of a into variable b b = 5 # changing the value at index 2 print(a) # printing a on the console Where you might be wrong? You must be thinking that as we have changed the value at index 2 of list named b, nothing will happen to list named a. So, the output should be [1, 2, 3, 4] The above output is incorrect. Why? When we wrote a = [1, 2, 3, 4] , that means a list gets created and variable a is referencing that list in the memory. Then, b = a , that means that b is referencing to the same memory fragment as a. So, b is same as a. This statement doesn't create a copy of a and then store it to b. Then we changed the value at index 2. So, now list is [1, 2, 5, 4] Now, if we print a or print b. Since, both of the list are referencing to same stored list. So, final output will be [1, 2, 5, 4]

### Subject:Java Programming

TutorMe
Question:

class Greeting{ public void greet(String name) { System.out.println("Welcome "+name); } } public class Example { public static void main(String[] args) { Greeting englishGreeting = new Greeting(); englishGreeting.greet("Piyush"); } } Output : Welcome Piyush What if I want to greet someone in French using the same function, that is, How to change the definition of the greet function without making change in Greeting Class?

Piyush A.

We will use concept of an anonymous inner class. We will change the definition of the class method while creating its object. We override the definition of the function of the Greeting class before creating its object and used new definition upon call greet function with updated reference class Greeting{ public void greet(String name) { System.out.println("Welcome "+name); } } public class Example { public static void main(String[] args) { Greeting englishGreeting = new Greeting(); englishGreeting.greet("Piyush"); Greeting frenchGreeting = new Greeting() { @Override public void greet(String name) { System.out.println("Salut "+name); } }; frenchGreeting.greet("Piyush"); } } Output : Welcome Piyush Salut Piyush

### Subject:Algebra

TutorMe
Question:

If $$x^3 + y^3$$= 9 and $$x + y = 3$$, then find the value of $$x^4+y^4$$ ?

Piyush A.

Given : $$x^3 + y^3 = 9$$ and $$x+y = 3$$ Find : $$x^4 + y^4$$ Solution : $$x^3 + y^3 = 9$$ Apply identity : $$a^3 + b^3 = (a + b) (a^2 + b^2 - ab)$$ $$(x + y) ( x^2 + y^2 - xy ) = 9$$ Substitute value of $$x+y=9$$ $$3 ( x^2 + y^2 - xy ) = 9$$ Divide both side by 3, $$( x^2 + y^2 - xy ) = (9 / 3)$$ $$x^2 + y^2 - xy = 3$$ Apply identity : $$a^2 + b^2 = (a + b)^2 - 2ab$$ $$(x + y)^2 - 2xy - xy = 3$$ $$(3)^2 - 3xy = 3$$ $$9 - 3xy = 3$$ Add 3xy to both sides, $$9 - 3xy + 3xy = 3 + 3xy$$ $$9 = 3 + 3xy$$ Subtract 3 from both sides, $$9 -3 = 3 + 3xy - 3$$ $$6 = 3xy$$ $$3xy = 6$$ Divide both sides by 3, $$xy = (6/3)$$ $$xy = 2$$ Now, Let's take the question, $$x^4 + y^4$$ $$= ( x^2 )^2 + (y^2)^2$$ Apply identity : $$a^2 + b^2 = (a + b)^2 - 2ab$$ $$= (x^2 + y^2)^2 - 2 x^2 y^2$$ Apply identity : $$a^2 + b^2 = (a + b)^2 - 2ab$$ $$= ( (x + y)^2 - 2xy )^2 - 2 (xy)^2$$ Substitute the value of x+y=3 and xy=2, $$= ( (3)^2 - 2*2 )^2 - 2 (2)^2$$ $$= ( 9 - 4 )^2 - (2 * 4)$$ $$= 5^2 - 8$$ $$= 25 - 8$$ $$= 17$$ Final answer : $$x^4 + y^4 = 17$$

## FAQs

What is a lesson?
A lesson is virtual lesson space on our platform where you and a tutor can communicate. You'll have the option to communicate using video/audio as well as text chat. You can also upload documents, edit papers in real time and use our cutting-edge virtual whiteboard.
How do I begin a lesson?
If the tutor is currently online, you can click the "Start Lesson" button above. If they are offline, you can always send them a message to schedule a lesson.
Who are TutorMe tutors?
Many of our tutors are current college students or recent graduates of top-tier universities like MIT, Harvard and USC. TutorMe has thousands of top-quality tutors available to work with you.
BEST IN CLASS SINCE 2015
TutorMe homepage