[go: up one dir, main page]

0% found this document useful (0 votes)
60 views18 pages

Assignment 7-12

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views18 pages

Assignment 7-12

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

Week 7: Assignment 7

The due date for submitting this assignment has passed.

Due on 2024-09-11

Assignment submitted on 2024-09 -10, 20:50 1ST


1) Which of the following methods is used to read the content of a CSV file in Python using the csv module?

• csv.readerO
csv.writeO
csv.loadO
csv. readfi leO

Yes, the answer is correct.


Score: 1
Accepted Answers:
csv.readerO

2) Which command is used to install a Python package using pip?

• pip install package-name


install pip package-name
python install package-name
pip package-name install

Yes, the answer is correct.


Score: 1
Accepted Answers:
pip install package-name

3) What is the primary purpose of the gmplot library in Python? 1

To create 3D plots
• To plot data on Google Maps
To generate matplotlib graphs
To create dashboards
Yes, the answer is correct.
Score: 1
Accepted Answers:
To plot data on Google Maps

4) In a game of Snakes and Ladders, a player is currently on square 96. There ls a snake on square 99 that sends the player back to square
78. If the
player wishes to reach square 100 in one dice throw, what number must they roll on the dice?
i onlinecourses.nptel.ac.in

4) In a game of Snakes and Ladders, a player is currently on square 96. There is a snake on square 99 that sends the player back to square 78. If the
player wishes to reach square 100 in one dice throw, what number must they roll on the dice?

Yes, the answer is correct.


Score: 1
Accepted Answers:
(Type: Numeric) 4

1 point

5) In the same scenario, where the player is on square 96 and needs to roll a 4 to reach square 100, what is the probability of rolling this number o~1 point
a fair six-sided die?

1/2
1/3
1/4
1/6

Yes, the answer is correct.


Score: 1
Accepted Answers:
1/6

6) Which of the following commands will draw a square using Python's turtle module? 1 point
Turtle is imported in the following way-
import turtle as t
turtle = t.Turtle()

./ for i in range(4):
turtle. forward(100)
turtJe.left(90)

for i in range(4):
turtle. forward(100)
turtle.right(90)

for i in range(4):
turtle.backward(100}
turtle.laft(90)

for i in range(4):
turtle.backward(100)
turtle.nght(90}
7) Does the turtle module in Python allow you to draw complex shapes on the screen?

Yes
No

Yes, the answer is correct.


Score: 1
Accepted Answers:
Yes

8) What is the purpose of the lurtle.penupQ and turtle.pendownO commands in Python's turtle module?

• To stop the turtle from drawing and then resume drawing at a new position
To change the color of the turtle's pen
To speed up or slow down the drawing speed of the turtle

Yes, the answer is correct.


Score: 1
Accepted Answers:
To stop the turtle from drawing and then resume drawing at a new position

9) What is the default drawing state of the turtle when a new turtle object is created in Python's turtle module?

The turtle's pen is up, so it does not draw while moving.


• The turtle's pen is down, so it draws while moving.
The turtle is hidden, so it does not appear on the screen.
The turtle starts with a circular shape.

• Yes, the answer is correct.


Score: 1
Accepted Answers:
The turtle's pen is down, so it draws while moving.

10) Which of the following commands is used to open an image file using Python's PIL (Pillow) library?

img = PIL.lmage.open('image.jpg')
• img = lmage.open('image.jpg')
img = open_image('image.jpg')
img = PIL.open_image('image.jpg')
Yes, the answer is correct.
Score: 1
Accepted Answers:
img = lmage.open('image.jpg')
We ek 8: Assignment 8
The due date for submitting this assignment has passed.

Assignment submitted on 2024 -09-1 7, 21 :34 1ST


1) Which of the following is a valid way to create a tuple in Python?

t = (1, 2, 3)
✓ t = (1, 2, 3)
t = {1, 2, 3}
✓ t = 1, 2, 3

Yes, the answer is correct.


