NPTEL The Joy Of Computing Using Python Assignment 3 Answers 2023

NPTEL The Joy of Computing using Python Assignment 3 Answers 2023:- All the Answers provided here to help the students as a reference, You must submit your assignment at your own knowledge.

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 :- For Answer Click Here

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 :- 

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

insert()
add()
append()
index()

Answer :- For Answer Click Here

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 :- 

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

integer
string
float
character

Answer :- For Answer Click Here

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 :- For Answer Click Here

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

2
2.5
3
2.0

Answer :- 

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

“hello”
“olleh”
“hlo”
“leh”

Answer :- For Answer Click Here

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

2
5
0
1

Answer :- 

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

“pyt”
“yth”
“tho”
“hon”

Answer :- For Answer Click Here
Course NameThe Joy Of Computing Using Python
CategoryNPTEL Assignment Answer
Home Click Here
Join Us on TelegramClick Here

NPTEL The Joy of Computing using Python Assignment 3 Answers [July 2022]

1. 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

2. 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

Answers will be Uploaded Shortly and it will be Notified on Telegram, So JOIN NOW

NPTEL The Joy Of Computing Using Python Assignment 3 Answers 2023

3. 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

4. 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

5. 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

6. 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

👇For Week 04 Assignment Answers👇

NPTEL The Joy Of Computing Using Python Assignment 3 Answers 2023

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

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

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

Answer:- d

9. 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:- For Answers Click Here

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

Answer:- d

NPTEL The Joy Of Computing Using Python Assignment 3 Programming Solutions

Q1. There is list L containing some numbers. Write a program to create a new list which contains the numbers which are either divisible by 5 or 7 or both. Print that new list in ascending order.

Code:-

ans=[z for z in L if z%5==0 or z%7==0]
print(sorted(ans),end="")

Q2. Write a function rev which takes a list L and integer n and print the first n largest numbers of the list.

Code:-

def rev(L,n):
  print(sorted(L)[::-1][:n],end="")

Q3. Write a program to count and print the number of odd numbers in a list L.

Code:-

odd=[a for a in L if a%2!=0]
print(len(odd),end="")

For More NPTEL Answers:- CLICK HERE

Join Our Telegram:- CLICK HERE

What is The Joy Of Computing Using Python?

The Joy Of Computing Using Python is a fun-filled whirlwind tour of 30 hrs, covering everything you need to know to fall in love with the most sought-after skill of the 21st century. This course includes examples of analytics in a wide variety of industries, and we hope that students will learn how you can use analytics in their careers and life. One of the most important aspects of this course is that you, the student, are getting hands-on experience creating analytics models; we, the course team, urge you to participate in the discussion forums and to use all the tools available to you while you are in the course!

CRITERIA TO GET A CERTIFICATE

Average assignment score = 25% of the average of best 8 assignments out of the total 12 assignments given in the course.
Exam score = 75% of the proctored certification exam score out of 100

Final score = Average assignment score + Exam score

YOU WILL BE ELIGIBLE FOR A CERTIFICATE ONLY IF THE AVERAGE ASSIGNMENT SCORE >=10/25 AND EXAM SCORE >= 30/75. If one of the 2 criteria is not met, you will not get the certificate even if the Final score >= 40/100.

NPTEL The Joy of Computing using PythonAnswers
Assignment 1Click Here
Assignment 2Click Here
Assignment 3Click Here
Assignment 4Click Here
Assignment 5Click Here
Assignment 6NA
Assignment 7NA
Assignment 8NA
Assignment 9NA
Assignment 10NA
Assignment 11NA
Assignment 12NA

NPTEL The Joy Of Computing Using Python Assignment 3 Answers Jan 2022

Q1. What will be the output of the following code?

NPTEL The Joy Of Computing Using Python Assignment 3 Answers 2023

(A) Practice,Practice,Practice,Practice,Practice 
(B) Practice makes the man perfect. 
(C) Practice makes man perfect. the 
(D) Makes man perfect. Practice the

Answer:- (C) Practice makes man perfect. the 

👇FOR NEXT WEEK ASSIGNMENT ANSWERS👇

NPTEL The Joy Of Computing Using Python Assignment 3 Answers 2023

Q2. What should be the code to print all Even numbers between 1-10 (both inclusive)?

Answer:- (C)

Q3. What will be the output of the following code?

NPTEL The Joy Of Computing Using Python Assignment 3 Answers 2023

(A) Sorted List(L) containing random elements between 0-10 in descending order.
(B) Sorted List containing random elements between 0-10 in ascending order. 
(C) Sorted List containing elements between 0-10. 
(D) Sorted List containing elements between 0-9 in ascending order.

