The Joy of Computing using Python | NPTEL 2023 | Week 3 Assignment Solutions

Cloud Computing NPTEL assignment answers

This set of MCQ(multiple choice questions) focuses on the The Joy of Computing using Python NPTEL 2023 Week 3 Assignment Solutions.

The course carries programming to your work area with stories, similarities and distinguished models. Going reflections to experiences and designing to engineering, the course concentrates fundamentally to rouse the student’s psyche to automatically think intelligently and show up at an answer. As a feature of the course, you will figure out how to practice and culture the craft of programming with Python as a language.

Course layout

Answers COMING SOON! Kindly Wait!

Week 0: Assignment answers
Week 1: Assignment answers
Week 2: Assignment answers
Week 3: Assignment answers
Week 4: Assignment answers
Week 5: Assignment answers
Week 6: Assignment answers
Week 7: Assignment answers
Week 8: Assignment answers
Week 9: Assignment answers
Week 10: Assignment answers
Week 11: Assignment answers
Week 12: Assignment answers

NOTE: You can check your answer immediately by clicking show answer button. The Joy of Computing using Python NPTEL 2023 Week 3 Assignment Solution” contains 10 questions.

Now, start attempting the quiz.

The Joy of Computing using Python NPTEL 2023 Week 3 Assignment Solutions

Q1. What will be the output of the following code?
L = [‘a’, ‘b’, ‘c’, ‘d’, ‘e’, ‘f’, ‘g’, ‘h’]
print(L[2:5])

a) a, b, c
b) a, b, c, d
c) c, d, e
d) c, d, e, f

Answer: d) c, d, e, f

Q2. Which of the following is a valid way to declare a dictionary in Python?

a) {1: “one”, 2: “two”, 3: “three”}
b) [1: “one”, 2: “two”, 3: “three”]
c) (1: “one”, 2: “two”, 3: “three”)
d) <1: “one”, 2: “two”, 3: “three”>

Answer: a) {1: “one”, 2: “two”, 3: “three”}

Q3. Which of the following method is correct to add an element at a specific position?

a) insert()
b) add()
c) append()
d) index()

Answer: a) insert()

Q4. What is the correct syntax to add an item to the end of a list in Python?

a) list.add(item)
b) list.append(item)
c) list.insert(item)
d) list.extend(item)

Answer: b) list.append(item)

Q5. Which of the following is not a valid data type in Python?

a) integer
b) string
c) float
d) character

Answer: d) character

The Joy of Computing using Python NPTEL week 3 Assignment Solutions

Q6. 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)

a) Prints numbers from 1 to 20
b) Prints Fizz for multiples of 3 and Buzz for multiples of 5
c) Prints FizzBuzz for multiples of 3 and 5
d) None of the above

Answer: c) Prints FizzBuzz for multiples of 3 and 5

Q7. What is the output of the following code?
a = 5
b = 2
print(a // b)

a) 2
b) 2.5
c) 3
d) 2.0

Answer: a) 2

The Joy of Computing using Python NPTEL week 3 Assignment Solutions

Q8. What is the output of the following code?
s = “hello”
print(s[::-1])

a) “hello”
b) “olleh”
c) “hlo”
d) “leh”

Answer: b) “olleh”

The Joy of Computing using Python NPTEL week 3 Assignment Solutions

Q9. What is the output of the following code?
a = 10
b = 5
c = a % b
print(c)

a) 2
b) 5
c) 0
d) 1

Answer: c) 0

Q10. What is the output of the following code?
s = “python”
print(s[1:4])

a) “pyt”
b) “yth”
c) “tho”
d) “hon”

Answer: b) “yth”

The Joy of Computing using Python NPTEL week 3 Assignment Solutions

The Joy of Computing using Python NPTEL 2023 Week 3 Assignment Solutions

Q1. ___________ is the method to insert an item into a specified position in a list.

a) Push
b) Write
c) Insert
d) All of the above

Answer: c) Insert

Q2. Which method returns the number of occurrences of an element in a list.

a) Number of
b) Total
c) Count
d) Length

Answer: c) Count

Q3. The function random.randint(1,100) in python generates.

a) A random integer between 1 to 100 with 1 and 100 both inclusive
b) A random integer between 1 to 100 with 1 and 100 both exclusive
c) A random integer between 1 to 100 with only 100 inclusive
d) None of the above

Answer: a) A random integer between 1 to 100 with 1 and 100 both inclusive

Q4. The method open(“file1.txt”, r+) opens the file file1.txt in __________________.

a) Read only mode
b) Write only mode
c) Read Write mode
d) None of the above

Answer: c) Read Write mode

Q5. Consider the list L= [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]. What will be the output of the statement L [3:6]?

a) [2, 3, 5]
b) [0, 1, 1]
c) [1, 2, 3]
d) None