Score: 1
Accepted Answers :
t = (1, 2, 3)
t = 1, 2, 3
2) Which of the following operations is valid on a tuple?

t[1] = 4
t.append(4)
• t = t + (4,)
del t[1]

Yes, the answer is correct.


Score: 1
Accepted Answers:
t = t + (4,)
3) What will the following code output?

t=[1,2,3 ]
print(type((t,t)))

< class 'list' >


< class 'set' >
< class 'tuple' >
Error

Yes. the answer is correct.


4) What is the primary ·purpose of the matplotlib.pyplot module in Python?

To perform matrix operations.


To handle file 1/0 operations.
, To generate and customi ze visualizations like plots and graphs.
To manipulate and process images.

Yes, the answer is correct.


Score: 1
Accepted Answers:
To generate and customize visualizations like plots and graphs.

5) Which of the following statements is true about anagrams?


• 1p
Two strings of different lengths can be anagrams.
Two strings are anagrams if they contain the same characters in the same order.
• Two strings are anagrams if they contain the same characters in different orders.

Yes, the answer is correct.


Score: 1
Accepte d Answers:
Two strings are anagrams if they contain the same characters in different orders.

6) Every character, whether an alphabet, digit, or special character, has an ASCII


value. Which of the following methods is used to find the ASCII 1 poi
value?

ASCJl('a'}
• ord('a'}
int('a'}
ASC_val('a'}

Yes, the answer is correct.


Score: 1
Accepte d Answers :
ord('a')
7) Which of the following libraries is commonly used to determine the intensity of emotions
in sentiment analysis? 1 point
• VADER
Numpy
Pandas
SciPy
Yes, the answer is correct.
Score: 1
Accepted Answers:
VADER

i onlinec ourses .nptel.a c.in
- C
Accepted Answers:
VADER

8) Which of the following Python code snippets correctly checks if two strings
are anagrams? 1 point
• def are_anagrams(str1 , str2):
return sorted(str1) == sorted(str2)

def are_anagrams(str1 , str2):


return set(str1) == set(str2)

def are_anagrams(str1 , str2):


return str1 == str2(::-1]

def are_anagrams(str1 , str2):


return len(str1) == len(str2)
Yes, the answer is correct.
Score: 1
Accepted Answers:
def are_anagrams(str1, str2):
return sorted(str1) == sorted(str2)

9) Why is gamblin g general ly a bad decision ?


1 point
• Becaus e you will lose more money than you win over time.
Becaus e the probabi lity of winning is always 0.
Becaus e you will always win.
Becaus e the amount of money you can win is always greater than the
amount you lost over time
Yes, the answer is correct.
Score: 1
Accepte d Answers:
Because you will lose more money than you win over time.
1 0) True or False: A significa nt amount of information can be extracte
d from an Image by applying the appropriate image enhancement techniqu
es 1 point
True
False
Yes, the answer is correct.
Score: 1
Accepte d Answers :
True
i onlinecourses.nptel.ac.in

Week 9: Assignment 9
The due date for submitting this assignment has passed.
Due on

Assignment submitted ,on 2024-09-24, 18:37 1ST


1) 'nltk.downloadQ' function downloads necessary packages for the Natural Language Toolkit (NLTK) library?

• True
False

Yes, the answer is correct.


Score: 1
Accepted Answers:
True

2) Which of the following best defines a complete graph?

• A graph where.every pair of distinct vertices is connected by a unique edge


A graph with no edges
A graph with a single vertex
A graph with at least one loop

Yes, the answer is correct.


Score: 1
Accepted Answers:
A graph where every pair of distinct vertices is connected by a unique edge

3) How many edges are there in a complete graph with 4 nodes?

• 6
8
12
16

Yes, the answer is correct.


Score: 1
Accepted Answers:
6

4) Which Python library is most commonly used for working with graphs related to networks?

Random
Pandas
NumPy
NetworkX
5) Gephi is:

A Python library for linear algebra


