Are you looking for help in Joy of Computing using Python NPTEL Week 3 Assignment Answers? So, here in this article, we have provided Joy of Computing using Python week 3 Assignment Answer’s hint.
Table of Contents
NPTEL The Joy of Computing using Python Assignment Answers Week 3
Q1. ___________ is the method to insert an item into a specified position in a list.
Answer: c. Insert
1000+ students getting help from instant notifications, Join us on telegram.
Q2. Which method returns the number of occurrences of an element in a list.
Answer: c. Count
Q3. The function random.randint(1,100) in python generates.
Answer: a. A random integer between 1 to 100 with 1 and 100 both inclusive
Q4. The method open(“file1.txt”, r+) opens the file file1.txt in _____
Answer: c. Read Write mode
Q5. Consider the list L= [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]. What will be the output of the statement L [3:6]?
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)
Answer: a. 0
Q7. What is the output of the following code?
def foo(l):
a = l[0]
for i in l:
if i < a:
a = i
return a
print (foo([2, 3, 5, 1, 7, 6]))
Answer: 1
Q8. What is the output of the following code?
def bar(string):
left = 0
right = len(string) - 1
while(left < right):
if(string[left] != string[right]):
return False
left += 1
right -= 1
return True
print(bar("telugu"))
print(bar("malayalam"))
Answer: a. False True
Q9. Explain what the output will be when the code given below is executed.
def func(list1):
while (len(list1) > 2):
k=list1 [0]
for i in list1:
if k<i:
k=i
list1.remove (k)
j=list1[0]
for i in list1:
if j>i:
j=i
list1.remove (j)
return list1
list2=func ([1,4,3,6,5,3,7,8,9,4])
#sum is a function which returns the sum of all of the values of all the elements of a list
print(sum(list2)/len (list2))
Answer: d. 4.5
Q10. Which among the following statements is True with respect to the code given below?
count = 0
for i in range(10):
for j in range(5):
count += i *j
print(count)
Answer: d. count=450
The Joy of Computing using Python Programming Assignment Answers
Q1.
N=int(input())
for i in range(1,N+1):
for j in range(1,i+1):
print("* ",end="")
if j!=N:
print()
Q2.
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])
Q3.
B=int(input())
H=int(input())
for i in range(H):
for j in range(B):
print('*',end="")
if i!=H-1:
print()
TELEGRAM FOR NOTIFICATION | Click Here |
Follow on Google News (in one click) | Click Here |
Disclaimer: These answers are provided only for the purpose to help students to take references. This website does not claim any surety of 100% correct answers. So, this website urges you to complete your assignment yourself.
Also Available:
NPTEL The Joy of Computing using Python Assignment Answers Week 2