The Joy of Computing Using Python Week 3 assignment answers ? In this article we will discuss about the answers of week 3 of joy of computing. The answers shared here will be based on our own knowledge. Please use this as your reference.
About NPTEL
The Joy Of Computing Using Python Week 3 Assignment 2023
Q1. ___________ is the method to insert an item into a specified position in a list.
a. Push
b. Write
c. Insert
d. All the above
Answer: [ c ] Insert
Q2. Which method returns the number of occurences of an element in a list.
a. Number of
b. Total
c. Count
d. Length
Answer: [ c ] Count
Q3. The function random.randint(1,100) in python generates.
a. A random integer between 1 to 100 with 1 and 100 both inclusive.
b. A random integer between 1 to 100 with 1 and 100 both exclusive.
c. A random integer between 1 to 100 with only 100 inclusive.
d. All the above
Answer: [ d ] All the above
Q4. The method open ("file.txt" , r+ ) opens the file file1.txt in ________
a. Read only mode
b. Write only mode
c. Read Write Mode
d. None of the above
Answer: [ c ] Read Write Mode
Q5. Consider the list L = { 0 , 1 , 1 , 2 , 3 , 5 , 8 , 13 , 21 , 34 } . What is the output of this code for
the statement L [ 3:6]
a. [ 2,3,5 ]
b. [ 0,1,1 ]
c. [ 1,2,3 ]
d. none
Answer: [ a ] [ 2, 3, 5 ]
Q6. What is the output of this code ?
a, b = 1, 0
a = a^b
b = a^b
a = a^b
print ( a )
a. 0
b. 1
c. 2
d. The code will raise a runtime error
Answer: [ a ] 0
Q7. What is the output of this code ?
def foo (l):
a = l [ 0 ]
for i in l :
if i < a :
a = i
return a
print ( foo ( [ 2 , 3 , 5 , 1 , 6 ] ) )
Answer: 1
Q8. What is the output of this code ?
def bar ( string ):
left = 0
right = len (string )
while ( left < right )
if ( String [ left ] != string [right ] )
return false
left += 1
right -= 1
return True
print ( bar ("telugu") )
print ( bar (" Malayalam " ) )
a. False True
b. True False
c. True True
d. False False
Answer: [ a ] Fasle True
Q9. Explain what will be the output of the following code when given below is executed?
a. The program throws an error
b. 5
c. 5.5
d. 4.5
Answer: [ d ] 4.5
Q10. Which among the following statements is True with respect the following code given below
Count = 0
for i in range (10) :
for j in range ( 5):
Count + = i*j
print (count )
a. count = 50
b. The following code throws up an error
c. count = 550
d. count = 450
Answer: [ d ] 450
Programming Assignment
N = int(input())for i in range(1,N+1):for j in range(1,i+1):print('* ',end="")print(){codeBox}
N=int(input())L=[0,1]if N==1:print(0)elif N==2:print(0)print(1)else:print(0)print(1)for i in range(N-2):if i==N-3:print(L[-1]+L[-2],end="")else:print(L[-1]+L[-2])L.append(L[-1]+L[-2]){codeBox}
B=int(input())H=int(input())for i in range(H):for j in range(B):print('*',end="")if i!=H-1:print() {codeBox}
Conclusion:
Finally, these are the answers for Week 3 Assignment. Please recheck on 15 Feb for any Re-correction of answers.
