NPTEL Assignment 3-4
NPTEL Assignment 3-4
n=
a = []
fo r i in ra ng e( n) :
11 = []
p = 0
fo r j in ra ng e( i):
11 .a pp en d( j)
fo rk in 11:
p+ =l
a. ap pe nd (p )
k= 0
k=0
for 1 in a:
k+=l
print(k)
For what value of n does the program print 21 ?
21
3) From the previous question, for what values of n is the number 7 appended to list a.
7
6
✓ 8
./ 9
• :1
.-. ~: open ("+·
, ~1 ,_ .. t :-: ~ ,• ,
dat a= f.re ad( )
prin t(da ta)
Yes
No
StackOverflow
Wikipedia
Quora
None
n =
k = 0
a = []
b = 0
while (n ! = 0):
k = k + (n X 10)
a.append(n % 10)
n = n//10
a. sort()
f'.Jr i 1n a:
b = b + i
::(b == k):
print( "WE KNO\oJ THE WISDOM OF SERIES")
.. l . '=' :
print("Wl: ARE: YET TO KNOW MANY !HING~")
9) From the previous question, is the variable nor a.sortO responsible for printing of either of the two possible sentences?
No, it is not dependent on variable n, the code will never print "WE ARE YET TO KNOW MANY ~i-JINGS".
Yes on a.sortQ only, but the code will never print "WE ARE YET TO KNOW MANY THINGS".
Yes on both, the code may print both sentences.
No, it is not dependent on a.sortQ, the code will never print "WE ARE YET TO KNOW MANY THINGS".
56
answer is correct.
Week 4: Assignment 4
The due date for submitting this assignment has passed.
Due on 2024-08-21, 2
n(n 2 + 1)
2
n3
2
n3 +2
2
✓
n4 + n2
2n
Yes, the answer is correct.
Score: 1
Accepted Answers:
n(n 2 + 1)
2
n4 + n2
~
2n
2) What would the magic constant be for a magic square of size 6, given that all elements in the square are distinct numbers from 1 to 36?
72
111
109
110
Yes
• No
10 3 13 8
5 16 2 11
4 9 7 14
15 6 12 1
✓
1 14 4 15
8 11 5 10
13 2 16 3
12 7 9 6
49
1 point
6) Calculate the magic constant for 4x4 square, where all elements are distinct numbers from 1 to 16, is it same as
the magic constant for Ramanujan's
magic square ?
If yes, enter 0, else enter the absolute difference between the two.
Hint: Search the about Ramanujan's magic square.
105
2,3
0,0
1,1
1,0
9) If all possible pairs of prime numbers between 0 and 20, are given to n1 and n2, for how many pairs would function2 print "Completed" ? 1
10) If numbers of pairs of primes which result in function2 to print "Completed" are greater than 0, Can we edit the code in function20 so that " 1
Completed" is never printed for any pair of primes ?
Yes, we can change the logic for setting flag variable to True.
Yes, we can change/increase the threshold for length of list2 in the last if block.
No, it is logically not possible.
Yes, we can change the initial value of flag to True, instead of False.