NPTEL The Joy Of Computing Using Python Assignment Answer
NPTEL The Joy Of Computing Using Python Week 4 Assignment Answer 2023
1. What is a magic square?
A square grid of letters
A square grid of numbers where the sum of the rows, columns, & diagonals are equal
A special kind of card trick
A term used in cryptography
Answer :- For Answer Click Here
2. In a 3×3 magic square, what is the magic constant?
- 3
- 6
- 9
- 15
Answer :- For Answer Click Here
3. Which of the following is NOT a property of a magic square?
- The sum of each row is equal
- The sum of each column is equal
- The sum of each diagonal is equal
- The sum of each individual element is equal
Answer :- For Answer Click Here
4. What will be the output of the following code?
- A magic square of size 2.
- A magic square of size n.
- A magic square of an even size.
- A magic square of an odd size.
Answer :- For Answer Click Here
5. What will be the output of the following code?
- Sorted List(L) containing random elements between 0-10 in descending order.
- Sorted List containing random elements between 0-10 in ascending order.
- Sorted List containing elements between 0-10.
- Sorted List containing elements between 0-9 in ascending order.
Answer :- For Answer Click Here
6. Which code will generate all prime numbers between 0-100?
Answer :- For Answer Click Here
7. In the birthday paradox, as the number of people in a group increases, what happens to the probability that two people share a birthday?
- It increases
- It decreases
- It stays the same
- It becomes impossible
Answer :- For Answer Click Here
8. Which module is used to generate random numbers in Python?
- math
- random
- stats
- numpy
Answer :- For Answer Click Here
9. Which function is used to shuffle a list in Python?
- random.shuffle()
- shuffle()
- list.shuffle()
- random_list()
Answer :- For Answer Click Here
10. What is the output of the following code?
import random
nums = [1, 2, 3, 4, 5]
random.shuffle(nums)
print(nums)
- [1, 2, 3, 4, 5]
- [5, 4, 3, 2, 1]
- A random ordering of the numbers 1 through 5
- An error
Answer :- For Answer Click Here
Course Name | The Joy Of Computing Using Python |
Category | NPTEL Assignment Answer |
Home | Click Here |
Join Us on Telegram | Click Here |
NPTEL The Joy Of Computing Using Python Week 3 Assignment Answer 2023
1. What will be the output of the following code?
L = [‘a’, ‘b’, ‘c’, ‘d’, ‘e’, ‘f’, ‘g’, ‘h’]
print(L[2:5])
- a, b, c
- a, b, c, d
- c, d, e
- c, d, e, f
Answer :- c
2. Which of the following is a valid way to declare a dictionary in Python?
- {1: “one”, 2: “two”, 3: “three”}
- [1: “one”, 2: “two”, 3: “three”]
- (1: “one”, 2: “two”, 3: “three”)
- <1: “one”, 2: “two”, 3: “three”>
Answer :- a
3. Which of the following method is correct to add an element at a specific position?
- insert()
- add()
- append()
- index()
Answer :- a
4. What is the correct syntax to add an item to the end of a list in Python?
- list.add(item)
- list.append(item)
- list.insert(item)
- list.extend(item)
Answer :- b
5. Which of the following is not a valid data type in Python?
- integer
- string
- float
- character
Answer :- d
6. What is the output of the following code?
for i in range(1, 21):
if i % 3 == 0 and i % 5 == 0:
print("FizzBuzz")
elif i % 3 == 0:
print("Fizz")
elif i % 5 == 0:
print("Buzz")
else:
print(i)
- Prints numbers from 1 to 20
- Prints Fizz for multiples of 3 and Buzz for multiples of 5
- Prints FizzBuzz for multiples of 3 and 5
- None of the above
Answer :- b
7. What is the output of the following code?
a = 5
b = 2
print(a // b)
- 2
- 2.5
- 3
- 2.0
Answer :- a
8. What is the output of the following code?
s = “hello”
print(s[::-1])
- “hello”
- “olleh”
- “hlo”
- “leh”
Answer :- b
9. What is the output of the following code?
a = 10
b = 5
c = a % b
print(c)
- 2
- 5
- 0
- 1
Answer :- c
10. What is the output of the following code?
s = “python”
print(s[1:4])
- “pyt”
- “yth”
- “tho”
- “hon”
Answer :- b
Course Name | The Joy Of Computing Using Python |
Category | NPTEL Assignment Answer |
Home | Click Here |
Join Us on Telegram | Click Here |
NPTEL The Joy Of Computing Using Python Week 2 Assignment Answer 2023
1. Which of the following is a high-level programming language?
- Assembly
- C
- Python
- Machine Language
Answer :- c
2. Which of the following is an example of a front-end programming language?
- PHP
- Java
- HTML
- SQL
Answer :- c
3. Which of the following is used to store data in a programming language?
- Variables
- Arrays
- Loops
- Conditionals
Answer :- a, b
4. Which statement will print ‘The joy of computing’?
- print(The joy of computing)
- print The joy of computing
- printf(‘The joy of computing’)
- print(‘The joy of computing’)
Answer :- d
5. What should be the value of _ to print all numbers from 0-10
- 10
- 9
- 11
- None of the above
Answer :- c
6. Which of the following keyword is used to declare a function in a programming language?
- def
- var
- int
- float
Answer :- a
7. What will be the output of the following code?
- 0
- 45
- 43
- 50
Answer :- b
8. What value will c store in it after the execution of the below code?
c=b**3
- Value of b multiplied by 3
- Cube of b
- Value of b multiplied with 3 twice
- It will throw an error
Answer :- d
9. What will be the output? suppose the input is 30
- 60
- Error
- 3030
- 30
Answer :- c
10. What is the output for the following program?
- True
- False
- It will display an error message
- Boolean
Answer :- b
Course Name | The Joy Of Computing Using Python |
Category | NPTEL Assignment Answer |
Home | Click Here |
Join Us on Telegram | Click Here |
NPTEL The Joy Of Computing Using Python Week 1 Assignment Answer 2023
1. What will be the value of my variable at the end of the loop.
- 50
- 40
- 49
- 0
Answer :- 40
2. Which of the following is not a type of block in Scratch?
- Motion
- Looks
- Sound
- Jump
Answer :- Jump
3. What is the main function of the “if” block in Scratch?
- To repeat a set of instructions
- To create a loop
- To control the flow of the program based on a condition
- To play a sound
Answer :- To control the flow of the program based on a condition
4. Which block in Scratch is used to control the movement of a sprite?
- Motion
- Looks
- Sound
- Control
Answer :- Motion
5. Imagine sprite to be a scooter. How many times scooter will move forward?
- 7
- 4
- 6
- 5
Answer :- 5
6. Which block in Scratch is used to make a sprite say something?
Motion
Looks
Sound
Control
Answer :- Looks
7. What is the purpose of the “repeat” block in Scratch?
- To repeat a set of instructions a specific number of times
- To repeat a set of instructions forever
- To repeat a set of instructions based on a condition
- To play a sound repeatedly
Answer :- To repeat a set of instructions a specific number of times
8. Which block in Scratch is used to wait for a certain amount of time before continuing with the program?
- Motion
- Looks
- Sound
- Control
Answer :- Control
9. Which block in Scratch is used to detect when a sprite touches another sprite?
- Motion
- Looks
- Sound
- Sensing
Answer :- Sensing
10. What is the purpose of the “broadcast” block in Scratch?
- To send a message to another sprite
- To play a sound
- To move a sprite
- To change the background color
Answer :- To send a message to another sprite
Course Name | The Joy Of Computing Using Python |
Category | NPTEL Assignment Answer |
Home | Click Here |
Join Us on Telegram | Click Here |