The Joy Of Computing Using Python Week 11 : Assignment 11 | NPTEL | Answers Jan 2023

The Joy of Computing using Python Week 11 - Assignment 11 | NPTEL | Answer with Explanation

The Joy Of Computing Using Python Week 11  : Assignment 11  | NPTEL | Answers Jan 2023
"Discover the Excitement of Computing with Python | Week 11 Multiple Choice Questions - Get ready to enhance your programming skills and deepen your understanding of the Python language with this week 11 MCQ on 'The Joy of Computing using Python'. Test your knowledge and boost your confidence as a Python programmer today!"

Which statement will return the calendar for a whole year?

a. calendar.month(year)
b. calendar(year)
c. calendar.prcal(year)
d. calendar.year(year)
Answer

c. calendar.prcal(year)

The calendar.prcal(year) method in the calendar module will print the calendar for the specified year, including all 12 months, with each month's dates and days of the week aligned in a grid.

By which statement can we come out of the loop?

a. continue
b. leave
c. catch
d. break
Answer

d. break

"break" is a keyword in most programming languages that is used to exit out of a loop immediately. When "break" statement is executed inside a loop, the loop will terminate and the program will continue executing from the next statement after the loop.

Option a, "continue", is used to skip the current iteration of a loop and continue with the next iteration. It does not terminate the loop.

Option b, "leave", is not a valid keyword in most programming languages and is not used to exit out of a loop.

Option c, "catch", is used in exception handling to catch and handle exceptions, but it is not used to exit out of a loop.

What time.time() will return?

a. Time in seconds.
b. Current date and time.
c. Time in minutes
d. The current date, time and year.
Answer

a. Time in seconds.

time.time() returns the time in seconds since the epoch as a floating point number. So the correct answer is Time in seconds.

Which library used to get all timezones?

a. Selenium
b. Calender
c. nltk
d. pytz
Answer

d. pytz
The library used to get all time zones is pytz. It provides the timezone class that allows you to create time zones and perform conversions between them. To get a list of all available time zones, you can use the all_timezones attribute of the pytz module, like so:
import pytz
all_timezones = pytz.all_timezones
print(all_timezones)

This will print a list of all available time zones.

What is the output of the following code:

import pytz
from datetime import datetime as dt

zone = pytz.all_timezones

for i in range(len(zone)):
   print(dt.now(pytz.timezone(zone[i])))
a. Print the current date and time of all time zones.

b. Print the current date and time of specific time zones.

c. Print the current date of all time zones.

d. Print the current date of some specific time zones. 
Answer

a. Print the current date and time of all time zones.

This code uses the pytz library in Python to print the current time in all available time zones. The code first imports the pytz module and the datetime module from the standard library, renaming datetime to dt for brevity.

The code creates a variable called "zone" which is assigned to the result of calling the pytz.all_timezones method. This method returns a list of all available time zones in the pytz database.

The code then iterates over the length of the "zone" list using a for loop. For each index i in the range of the list length, the code retrieves the timezone at that index using zone[i], and passes it as an argument to the dt.now() method with pytz.timezone() method, which returns the current datetime for that timezone.

Finally, the code prints each datetime object using the print() function, resulting in a printout of the current time in all available time zones.

In the page rank algorithm,

a. We randomly travel from node to node without any relationship.
b. We randomly travel from node to neighbor node.
c. The maximum visited node will be the leader.
d. 2 and 3
e. 1 and 3
Answer

d. 2 and 3

If we perform the page rank algorithm on the web as a graph, which of the following is true?

a. Websites are nodes, and hyperlinks in websites are edges.
b. Hyperlinks in websites are nodes, and websites are edges.
c. Websites will work as nodes and edges.
d. Hyperlinks will work as nodes and edges.
Answer

a. Websites are nodes, and hyperlinks in websites are edges.

n the PageRank algorithm, a web page is represented as a node, and hyperlinks between web pages are represented as directed edges. The algorithm determines the importance of each web page based on the number and quality of the incoming links to that page. Therefore, option a is the correct statement.

In the page rank algorithm, the leader is decided by?

a. A node(person) with a maximum number of outgoing edges.
b. A node(person) with a maximum number of incoming edges.
c. A node(person) that is visited maximum times.
d. Can not decide.
Answer

c. A node(person) that is visited maximum times.

Which statement is correct about the following program?

import random
import matplotlib.pyplot as plt

l=[]
count = 0

for i in range(10):
  guess = random.randint(1, 10)
  pick = random.randint(1, 10)

  if(guess!=pick):
    count+=1
    l.append(count)
  else:
    count-=1
    l.append (count)

plt.plot(l)
plt.show()
a. The graph will go up when guess and pick are the same.
b. The graph will go down when guess and pick are the same.
c. The graph will go up when guess and pick are not the same.
d. Both B and C
Answer

d. Both B and C

Which of the following is not used as conditional statement in Python?

a. switch
b. if...else
c. elif
d. None of the mentioned above
Answer

a. switch

Python doesn't have a switch statement like some other programming languages (such as Java or C++), but instead uses if...elif...else statements to handle multiple conditions. So, the correct answer is a. switch.

Disclaimer:
"This page contains multiple choice questions (MCQs) related to The Joy of Computing using Python . The answers to these questions are provided for educational and informational purposes only.These answers are provided only for the purpose to help students to take references. This website does not claim any surety of 100% correct answers. So, this website urges you to complete your assignment yourself."

The Joy of Computing using Python Week 11,NPTEL ,Assignment 11 [Jan 2023],noc23_cs20

The Joy of Computing using Python - Course | NPTEL - All assignment

Post a Comment

0 Comments