• A software for visualizing and analyzing large networks
A tool for data cleaning and preprocessing
A Python library for building statistical models

Yes, the answer is correct.


Score: 1
Accepted Answers:
A software for visualizing and analyzing large networks

6) How many attributes typically define a color in digital representations?

1
2
• 3
9

Yes, the answer is correct.


Score: 1
Accepted Answers:
3

7) What is the degree of a node in a graph?

• The ~umber of edges connected to the node


The shortest path between two nodes
The number of nodes in the graph
The distance from the node to the center of the graph

Yes, the answer is correct.


Score: 1
Accepted Answers:
The number of edges connected to the node

8) What is the primary goal of stylometry?

• To analyze the style and structure of literary works for authorship attribution
To create stylized graphics for digital art
To study phonology of languages
To enhance the readability of texts by adjusting font styles

Yes, the answer is correct.


Score: 1
Accepted Answers:
To analyze the style and structure of literary works for authorship attribution

i onlinecourses.nptel.ac.in

8) What is the primary .goal of stylometry?

• To analyze the style and structure of literary works for authorship attribution
To create stylized graphics for digital art
To study phonology of languages
To enhance the readability of texts by adjusting font styles

Yes, the answer is correct.


Score: 1
Accepted Answers:
To analyze the style and structure of literary works for authorship attribution

9) Given the following Python code, what is printed in the end?

x =["apple", "banana", "cherry", "date"]


k=O
for item in x:
k += len(item)

print(k)

4
• 21
24
26

Yes, the answer is correct.


Score: 1
Accepted Answers:
21

1O) How can you estimate the area of a sub-region within a larger region by randomly throwing points in the larger region?

By counting the total number of points and calculating the sum of their distances from the center
• By calculating the proportion of points that land in the sub-region compared to the total number of points in the larger region
By calculating the distance between each point and the boundary of the region
By averaging the coordinates of all the points that land in the larger region

Yes, the answer is correct.


Score: 1
Accepted Answers:
By calculating the proportion of points that land In the sub-region compared to the total number of points in the larger region

J
i onlinecourses.nptel.ac.in

Week 10: Assignment 1O


The due date for submitting this assignment has passed.
Due on 2024-10-0

Assignment submitted on 2024-10-01, 21 :05 1ST


1) What will be the output of the following Python code?

s = "Hello, World!"
print (s[7:12 ))

• "World"
"World!"
"Worl"
"orld"

Yes, the answer is correct.


Score: 1
Accepted Answers:
"World"

2) Which string method would you use to remove all leading and trailing whitespace from a string in Python?

• stripp
splitO
replaceO
joinO

Yes, the answer is correct.


Score: 1
Accepted Answers:
stripO

3) Given the strings= "PythonProgrammlng", what does s (::2) return?

"PythonProgramming"
"Pto rgamn"
"PyonPormig"
"PtoPormig"
Yes, the answer is correct.
Score: 1
Accepted Answers:
"PtoPormig"
• i onlinecours es.nptel.ac. in

4) Why are names often converted to lowercase and spaces removed when implementing the FLAMES game in Python?

To increase game difficulty


• To ensure consistent character comparison
Because uppercase letters are not supported in Python strings
To encrypt the names for privacy

Yes, the answer is correct.


Score: 1
Accepted Answers:
To ensure consistent character comparison

5) Given the names "Alice" and "Bob", what is the FLAMES result of their relationship according to the FLAMES game?

Friends
Love
• Affection
Marriage
Enemy
Siblings

Yes, the answer is correct.


Score: 1
Accepted Answers:
Affection
1
6) Given· a= np.array ((1, 2, 3, 4, 5)), what does print(a[1 :4)) output?

(1 2 3)
• (2 3 4)
[2 3 4 5)
[1 2 3 4)

Yes, the answer is correct.


Score: 1
Accepted Answers:
{2 3 4]

7) In the NumPy array arr= np.array ( [ [1,2,3),(4,5,6),[7,8,9)] ), what is the value of arr (1,2)? 1p

