NPTEL Assignment 1 and 2
NPTEL Assignment 1 and 2
• Yes
No
2) Which block moves the cat as described in the previous questl)n ? 1 point
10
move G steps
tum C- • degrees
mo ve. steps
0
$ays the number 4, for 1 second, 10 times and changes the value of number variable by multiplying previous value with 4.
Says the number 4, for 1 second, 10 times and changes the value of number variable by adding previous value with 4.
Says the number 4, and its multiples each for 1 second, till 40 and changes the value of number variable by multiplying previous value with 4.
• Says the number 4, and its multiples each for 1 second, till 40 and changes the value of number variable by adding previous value with 4.
40
• 44
36
4
say.
16
5
29
• 44
No, the answer is incorrec t
Score: 0
Accepted Answers:
29
Accepted Answers:
29
They are used to make the computer store program data into SSD.
• They help in storing and retrieval of information/data while a task on the machine is running.
They simplify a task which involves processing repetitive procedures. They simplify a task which involves processing repetitive procedures.
They help in running multiple tasks parallel to each other.
7) What is the concept that helps in instructing the computer to execute repetitive tasks ? 1J
Functions
Variables
Conditionals
• Loops
Yes
No
set x1 • to.
set y1 • to.
set x2 • to.
set distance • to x1 x2 • x1 x2 y1 y2 • y1 y2
1O) What task does the block below accomplish ?
Moves the ball in a parabolic path and stops 21 away steps from center(O, 0) In x direction.
Moves the ball in a circular path and 21 times.
• Moves the ball in a triangular path and end at the center (0, 0).
Moves the ball in a parabolic path and stops 20 away steps from center(O, 0) In x direction.
2) Which of the following code blocks print - "Hello Ram Lakshman and Hanuman !" ?
namel =
name2 = "Lakshman"
name3 = "Hanuman"
print("Ht:llo",na mel,name2, "and",name3," ! ")
namel = "Ham"
name 2 = " I a k s ti mc1 n "
name3 = "Hanumdn"
print("HE'l1o",n amel,namel, "and",name3," ! ")
in(inputO)
float(inputO)
int(inputO)
a= inputQ
a= int(a)
a =7
resu lt= 1
for i in rang e(a):
if(i > 0):
resu lt= resu lt* i
prin t(res ult+ 2)
For what value of a does the code output 8 ?
2
1
4
6
6) Which loop is used to perform a set of repetitive tasks based on condition in Python?
• while loop
•
for loop
do-while loop
while-range loop
7) What happens when the condition inside the if and while evaluate to false ?
Python interpreter ignores the if/while blocks, and halts the program.
Python interpreter ignores the if/while blocks, and proceeds the program from the lines after the if/while block
Python interpreter executes the if/while blocks, and rest of the program.
Python interpreter executes the if/while, and the programs runs in an infinite loop.
Yes, the answer is correct.
Score: 1
Accepted Answers:
Python interpreter ignores the if/while blocks, and proceeds the program from the lines after the if/while block.
8) The following program might/might not have an infinite loop. Does the program have infinite loop ?
l a -- int(in put() )
2 while (a --
-- 0):
3 if(a< 0):
4 a=-1
5 if(a> 0):
6 a=l
7 if(a> l):
8 a=2
' -i
if(a< l):
a=-2
print (a)
No, the program doesn't have infinite loop.
Yes, it can be prevented by updating the value of a before the if block at line 3
Yes, it can be prevented by removing both the if blocks Inside the while loop.
Yes, but it cannot be prevented
aryan, 20
arjun, 19
~ aakash, 17
aatreya, 18