Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Using your own word , explain the following function >>> print ((1+1)**(5-2)) # what ** is and how it affects this function ? -------------------------------------------------------------- def

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 ?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions