Consider the following Python code of 4 lines, with line numbers (not part of the code) shown on the left. The objective is to write a string onto the file.
1 f = open('Out.txt', 'w')2 f.write("this is the string")3 ...........4 print('Done...')What should fill the blank at line 3 to make the code complete?
Out of the four control structures used in programs, a Python function is a:
What will be the output of the following Python function?
def findList( inputList ):
return [i for i in inputList if i%2 == 1]
What will be the output of the following Python code segment?
def printinfo(arg1,*vartuple): total = 0; for var in vartuple: total += var print (total) returnprintinfo(70,60,50,40,30,20)
What will be the output of the following Python code segment?
d = "M"def add( arg2 , arg1 = "U" ): global d d += arg2 + arg1 returnadd("o")print (d)
What will be the output of the following Python code segment?
def myFunc( x ): x += 30 return xx = 20myFunc(x)print (x)
Regulārā trijstūra piramīdā ievilkts konuss. Aprēķini konusa tilpumu, ja piramīdas pamata malas garums ir 6 cm un piramīdas augstums ir 8 cm!
What will be the output of the following Python code segment?
def makeWord( c1 = "m", *c2 ): c = c1 for a in c2: c += a return cprint (makeWord("k","i","n","d"))
Consider the following Python function.
def PerformTask(S): L = []; for i in range(0, len(S)): if S[i] == "(": L.append(S[i]) elif S[i] == ")" and len(L)>0: L.pop() else: return False return True
Which of the following input parameter will result in a return value of “True" in the above?
What will be the output of the following Python code segment?
def printname( fn = "L", sn = "D", ln = "Shanaka" ): ln = "Mathews" print(fn,sn,ln) returnprintname("A")