0% found this document useful (0 votes)
387 views14 pages

NPTEL Assignment 1 and 2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
387 views14 pages

NPTEL Assignment 1 and 2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Week 1 : Assignment 1

The due date for submitting this assignment has passed.


Due on 2024-08-07, 23:59 IS'

Assignment submitted on 2024-08-07, 19:58 1ST


1) T"'e cat wants to move 100 steps away slowly, and by the time it finishes moving 100 steps, it needs to slowly rotate as well towards the 1 poin
opposite direction. Can both these tasks be accomplished by using single loop in scratch?

• Yes
No

Yes, the answer is correct


Score: 1
Accepted Answers:
Yes

2) Which block moves the cat as described in the previous questl)n ? 1 point

10
move G steps

tum C- • degrees

No, the answer is incorrect.


Score: 0
Accepted Answers:

mo ve. steps

turn C' • degrees


iy
3) What does the cat say here ? 1 point

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.

Yes, the answer is correct.


Score: 1
Accepted Answers:
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.
~
4) From the previous question, what is the value of number variable after the loop ends ? 1 point

40
• 44
36
4

Yes, the answer is correct.


Score: 1
Accepted Answers:
44
·0

say.

16
5
29
• 44
No, the answer is incorrec t
Score: 0
Accepted Answers:
29
Accepted Answers:
29

6) Which of the following is use case of variables in programming.

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.

Yes, the answer is correct.


Score: 1
Accepted Answers:
They /Je/p in storing and retrieval of information/data while a task on the machine is running.

7) What is the concept that helps in instructing the computer to execute repetitive tasks ? 1J

Functions
Variables
Conditionals
• Loops

Yes, the answer is correct.


Score: 1
Accepted Answers:
Loops

8) Can polynomial expressions be instructed to computer in logically finite steps ? 1 poii

Yes
No

Yes, the answer is correct.


Score: 1
Accepted Answers:
Yes
Accepted Answers:
Yes

9) \n which o\ the to\lowing cod


e b\oc\<.s ca\cu\a\\on o\ the S(\\lat
ed d\s\ance 'oe\\Neen \~ o ?C>\n\s
\,\) , '2.\)\ an d~ ~. A.~\ \s accom~\\
s'n~d
.
At;t;l:lj.Jll:IU ""1;::,wc1 ;::,.

set x1 • to.

set y1 • to.

set x2 • to.

set y2. 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.

No, the answer is incorrect.


Score: 0
Accepted Answers:
Moves the ball in a parabolic path and stops 20 away steps from center(0, 0) in x direction.
Week 2: Assignment 2
The due date for submitting this assignment has passed.

Assignment submitted on 2024-08-07, 20:04 1ST


1) Statement : If a variable is assigned multiple times, the latest value is not stored in the variable

False, the variable stores all values it was assigned


False, the variable stores the value from the latest assignment.
True, the variable stores the value from the second-last assignment.
True, the variable stores value from the initial assignment

Yes, the answer is correct.


Score: 1
Accepted Answers:
False, the variable stores the value from the latest assignment.

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," ! ")

print("Hr.:-llo RJm Lakshrrun .111d H.Jnurndll ! ")

name 1 = "R ,rn1 "


name2 = "LJkslirncJri"
name3 = "H,ir1L1r:1c-n1"

print(' l' f'.T'1", namel, ",1r:.)' ,name3,'' ··)


3) What aren't the correct ways to inform python that input is an integer ?

in(inputO)
float(inputO)
int(inputO)
a= inputQ
a= int(a)

Yes, the answer is correct.


Score: 1
Accepted Answers:
inOnputO)
float(inputO)

4) TAe following program outputs 722 -

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

Yes, the answer is correct.


Score: 1
Accepted Answers:
4
5) What does previous question calculate ?

Calculates the factorial of a.


Calculates the factorial of a and adds 2.
Calculates the a multiples of a starting from 1 and adds 2 .
.. Calculates the factorial of a-1 and adds 2.

Yes, the answer is correct.


Score: 1
Accepted Answers:
Calculates the factorial of a-1 and adds 2.

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

Yes, the answer is correct.


Score: 1
Accepted Answers:
while 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

No, the answer Is incorrect.


Score: 0
Accepted Answers:
Yes, it can be prevented by updating the value of a before the if block at line 3
9) For which of the following values of name and age variables does the following code print "You are lucky"?

name = input (" Eri Ler· yuur· 11d111e: ")


age= int(in put(" Enter your age: "))
flag= "Fals e"
if(ag e >= 18):
flag= "True"
else:
flag - "Fals e"
coun ter= 0
for i in name:
if ( i == "a") :I
coun ter+= 1
if(fla g == "True "):
if(co unter > 2):
print("You are lucky")
else:
print( "You are not lucky ")
aryan, 20
arjun, 19
aakash, 17
aatreya, 18

Yes, the answer is correct.


Score: 1
Accepted Answers:
aatreya, 18
10) For which of the options among the previous question, the program doesn't print anything.

aryan, 20
arjun, 19
~ aakash, 17
aatreya, 18

Yes, the answer is correct.


Score: 1
Accepted Answers:
aakash, 17

You might also like