Answer:- (A) Sorted List(L) containing random elements between 0-10 in descending order.

Q4. What will be the output of the following code?

(A) we were here together 
(B) we were here 
(C) we were 
(D) we

Answer:- (B) we were here 

Q5. What will be the value of list L?

NPTEL The Joy Of Computing Using Python Assignment 3 Answers 2023

(A) [‘Even’, ‘Odd’, ‘Even’, ‘Odd’] 
(B) [‘Even’, ‘Odd’, ‘Even’, ‘Odd’, ‘Even’, ‘Odd’] 
(C) [‘Even’, ‘Odd’, ‘Even’, ‘Even’, ‘Even’] 
(D) [‘Even’, ‘Odd’, ‘Even’, ‘Odd’, ‘Even’]

Answer:- For Answer Click Here

Q6. What is the correct code for a function to return the sum of elements of list L?

NPTEL The Joy Of Computing Using Python Assignment 3 Answers 2023
(A)
NPTEL The Joy Of Computing Using Python Assignment 3 Answers 2023
(B)
NPTEL The Joy Of Computing Using Python Assignment 3 Answers 2023
(C)
NPTEL The Joy Of Computing Using Python Assignment 3 Answers 2023
(D)

Answer:- (A)

👇FOR NEXT WEEK ASSIGNMENT ANSWERS👇

NPTEL The Joy Of Computing Using Python Assignment 3 Answers 2023

Q7. What does the following code represent?

(A) Checks if a is divisible by b. 
(B) Checks if b is divisible by a. 
(C) Checks if a and b are multiples of 5. 
(D) None of the above.

Answer:- (A) Checks if a is divisible by b. 

Q8. Suppose there exists a file named file.txt. What the following code will do?

NPTEL The Joy Of Computing Using Python Assignment 3 Answers 2023

(A) Print whatever is there in the file and add hey there. 
(B) Throws an error in the end as the file is not opened in writable mode. 
(C) Throws an error in the end as the file is not opened in readable mode. 
(D) No error will be thrown and the code will work fine.

Answer:- (B) Throws an error in the end as the file is not opened in writable mode. 

Q9. Suppose there is an empty file named file.txt. What will be the output of the following code?

NPTEL The Joy Of Computing Using Python Assignment 3 Answers 2023

(A) writing this file again 
(B) hey there!! 
(C) hey there!!writing this file again 
(D) Throws an error

Answer:- (C) hey there!!writing this file again 

Q10. What will be the output of the following code?

NPTEL The Joy Of Computing Using Python Assignment 3 Answers 2023

(A) Alternative 1’s and 0’s respectively 
(B) Alternative 0’s and 1’s respectively. 
(C) All Zeroes towards left and ones towards the right. 
(D) All ones towards the left and zeroes towards the right.

Answer:- (A) Alternative 1’s and 0’s respectively 

The Joy Of Computing Using Python Programming Assignment week 3

Q1. You are given a list named L. Print all the elements at odd position of list L.(We will take care of the input, you just have to print elements present at odd position)

Code:-

for a in range(len(L)):
  if a%2!=0:
    if len(L)-a<=2:
      print(L[a],end="")
    else:
      print(L[a])

Q2. You are given a list L. Print the list of first 3 smallest elements in ascending order and last 2 greatest elements in descending order of the list L respectively.(We will take care of the input)

Code:-

print(sorted(L)[:3])
print(sorted(L)[::-1][:2],end="")

Q3. You are given a list L. Write a function all_even that accepts the list Land print all the even numbers is the list L.(Order of the numbers should be same as the order present in the list)

Code:-

def all_even(L):
  ans=[]
  for i in L:
    if i%2==0:
      ans.append(i)
  for a in range(len(ans)):
    if a==len(ans)-1:
      print(ans[a],end="")
    else:
      print(ans[a])

👇FOR NEXT WEEK ASSIGNMENT ANSWERS👇

NPTEL The Joy Of Computing Using Python Assignment 3 Answers 2023

Disclaimer:- We do not claim 100% surety of solutions, these solutions are based on our sole expertise, and by using posting these answers we are simply looking to help students as a reference, so we urge do your assignment on your own.

For More NPTEL Answers:- CLICK HERE

Join Our Telegram:- CLICK HERE

NPTEL The Joy of Computing using Python Assignment 3 Answers 2022:- All the Answers provided here to help the students as a reference, You must submit your assignment at your own knowledge.