8.3k views
1 vote
4. Calculate the square root of potato using the sqrt() function. Print out the value of potato again to verify that the value of potato hasn't changed.

1 Answer

4 votes

Answer:

potato<-100

print(potato)

sqrt(potato)

potato<-potato*2

print(potato)

Explanation:

The complete question is as follows

Create a variable called potato whose value corresponds to the number of potatoes you’ve eaten in the last week. Or something equally ridiculous. Print out the value of potato.

Calculate the square root of potato using the sqrt() function. Print out the value of potato again to verify that the value of potato hasn’t changed.

Reassign the value of potato to potato * 2.

Print out the new value of potato to verify that it has changed

The question was answered using R programming language.

At line 1, I assumed that I ate 100 potatoes in the previous week.

So, potato = 100

At line 2, the value of potato is printed as 100.

At line 3, the square root of potato is calculated using sqrt function: Square for of 100 = 10

At line 4,the initial value of potato is doubled and stored in potato variable. 100 * 2 = 200

At line 5, the new value of potato is printed: 200.

User Jstell
by
4.7k points