The Joy of Computing Using Python Week 2 assignment answers ? In this article we will discuss about the answers of week 1 of joy of computing. The answers shared here will be on our own knowledge. Please use this as your reference.
Also Read: The Joy Of Computing Using Python Week 1 Assignment
The Joy of Computing Using Python
Q1. What are the applications of Python?
a. Image processing and graphic design applications.
b. Enterprise and business applications development.
c. Operating Systems
d. All the above
e. None of the above
Answer : [ d ] All the above
e. None of the above
Answer : [ d ] All the above
Q2. Which of the following is not the correct Variable Name?
a. ABC
b. Abd23
c. 32asd
d. Ab_cd_23
d. Ab_cd_23
Answer: [ c ] 32asd
Q3. Write the output of the following code ?
L = [ 1,2,3,4,5,6,7,8,9 ]
Print ( L [: : -1 ] )
a. [ 1,2,3,4,5,6,7,8,9 ]
b. [ 1,2,3,4,5,9,8,7,6 ]
c. [ 9,8,7,6,5,4,3,2,1 ]
d. Error
Answer: [ c ]
Q4. Predict the output of following code
L = [[1,2,3],[0,4,5],[0,0,6]]
Code:
for i in range (3):
for j in range (2, i-1, -1):
print (L[i][j] , end = "")
a. 3,2,1,5,4,6
b. 3 2 1 5 4 6
c. 0 0 0 0 0 0
d. 0,0,0,0,0,0
Answer: [ b ]
Q5. Find the errors in the following code
Code:
n = 10
l = [ ]
for i in range( 10, n+10 ):
l . append (i**i)
for i in range ( 10,0,-1 ):
print ( l[i] )
a. Index out of range
b. Syntax error
c. Variable not defined
d. ' int ' object does not support item assignment
Answer: [ a, b ]
Q6. What is the output of the following code ?
Code:
def add_items ( x,y):
x+= [ 1,2 ]
y+= ( 3,4 )
l = [ 0 ]
t = (5, )
add_items (l, t)
print (l, end = " " )
print( t )
a. [ 0,1,2 ] ( 5,3,4 )
b. [ 0,1,2 ] ( 5, )
c. [ 0 ] ( 5, 3, 4)
d. [ 0 ] (5, )
Answer: [ b ]
Q7. What is the correct syntax for defining a function in Python?
a. def function name():
b. function function_name():
c. function_name:
d. def function_name:
Answer: [ a ] def function name():
Q8. What is the purpose of the continue statement in a for loop?
a. To skip the rest of the current iteration and move on to the next one
b. To terminate the loop and exit the loop block
c. To return to the top of the loop and start a new iteration.
d. To skip the current iteration and move on to the next one, but only if a certain condition is met
Answer: [ d ] To skip the current iteration and move on to the next one, but only if a certain condition is met
Q9. How do you check if a number is even in python ?
a. if number % 2 == 0
b. if number is_even()
c. if number % 2 is 0
d. if number even()
Answer: [ a ]
Q10. What should be the value of _ to print all numbers from 0-10?
for i in range ( _ ) :
print( i )
a. 11
b. 9
c. 10.
d. None of the above
Answer: [ a ] 11
NPTEL Programming Assignment
Q1. Given an integer as an input , write a program to print that integer.
INPUT:
A Number
OUTPUT:
A Number
Program :
print(num , end="") {codeBox}
Q2. Given an integer as an input , write a program to print the sum of those integers.
Program :
print(num1+num2 , end="") {codeBox}
Q3. You are given a number as an input . You have to display all the numbers from 0 till X
INPUT:
X
OUTPUT:
0 1 2
Program :
for a in range(num+1):if a==num:print(a,end="")else:print(a) {codeBox}
Conclusion:
Finally, these are the answers for Week 2 Assignment. Please recheck on 08 Feb for any Re-correction of answers.
