Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using your own word , explain the following function >>> print ((1+1)**(5-2)) #

ID: 3875458 • Letter: U

Question

Using your own word , explain the following function

>>> print ((1+1)**(5-2)) # what ** is and how it affects this function ?

--------------------------------------------------------------

def find(strng, ch): # what does (strng, ch) means
index = 0
while index < len(strng): # what is the difference of function while and if , what len() function do ?
if strng[index] == ch: # why we use [] here instead of () , why we don't put "ch" in () or " "
return index
index += 1 # what is += here means and how it affect the function ?
return -1 # what does return - 1 means, why don't we put return = -1

print (find("the doctor is in", '*'))

---------------

>>> mylist = [1, 4, 2 3] # why we use [] instead of " ",
>>> mylist.append(5) # what does mylist.append means ? what does 5 mean here ?

what this function is trying to do ? is it the correct way ? what would be the correct way if your answer is that this function is not correct?

-------------------------

Why is the result of this function equal to 7?

n = 2
n += 5 # what += means ? , how it affects the result of the function
print(n)

---------------

What does subroutine do ?

def subroutine(n):
while n > 0:
print (n,) # why there is a ",", what does it do ?
n -= 1 # what does " -=" means ? what does it do ?

---------

mylist = [ [2,4,1], [1,2,3], [2,3,5] ] # why we use [] o seperate number in to 3 groups/ set
a=0   
b=0
total = 0
while a <= 2: # why we use while instead of if, what is the meaning of while function
while b < 2:
total += mylist[a][b] # what does this expression means ?
b += 1    # what does this expression means ?
a += 1    # what does this expression means ?
b = 0 #  # what does this expression means ? would b = 0 contradict with b+= 1? If not explain

print (total)

---------------------

x = 5
if x % 2 == 0: # what does this expression means ?
print (x)
else:
print (x, x%2) # what does x%2 represent , what print (x, x%2) means ?

Explanation / Answer

1. print ((1+1)**(5-2)) it will work as power function. ** provide like power. (1+1)**(5-2) it is like 2^3 so it will print 8.

2.

3.

4. n = 2

n += 5 it is like n=n+5 so from this it increase in value by 5. so the value of n is inccrease from 2 to 7.

5.

6.