logo

Crowdly

Browser

Add to Chrome

In24-S1-CS1033 - Programming Fundamentals

Looking for In24-S1-CS1033 - Programming Fundamentals test answers and solutions? Browse our comprehensive collection of verified answers for In24-S1-CS1033 - Programming Fundamentals at online.uom.lk.

Get instant access to accurate answers and detailed explanations for your course questions. Our community-driven platform helps students succeed!

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"))

View this question

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)
View this question

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.

View this question

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))
View this question

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)

View this question

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))
View this question

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

0%
0%
0%
0%
View this question

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%
View this question

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

View this question

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?

View this question

Want instant access to all verified answers on online.uom.lk?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!

Browser

Add to Chrome