The Joy of Computing Using Python NPTEL Assignment 3 Answers
Are you looking for The Joy of Computing Using Python NPTEL week 3 Answers? You’ve come to the right place! Access the latest and most accurate solutions for your Assignment 3 in The Joy of Computing Using Python course
Course Link: Click Here
Table of Contents
The Joy of Computing Using Python NPTEL week 3 Answers (July-Dec 2024)
Q1.Which of the following is/are true statement(s)?
Lists are used to store multiple values.
One can access element in list by using non-numeric indices.
Iterating over lists is possible in Python.
We need to specify required size of list while creating a new list variable.
Answer: Lists are used to store multiple values, Iterating over lists is possible in Python.
Q2. In the below code
For what value of n does the program print 21 ?
Answer: 21
For answers or latest updates join our telegram channel: Click here to join
These are The Joy of Computing Using Python NPTEL Week 3 Answers
Q3. From the previous question, for what values of n is the number 7 appended to list a.
7
6
8
9
Answer: 8 , 9
Q4. What does the following code perform ?
It converts any input list into a new list which is filled with some alternative even and odd numbers.
It converts any input list into a new list such that at even indices, the value is a multiple of an even number and at odd indices, the value is either odd or even number.
It converts any input list into a new list such that at even indices, the value is multiple of 2 and at odd indices, the value is multiple of 3.
It converts any input list into a new list, which follows no pattern.
Answer: It converts any input list into a new list such that at even indices, the value is a multiple of an even number and at odd indices, the value is either odd or even number.
For answers or latest updates join our telegram channel: Click here to join
These are The Joy of Computing Using Python NPTEL week 3 Answers
Q5. From the previous question, if the option –
It converts any input list into a new list which is filled with some alternative even and odd numbers.
is incorrect, Can you make changes to code such that this option is true ?
No, it is not possible to make such changes.
No, the option is already correct.
Yes, we can make changes.
Answer: Yes, we can make changes.
Q6.If file.txt exists, Does the code successfully run ?
Yes
No
Answer: No
For answers or latest updates join our telegram channel: Click here to join
These are The Joy of Computing Using Python NPTEL week 3 Answers
Q7.Which of the following are examples of Social Computing ?
StackOverflow
Wikipedia
Quora
None
Answer: StackOverflow, Wikipedia, Quora
Q8. What does the following code print for n = 3?
WE KNOW THE WISDOM OF SERIES
WE ARE YET TO KNOW MANY THINGS
Answer: WE KNOW THE WISDOM OF SERIES
For answers or latest updates join our telegram channel: Click here to join
These are The Joy of Computing Using Python NPTEL week 3 Answers
Q9. From the previous question, is the variable n or a.sort() responsible for printing of either of the two possible sentences ?
No, it is not dependent on variable n, the code will never print ”WE ARE YET TO KNOW MANY THINGS”.
Yes on a.sort() only, but the code will never print ”WE ARE YET TO KNOW MANY THINGS”.
Yes on both, the code may print both sentences.
No, it is not dependent on a.sort(), the code will never print ”WE ARE YET TO KNOW MANY THINGS”.
Answer : No, it is not dependent on variable n, the code will never print ”WE ARE YET TO KNOW MANY THINGS”.
No, it is not dependent on a.sort(), the code will never print ”WE ARE YET TO KNOW MANY THINGS”.
Q10. What does the code in question 8, calculate ?
Can you say what the values of k and b are if n = 10294343763482 x 102309.
If values of k and b are different, enter 0, else enter value of k
Answer: 56
For answers or latest updates join our telegram channel: Click here to join
These are The Joy of Computing Using Python NPTEL week 3 Answers
All Weeks of The Joy of Computing Using Python: Click here
For answers to additional Nptel courses, please refer to this link: NPTEL Assignment Answers
The Joy of Computing Using Python NPTEL Week 3 Answers (Jan-Apr 2024)
Course Name: The Joy of Computing using Python
For answers or latest updates join our telegram channel: Click here to join
These are The Joy of Computing Using Python NPTEL Week 3 Answers
Q1. Consider the following code snippet:
What does the code do?
Takes a list of numbers as input, appends each number to a list, and prints the list of numbers
Takes a list of elements as input, appends each element to a list, and prints the list of elements
Takes the count of elements followed by the same number of elements as input, appends each element to a list, and prints the list of elements
Takes the count of elements, appends each element to a list, and prints the count of elements entered.
Answer: c. Takes the count of elements followed by the same number of elements as input, appends each element to a list, and prints the list of elements
Q2. Data Structure is a way by which you can organize/arrange your data. Which of the following statements are true about List Data Structure: [MSQ]
It is a flexible Data Structure
Elements could be added to a list.
Elements could be subtracted from a list.
This_is_not_List = [ ] is an empty list
Answer: a, b, c, d
It is a flexible Data Structure
Elements could be added to a list.
Elements could be subtracted from a list.
This_is_not_List = [ ] is an empty list
For answers or latest updates join our telegram channel: Click here to join
These are The Joy of Computing Using Python NPTEL Week 3 Answers
Q3. Consider the following code snippet:
What does the above code print?
Amar, Akbar, Anthony
amar is brother of anthony and akbar
Amar is brother of Anthony and Akbar
Anthony is brother of Akbar and Amar
Answer: d. Anthony is brother of Akbar and Amar
Q4. Consider the following code snippet:
What does the code do?
Takes a list of numbers, multiplies each number by 2, and prints the updated list
Takes a list of numbers, appends each number to the list twice, and prints the updated list
Takes a list of numbers, removes even numbers from the list, and prints the updated list
Takes a list of numbers, divides each number by 2, and prints the updated list
Answer: a. Takes a list of numbers, multiplies each number by 2, and prints the updated list
For answers or latest updates join our telegram channel: Click here to join
These are The Joy of Computing Using Python NPTEL Week 3 Answers
Q5. What will be the output of the following Python code?
“1111111111”
“0000000000”
A string with some 1s and some 0s
The function will raise an error
Answer: c. A string with some 1s and some 0s
Q6. Consider the following code snippet:
What does the code do?
Takes a list of numbers as input, computes the sum of the numbers, and prints the sum along with the average
Takes the count of elements, computes the sum of the elements, and prints the sum along with the average
Takes a list of numbers as input, computes the average of the numbers, and prints the average along with the sum
None of the above
Answer: b. Takes the count of elements, computes the sum of the elements, and prints the sum along with the average
For answers or latest updates join our telegram channel: Click here to join
These are The Joy of Computing Using Python NPTEL Week 3 Answers
Q7. What will be the output of the following Python code?
“Python”
A random permutation of the letters in “python”
“random”
The function will raise an error
Answer: b. A random permutation of the letters in “python”
Q8. Consider the following code snippet:
What does the code do? [MSQ]
Reverses the numbers list and stores it in new_numbers.
Creates an empty list named new_numbers and appends elements from numbers to it in reverse order.
Produces an error due to an invalid function used for list manipulation.
Generates a new list new_numbers with elements from numbers in the same order as numbers.
Answer: a, b
For answers or latest updates join our telegram channel: Click here to join
These are The Joy of Computing Using Python NPTEL Week 3 Answers
Q9. Which of the following are the examples of Social Computing/Crowd Computing: [MSQ]
Wikipedia
Stack Exchange
Quora
Facebook
Answer: a, b, c, d
Wikipedia
Stack Exchange
Quora
Facebook
Q10. Consider the following code snippet:
What does the code do?
Prints numbers from 1 to 20, replacing multiples of 3 with “Fizz”, multiples of 5 with “Buzz”, and multiples of both 3 and 5 with “FizzBuzz”.
Prints numbers from 1 to 20, replacing multiples of 3 and 5 with “FizzBuzz”, multiples of 3 with “Fizz”, and multiples of 5 with “Buzz”.
Prints numbers from 1 to 20, replacing multiples of 3 with “Fizz”, multiples of 5 with “Buzz”, and numbers divisible by both 3 and 5 with their product.
Prints numbers from 1 to 20, replacing multiples of 3 with “Buzz”, multiples of 5 with “Fizz”, and numbers divisible by both 3 and 5 with “FizzBuzz”.
Answer: a. Prints numbers from 1 to 20, replacing multiples of 3 with “Fizz”, multiples of 5 with “Buzz”, and multiples of both 3 and 5 with “FizzBuzz”.
For answers or latest updates join our telegram channel: Click here to join
These are The Joy of Computing Using Python NPTEL Week 3 Answers
Question 1
You are given a list marks that has the marks scored by a class of students in a Mathematics test. Find the median marks and store it in a float variable named median. You can assume that marks is a list of float values.
Solution:
for i in range(0, len(marks)):
for j in range(i+1, len(marks)):
if marks[i] >= marks[j]:
marks[i], marks[j] = marks[j],marks[i]
#print(marks)
m=len(marks)//2
if len(marks)%2!=0:
median=marks[m]
else:
median=(marks[m-1]+marks[m])/2
For answers or latest updates join our telegram channel: Click here to join
These are The Joy of Computing Using Python NPTEL Week 3 Answers
Question 2
Accept a string as input, convert it to lower case, sort the string in alphabetical order, and print the sorted string to the console. You can assume that the string will only contain letters.
Solution:
get=input()
get=get.lower()
print(“”.join(sorted(get)), end=””)
For answers or latest updates join our telegram channel: Click here to join
These are The Joy of Computing Using Python NPTEL Week 3 Answers
Question 3
You are given the dates of birth of two persons, not necessarily from the same family. Your task is to find the younger of the two. If both of them share the same date of birth, then the younger of the two is assumed to be that person whose name comes first in alphabetical order (names will follow Python’s capitalize case format).
The input will have four lines. The first two lines correspond to the first person, while the last two lines correspond to the second person. For each person, the first line corresponds to the name and the second line corresponds to the date of birth in DD-MM-YYYY format. Your output should be the name of the younger of the two.
Solution:
p1=input()
dob1=input()
p2=input()
dob2=input()
y1=int(dob1.split(‘-‘)[2])
y2=int(dob2.split(‘-‘)[2])
m1=int(dob1.split(‘-‘)[1])
m2=int(dob2.split(‘-‘)[1])
d1=int(dob1.split(‘-‘)[0])
d2=int(dob2.split(‘-‘)[0])
if (y1>y2):
print(p1,end=””)
elif (y2>y1):
print(p2,end=””)
else:
if(m1>m2):
print(p1,end=””)
elif(m2>m1):
print(p2,end=””)
else:
if(d1>d2):
print(p1,end=””)
elif(d2>d1):
print(p2,end=””)
else:
print(min(p1,p2),end=””)
For answers or latest updates join our telegram channel: Click here to join
These are The Joy of Computing Using Python NPTEL Week 3 Answers
The Joy of Computing Using Python NPTEL Week 3 Answers (July-Dec 2023)
Course Name: The Joy of Computing using Python
These are The Joy of Computing Using Python NPTEL Week 3 Answers
Q1. 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, d, e
Q2. 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: {1: “one”, 2: “two”, 3: “three”}
Q3. Which of the following method is correct to add an element at a specific position?
insert()
add()
append()
index()
Answer: insert()
These are The Joy of Computing Using Python NPTEL Week 3 Answers
Q4. 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: list.append(item)
Q5. Which of the following is not a valid data type in Python?
integer
string
float
character
Answer: character
Q6. What is the output of the following code?
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: Prints FizzBuzz for multiples of 3 and 5
These are The Joy of Computing Using Python NPTEL Week 3 Answers
Q7. What is the output of the following code?
a = 5
b = 2
print(a // b)
2
2.5
3
2.0
Answer: 2
Q8. What is the output of the following code?
s = “hello”
print(s[::-1])
“hello”
“olleh”
“hlo”
“leh”
Answer: “olleh”
Q9. What is the output of the following code?
a = 10
b = 5
c = a % b
print(c)
2
5
0
1
Answer: 0
These are The Joy of Computing Using Python NPTEL Week 3 Answers
Q10. What is the output of the following code?
s = “python”
print(s[1:4])
“pyt”
“yth”
“tho”
“hon”
Answer: “yth”
These are The Joy of Computing Using Python NPTEL Week 3 Answers