5
6
2
8

Yes, the answer is correct.


Score: 1
8

Yes, the answ er is corre ct


Scor e: 1 •
Acce pted Answ ers:
6

8) Wha t is the outpu t of the follow ing Pytho n code


?
s = "abcd ef"
print (s[1 :5:2])

• "bd"
"bed "
"ace"
"be 11

Yes, the answ er is corre ct.


Scor e: 1
Acce pted Answ ers:
"bd"

9) Can nump y be used when worki ng with image s


in Python?
• Yes
No

Yes, the answ er is corre ct.


Scor e: 1
Acce pted Answers:
Yes •

1 0) When comp aring lossy and lossle ss comp ressio


n methods, which of the following statements is true?
Loss y comp ressi on reduc es file size witho ut any
loss of quality.
Lossl ess comp ressi on reduc es file size witho ut any
loss of quality.
Yes, the answ er is corre ct.
Score : 1
Acce pted Answ ers: •
Lossl ess comp ressi on reduc es file size witho ut
any loss of quality.

J i onlinecourses.nptel.ac.in

Week 11: Assignment 11


The due date for submitting this assignment has passed.
Du

Assignment submitted on 2024-10-08, 21 :13 1ST


1) Which Python library is commonly used for automating web browsers for tasks like testing or web scraping?

datetime
• selenium
chrome
webdriver

Yes, the answer is correct.


Score: 1
Accepted Answers:
selenium

2) In Selenium, what is the purpose of the WebDriver (e.g., webdriver.ChromeO)?

To interact with databases.


To send HTTP requests
• To control a web browser programmatically
To parse HTML and XML documents

Yes, the answer is correct.


Score: 1
Accepted Answers:
To control a web browser programmatically

3) Which method is used in Selenium to open a specific URL in the web browser?

driver.open(url)
driver.load(url)
driver.navigate(url)
• driver.get(url)

Yes, the answer is correct.


Score: 1
Accepted Answers:
driver.get(urlj

4) In Selenium, how can you simulate pressing the Enter key in a text input field?

input field.send keys(Keys.ENTER)


input field.submitO
i onlinecourses.nptel.ac.in

4) In Selenium, how can you simulate pressing the Enter key in a text input field?

• input field.send keys(Keys.ENTER)


input field.submitO
input field.send keys(Keys.RETURN)
input field.press('Enter')

No, the answer is incorrect.


Score: 0
Accepted Answers:
input field.send keys(Keys.RETURN)

5) How can you get the current local date and time in Python using the datetime module?

datetime.date. todayO
• datetime.datetime.nowO
datetime.time.nowO

Yes, the answer is correct.


Score: 1
Accepted Answers:
datetime. datetime.nowO

6) Which function from the calendar module can be used to create a formatted string representing a month's calendar?

calendar.printrnonthO
• calendar.monthO
calendar. rnonthcalendarO

Yes, the answer is correct.


Score: 1
Accepted Answers:
calendar.monthO

7) Which function would you use to replace characters in a string in Python? 1p

string.rnodify0
string.replace(old, new)
string.rernove(old)
string.update(new)

Yes, the answer is correct.


Score: 1
Accepted Answers:
string.replace(old, new)

8) Which of the following statements correctly imports the datetime module in Python? 1 poi

imoort datetime
i onlinecourses.nptel.ac.in

Accepted Answers:
string.replace(old, new)

8) Which of the following statements correctly imports the datetime module in Python?

import datetime
from datetime import datetime
import datetime as dt
• All of the given options

Yes, the answer is correct.


Score: 1
Accepted Answers:
All of the given options

9) What does the following Python code output?

import calendar
print(calendar.isleap(2024))

• True
False
2024.0
None

Yes, the answer is correct.


Score: 1
Accepted Answers:
True

10) Using the datetime module, how can you print the current date 7 times, each time increasing the day by 1 from the current date?

