s

The Joy of Computing using Python | Week 11 NPTEL Assignment Answers 2024

 
The Joy of Computing using Python | Week 11 NPTEL Assignment Answers 2024


These are the Joy of Computing using Python Assignment 11 Answers

Q1. Select the correct statement regarding selenium library

Selenium is primarily used for web browser automation

The web driver in selenium allows a way to interact with web browsers

The Keys Class provides a set of special keys that can be used for keyboard interaction

All of the above

Answer: All of the above


Q2. Which of the following tasks in WhatsApp can be automated using selenium?

Sending Media Files

Reading Messages

Creating and Managing Groups

Updating Profile Information


Answer: a), b), c), d)


For answers or latest updates join our telegram channel: Click here to join


These are the Joy of Computing using Python Assignment 11 Answers


Q3. Read the given code and identify the correct statement.

does_something returns a list of all time zones in Asia

the above code prints all time zones in Asia

The output of the code can change depending on the version of pytz used

All of the above


Answer: All of the above


Q4. Read the given code. What is the output of does_something(2022,2,29).(NAT)


Answer: 0


For answers or latest updates join our telegram channel: Click here to join


These are the Joy of Computing using Python Assignment 11 Answers


Q5. Read the given code.

Assume the file years.txt contains the following data.

What is the output of the code (NAT)


Answer: 2


Q6. Read the given code.

Enter the value of int(count_something(1996)==count_something(2024))


Answer: 1


For answers or latest updates join our telegram channel: Click here to join


These are the Joy of Computing using Python Assignment 11 Answers


Q7. Read the given code.

Enter the value returned by count_(1990,2024)


Answer: 9


Q8. In addition to the first birthday celebration, Koreans often celebrate “MiSeDol,” which marks the completion of the 100th day after a baby’s birth. This is considered another significant milestone. Given an input birthdate, the following code tries to calculate the date of “MiSeDol”, but the code might contain errors. Identify the line number corresponding to the error. In the absence of an error answer -1.


Answer: -1


For answers or latest updates join our telegram channel: Click here to join


These are the Joy of Computing using Python Assignment 11 Answers


Q9. Read the given code.

Find the value returned by finds_something (2000,12)


Answer: 5


Q10. Read the following code. What does count_something(2024,1) return ?


Answer: 23


For answers or latest updates join our telegram channel: Click here to join


These are the Joy of Computing using Python Assignment 11 Answers


The Joy of Computing using Python Programming Assignment

Question 1


Write the following functions:

(1) factors: accept a positive integer n as argument. Return the set of all factors of n.

(2) common_factors: accept two positive integers a and b as arguments. Return the set of common factors of the two numbers. This function must make use of factors.

(3) factors_upto: accept a positive integer n as argument. Return a dict D, whose keys are integers and values are sets. Each integer in the range [1,n], endpoints inclusive, is a key of D. The value corresponding to a key, is the set of all factors of key. This function must make use of factors.


The idea we are trying to bring out here is to make use of pre-defined functions whenever needed.


Solution:


def factors(n):

    factor_set = set()

    for ips in range(1, n + 1):

        if n % ips == 0:

            factor_set.add(ips)

    return factor_set



def common_factors(a, b):

    factors_a = factors(a)

    factors_b = factors(b)

    return factors_a.intersection(factors_b)


def factors_upto(n):

    factors_dict = {}

    for i in range(1, n + 1):

        factors_dict[i] = factors(i)

    return (factors_dict)

Next Post Previous Post
No Comment
Add Comment
comment url
×