The Joy of Computing using Python | NPTEL 2023 | Week 9 Assignment Solutions
ABOUT THE COURSE :
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. The
course brings programming to your desk with anecdotes, analogies and
illustrious examples. Turning abstractions to insights and engineering to
art, the course focuses primarily to inspire the learner's mind to think
logically and arrive at a solution programmatically. As part of the course,
you will be learning how to practice and culture the art of programming with
Python as a language. At the end of the course, we introduce some of the
current advances in computing to motivate the enthusiastic learner to pursue
further directions.
Course Status : Upcoming
Course Type : Elective
Duration : 12 weeks
Start Date : 23 Jan
2023
End Date : 14 Apr 2023
Exam Date : 29 Apr 2023 IST
Enrollment Ends : 30 Jan 2023
CRITERIA TO GET A CERTIFICATE :
Average assignment score = 25% of 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 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.
NOTE: Please note that there will not be an unproctored programming exam
for this course this term.
The Joy of Computing using Python Week 9 Assignment Solutions :-
Q1) How can we identify which book is written by which author?
a) By matching handwriting.
b) By analyzing word length distribution with previous books.
c) By analyzing the number of pages in a book.
d) By analyzing the book’s preface.
Answer :- (b) By analyzing word length distribution with previous books.
Q2) Is it guaranteed that the following code snippet will consistently yield a True result?
a) True
b) False
c) It will return neither True nor False
d) It will thow an error
Answer :- (b) False
Q3) What are the different methods available in Python for generating a string?
a) By using single quotes.
b) By using double quotes.
c) By using triple quotes.
d) All of the above
Answer :- (d) All of the above
Q4) A complete graph will have __ degree of separation
a) 1
b) 2
c) 3
d) Depends on the number of nodes
Answer :- (a) 1
Q5) Networkx in pythons is used for
a) Making networks
b) Analyzing networks
c) Visualizing networks
d) Breaking networks
Answer :- (a), (b), (c)
Q6) In the world, on average, how many hops will it take to connect two people?
a) 6
b) 7
c) 8
d) 9
e) 10
Answer :- (a) 6
Answer :- (b) 2
Q8) Assuming that the length and breadth remain constant, how can we enhance the precision of the calculated area for a state?
a) By increasing the size of the image.
b) By increasing the number of points.
c) By decreasing the size of the image.
d) By decreasing the number of points.
Answer :- (b) By increasing the number of points.
Q9) Degree of separation is equivalent to
a) Number of nodes in a graph
b) Number of edges in a graph
c) The average length of the shortest path in a graph
d) None of the above
Answer :- (c) The average length of the shortest path in a graph
Q10) While calculating the area of Punjab, which of the following will help in more accurate results.
a) More points landed in the Punjab region.
b) More points landed outside the Punjab.
c) More points on the overall map.
d) None of the above.
Answer :- (a) More points landed in the Punjab region.
Week 9 Programming Assignment 1 :-
Given two string s1 and s2, write a function subStr which accepts two parameters s1 and s2 and will return True if a s2 is a substring of s1 otherwise return False. A substring is a is a contiguous sequence of characters within a string.
Input:
bananamania
nana
Output:
True
Week 9 Programming Assignment 1
def subStr(s1,s2): return(s2 in s1)
Week 9 Programming Assignment 2 :-
Given two dictionaries d1 and d2, write a function mergeDic that accepts two dictionaries d1 and d2 and return a new dictionary by merging d1 and d2.
Note: Contents of d1 should be appear before contents of d2 in the new dictionary and in same order. In case of duplicate value retain the value present in d1.
Input:
{1: 1, 2: 2}
{3: 3, 4: 4}
output:
{1: 1, 2: 2, 3: 3, 4: 4}
Week 9 Programming Assignment 2
def mergeDic(d1,d2): for i in d2.keys(): if i not in d1.keys(): d1[i]=d2[i] return(d1)
Week 9 Programming Assignment 3 :-
Take an integer N as an input, print all the indexes of numbers in that integer from left to right.
Input:
122345
Output:
1 0
2 1 2
3 3
4 4
5 5
Week 9 Programming Assignment 3
n=int(input()) idp=dict() for i in str(n): idp[i]=[] for j in range(len(str(n))): if i==str(n)[j]: idp[i]+=[j] for k in idp: print(k,*idp[k],"")
Follow Us