logo

Crowdly

In24-S1-CS1033 - Programming Fundamentals

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

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

What will be the output of the following Python program?

def ProcessString(S):

if(len(S) <= 1):

return S

else:

return ProcessString(S[1:]) + S[0]

print(ProcessString("TIME STAR"))

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

What is the output (returned value) of the following function in terms of the inputs (x and y, which are integers)?

def recfun1(x, y):

    if(x <= 0):

        return y

    else:

        return recfun1 (x-1, x+y)
Переглянути це питання

The following incomplete Python function is intended to return the maximum number in a given list of numbers, where the list may contain many nesting levels.

def RecMax(L): 

     if (type(L) is not list) or (len(L) < 1): 

          return None

if len(L) == 1:

if type(L[0]) is list:

return …………(T)…………

else:

return L[0]

else:

if type(L[0]) is list:

return max(…………(U)…………)

else:

return max(L[0], RecMax(L[1:]))

Write the appropriate code to fill the blank (T) for completing the function.

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

What will be the output of the following Python program?

def MyFun(num):

  if (num > 0):

    return MyFun(num//2)+str(num%2)

  return ""

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

What will be the order of numbers printed by the following Python code?

def PrintNumbers(i, n):

if(i == n):

print(n)

else:

print(i)

PrintNumbers(i+1, n)

print(i)

PrintNumbers(0, 5)

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

What will be the output if the following function is called with input parameter 36?

def recfun2(x):

    if(x == 0):

        return str(0)

    else:

        return (recfun2(x/2) + str(x%2))
Переглянути це питання

What does the following recursive function do? (The input is a list of numbers).

def recfun4(L):

    if len(L) > 0:

        return L[0] + recfun4(L[1:])

    else:

        return 0

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

The following incomplete Python code is intended to flatten a nested list. A nested list is a list which can have lists as elements (and each such list element can be a nested list, recursively). A flattened list is a list that has no list as an element. When flattening a nested list, the flattened list must contain all the non-list elements in the original nested list. In the code, the input parameter is the original nested list and the function should return the flattened list.

def FlattenList(mylist):

retlist = []

if (len(mylist) == 0):

return []

elif (type(mylist[0]) is list):

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

else:

retlist.append(mylist[0])

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

return retlist

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

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

The following incomplete Python function is intended to return the maximum number in a given list of numbers, where the list may contain many nesting levels. 

def RecMax(L): 

     if (type(L) is not list) or (len(L) < 1): 

          return None

if len(L) == 1:

if type(L[0]) is list:

return …………(T)…………

else:

return L[0]

else:

if type(L[0]) is list:

return max(…………(U)…………)

else:

return max(L[0], RecMax(L[1:]))

Write the appropriate code to fill the blank (U) for completing the function

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

How will the number 45612.378910 be represented in a decimal floating-point notation which has a 5-digit mantissa, the decimal point after the second digit from left, and 10 as the base for the exponent?

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

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

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