logo

Crowdly

Browser

Додати до Chrome

In24-S1-CS1033 - Programming Fundamentals

Шукаєте відповіді та рішення тестів для In24-S1-CS1033 - Programming Fundamentals? Перегляньте нашу велику колекцію перевірених відповідей для In24-S1-CS1033 - Programming Fundamentals в online.uom.lk.

Отримайте миттєвий доступ до точних відповідей та детальних пояснень для питань вашого курсу. Наша платформа, створена спільнотою, допомагає студентам досягати успіху!

What will be the output (return value) of the following function if the initial call is “recfun3([11, 44, 33, 22, 66, 77], 0)”?

def recfun3(L, x):

    if len(L) == 0:

        return x

    else:

        y = max(x, L[0])

        return recfun3(L[1:], y)
Переглянути це питання

There are three stacks (A special kind of list) A, B and C. All the stacks support only the standard push (Add an element to the end of the list) and pop (Remove the last element from the list and return the value

) operations and checking whether the stack is empty or not. Stack A contains a sequence of n

(n >= 1) numbers in sorted order, where the largest number is at the bottom of the stack and

the smallest number is at the top of the stack. It is required to move n numbers in the stack A

to stack B. The numbers should appear in the stack B in the same order they appeared in stack

A.

The following pseudocode is intended to move all the numbers in the stack A to stack B

so that, after moving, the numbers will be in stack B in the same order they appeared in

stack A. It can use Stack C as well. What will be the appropriate values for X, Y and Z in

the given pseudocode?

MOVE (A, B, C):

   WHILE (stack A is not Empty):

temp = A.pop()

X.push(temp)

ENDWHILE

WHILE (Stack Y is not empty):

temp = Y.pop()

Z.push(temp)

ENDWHILE
Переглянути це питання

The following incomplete algorithm is intended to solve the Towers of Hanoi problem. The “Move-Disks” function takes the number of disks to be moved (Num_Disks), source tower (From_Tower), destination tower (To_Tower), and the other/third tower (Other_Tower) as the input parameters and solves the problem.

Move-Disks (Num_Disks, From_Tower, To_Tower, Other_Tower)

if (Num_Disks == 1):

Move the disk on the top of From_Tower to To_Tower

else:

.......(A).......

Move the disk on the top of From_Tower to To_Tower

.......(B).......

What will be the most suitable parts to fill the blanks A and B, respectively, so that the algorithm will solve the problem of Towers of Hanoi?

0%
Переглянути це питання

What will be the output of the following Python code?

S = set((1, 2, (31, 32), 31, 32))

print (len(S))
0%
0%
0%
0%
Переглянути це питання

What will be suitable representations in Python for the matrix shown below?

100%
Переглянути це питання

Consider the following incomplete Python code. The code is expected to compute xn.

def MyPow(x, n):

  if n==0:

    return 1

  hp = MyPow(x, n//2)

  ret = hp*hp

  if ....(A).... :

    ret = ret * x

  return ret

What should fill the blank A to make it work?

0%
0%
0%
0%
0%
Переглянути це питання

 The following recursive Python function is intended to accept a positive decimal number as the input and return the number of digits in the input number.

 

def MyFun(num):    

    if num == 0:       

       .......(A).......    

    else:       

       .......(B).......

 

What will be the most suitable parts to fill the blanks A and B, respectively, so that the code will work correctly?

Переглянути це питання

Consider the following Python code of 6 lines, with line numbers (not part of the code) shown on the left.

1   a = 10

2   b = 20

3   c = 30

4   T = ("A","B","C")

5   (a,b,c) = (b,c,a)

6   T[1] = "b"

Which of the following statement is correct regarding the above code?

Переглянути це питання

What will be the output of the following python program?

def MyFun(mylist):

  if len(mylist) > 0:

    mid = len(mylist)//2

    if mylist[mid] < 50:

      return MyFun(mylist[:mid-1]) + 1

    else:

      return MyFun(mylist[mid+1:]) + 1

  else:

    return 1

initlist = [12, 15, 72, 66, 23, 79, 35]

print (MyFun(initlist))
Переглянути це питання

You are asked to develop a Python program that will accept a list of English words as the input and return the words appearing in the list and the number of times each word appears in the list. What will be the most suitable collection data type in Python that can be used for implementing your program?

Переглянути це питання

Хочете миттєвий доступ до всіх перевірених відповідей на online.uom.lk?

Отримайте необмежений доступ до відповідей на екзаменаційні питання - встановіть розширення Crowdly зараз!

Browser

Додати до Chrome