Answer: a) [2, 3, 5]

The Joy of Computing using Python NPTEL week 3 Assignment Solutions

Q6. What is the output of this code?
a,b = 1,0
a=a^b
b=a^b
a=a^b
print(a)

a) 0
b) 1
c) 2
d) This code will raise a runtime error

Answer: d)

Q7. What is the output of the following code?

Answer: 1

The Joy of Computing using Python NPTEL week 3 Assignment Solutions

Q8. What is the output of the following code?

a) False True
b) True False
c) True True
d) False False

Answer: a) False True

The Joy of Computing using Python NPTEL week 3 Assignment Solutions

Q9. Explain what the output will be when the code given below is executed.

a) The program throws an error
b) 5
c) 5.5
d) 4.5

Answer: d) 4.5

Q10. Which among the following statements is True with respect to the code given below?

a) count=50
b) The following code throws up an error.
c) count=550
d) count=450

Answer: d) count=450

The Joy of Computing using Python NPTEL week 3 Assignment Solutions

The Joy of Computing using Python NPTEL 2022 Week 3 Assignment Solutions

Q1. Which of the following statements describes the challenge ‘Fizz Buzz’?

a) Multiples of 3 should print buzz, multiples of 5 should print fizz, and multiples of 3 and 5 should print fizz buzz.
b) Multiples of 3 should print fizz, multiples of 5 should print buzz, and multiples of 3 or 5 should print fizz buzz.
c) Multiples of 3 should print fizz, multiples of 5 should print buzz, and multiples of 3 and 5 should print fizz buzz.
d) Multiples of 3 should print buzz, multiples of 5 should print fizz, and multiples of 3 and 5 should print fizz buzz.

Answer: c)

Q2. random.randint(1,100) will generate a number _________.(assume random is imported)

a) Between 1,100 both inclusive.
b) Between 1,100 both exclusive.
c) Between 1,100 only 100 inclusive.
d) Between 1,100 only 1 inclusive.

Answer: a) Between 1,100 both inclusive.

Q3. Consider a string of 20 digits initialized with all zeros as a DNA sequence, in the context of lectures, updating a random ‘zero’ as ‘one’ implies ___.

a) Updating a random number
b) Evolution
c) Degradation
d) Increase

Answer: b) Evolution

Q4. Which of the following method is correct to add an element at a specific position?

a) insert()
b) add()
c) append()
d) index()

Answer: a) insert()

Q5. What will be the output of the following program?

a) Python, C++, Java, Kotlin
b) 0, 1, 2, 3
c) 0, 1, 2, 3, 4
d) Python, C++, Java

Answer: b) 0, 1, 2, 3

The Joy of Computing using Python NPTEL week 3 Assignment Solutions

Q6. Which of the following methods is correct to count the number of instances on an element in a list?

a) total()
b) sum()
c) count()
d) numberof()

Answer: c) count()

Q7. In the Fizz Buzz game, What will be the output if the number is 285?

a) Fizz
b) Buzz
c) Fizz Buzz
d) No output

Answer: c) Fizz Buzz

The Joy of Computing using Python NPTEL week 3 Assignment Solutions

Q8. Which of the following keywords is used to define a function in python?

a) func
b) function
c) define function
d) def

Answer: d) def

The Joy of Computing using Python NPTEL week 3 Assignment Solutions

Q9. Which of the following statements are true about crowd-sourcing?

a) Answers received via crowdsourcing are never correct.
b) Answers received via crowdsourcing can be as good as the answer by an expert.
c) Answers received via crowdsourcing can be better than the answer by an expert.
d) Answers received via crowdsourcing are always correct.

Answer: b), c)

Q10. Which of the following commands is not correct in order to generate a graph?

a) import matplotlib.pyplot as plt
plt.plot([1,2,3,4],[5,6,7,8],ro)
b) import matplotlib.pyplot as plt
plt.plot([1,2,3,4],[5,6,7,8],r–)
c) import matplotlib.pyplot as plt
plt.plot([1,2,3,4],[5,6,7,8],bs)
d) import matplotlib.pyplot as plt
plt.plot([1,2,3,4],[5,6,7,8],r—)

Answer: d)

The Joy of Computing using Python NPTEL week 3 Assignment Solutions

<< Prev- The Joy of Computing using Python Week 2 Assignment Solutions

>> Next- The Joy of Computing using Python Week 4 Assignment Solutions


DISCLAIMER: Use these answers only for the reference purpose. Quizermania doesn't claim these answers to be 100% correct. So, make sure you submit your assignments on the basis of your knowledge.

For discussion about any question, join the below comment section. And get the solution of your query. Also, try to share your thoughts about the topics covered in this particular quiz.

Checkout for more NPTEL Courses: Click Here!

Leave a Comment

Your email address will not be published. Required fields are marked *