for i in range(?):
print(datetime.datetime.now0 + datetime.timedelta(days=i))
• for i in range(?):
print(datetime.date.today0 + datetime. timedelta(days=i))
for i in range(?):
print(datetime.datetime. todayQ.add(days=i))
for i in range(?):
print(datetime.date.nowQ.add(days=i))

Yes, the answer is correct.


Score: 1
Accepted Answers:
for i in range(?):
print(datetime.date. todayO + datetlme. tlmedelta(days=i))
J • i onlinecourses.nptel.ac.in

Week 12: Assignment 12


The due date for submitting this assignment has passed.
Due on 2024-10-16, 2

Assignment submitted on 2024-10-15, 18:28 1ST


1) What is the key operation performed when the number n in the Collatz Conjecture is even?

Add 1
Multiply by 3 and add 1
• Divide by 2
Subtract 1

Yes, the answer is correct.


Score: 1
Accepted Answers:
Divide by 2

2) What happens to an odd number n in the Collatz Conjecture sequence?

It is divided by 2
It remains unchanged

It is replaced by n x 3 + 1

It is replaced by n - I
Yes, the answer is correct.
Score: 1 •
Accepted Answers:
It is replaced by n X 3 + 1

3) What is the ultimate goal of the Collatz Conjecture sequence? 1p

Reach the number 0


Return to the starting number
• Reach the number 1
Cycle through odd numbers

Yes, the answer is correct.


Score: 1
Accepted Answers:
Reach the number 1

4) Which of the following best describes the Collatz Conjecture? 1 poi


.in
• i on /in eco urs es. np te/ .ac

nje ctu re?


t des crib es the Co llat z Co
4) Which of the foll ow ing bes

ura l num ber s


It has been pro ven for all nat
ble m in ma the ma tics
It remains an unsolved pro
sim ple sol utio n
It is a trivial pro ble m wit h a
ber s
It onl y applies to prim e num

Yes, the ans we r is cor rec t.


Score: 1 . 1p
.
Acc ept ed Answers: in ma the ma tics
ble m
It remains an unsolved pro
d by Go ogl e?
at is the ma in ide a beh ind the PageRank alg orit hm use
5) Wh
rds on a pag e
Count the num ber of key wo b link s
dom wa lks on a gra ph of we
• Rank pages based on ran
reviews
Rank pages based on user
Rank pages alphabetically

Yes, the ans we r is cor rec t.


Score: 1
Acc ept ed Answers: s
walks on a graph of web link 1 po i
Rank pages based on random er imp ort ant pa ge s?
a pag e has a hig her num ber of inb oun d link s fro m oth
pens when
6) In PageRank, what hap
load on the ser ver
Its rank decreases due to the
• Its rank increases
Its rank remains unchanged
t page
It is marked as a less relevan
Yes, the answer is correct.
Score: 1
Accepted Answers:
Its rank incr eas es
the rank of a we b pag e? 1 po int
hnique is used in the PageRank algorithm to determine
7) Which tec
Depth-first search
Hyperlink analysis
• Random walk simulation
Data scraping
Yes, the answer is correct.
Score: 1
Accepted Answers:
Ran dom wal k sim ula tion
Yes, the answer is correct.
Score: 1
Accepted Answers:
Random walk simulation

8) PageRank relies heavily on the structure of the:

Web page content


• Hyperlink network between web pages
User interaction data
Server location

Yes, the answer is correct.


Score: 1
Accepted Answers:
Hyper/ink network between web pages

9) PageRank was developed primarily to solve which problem?

Calculating the shortest path in a network


• Ranking the importance of web pages on the internet
Counting the total number ·of web pages
Reducing the size of search engine databases

Yes, the answer is correct.


Score: 1.
Accepted Answers:
Ranking the importance of web pages on the internet

10) For which values between 200 and 3000 does the Collatz Conjecture not converge to 1?

2498.0
1576.0
2789.0
• None of the given options
Yes, the answer is correct.
Score: 1
Accepted Answers:
None of the given options

You might also like