The Joy of Computing using Python | Week 11

Session: JULY-DEC 2023

Course Name:  The Joy of Computing using Python

Course Link: Click Here

These are answers of The Joy of Computing using Python Assignment 11 Answers


Q1. Which library is used for browser automation?
nltk
numpy
selenium
PIL

Answer: selenium


Q2. What the given statement will return?
time.time()

Time in seconds.
Current date and time.
Time in minutes
The current date, time and year

Answer: Time in seconds.


Q3. Identify the library that can be used to get all timezones:
selenium
calender
nltk
pytz

Answer: pytz


These are answers of The Joy of Computing using Python Assignment 11 Answers


Q4. The output of the following code will be?
Date and time in dd- mm-yy hh:MM:ss:ms respectively.
Time and date in hh:MM:ss:ms dd- mm-yy respectively.
Date and time in mm-dd-yy hh:MM:ss:ms respectively.
Date and time in yy- mm-dd hh:MM:ss:ms respectively.

Answer: Date and time in yy- mm-dd hh:MM:ss:ms respectively.


Q5. We can use the selenium web driver for different browsers.
True
False

Answer: True


Q6. What will be the output of the following code?
Print the current date and time of all time zones.
Print the current date and time of specific time zones.
Print the current date of all time zones.
Print the current date of some specific time zones.

Answer: Print the current date and time of all time zones.


These are answers of The Joy of Computing using Python Assignment 11 Answers


Q7. What will be the output if the system date is 10 December 2021(Friday)?
5
3
4
error

Answer: 4


Q8. Which statement will return the calendar for a whole year?
calendar.month(year)
calendar(year)
calendar.prcal(year)
calendar.year(year)

Answer: calendar.prcal(year)


These are answers of The Joy of Computing using Python Assignment 11 Answers


Q9. By which statement can we come out of the loop?
continue
leave
catch
break

Answer: break


These are answers of The Joy of Computing using Python Assignment 11 Answers


Q10. How to check for the leap year?
calendar.leap(year)
calendar.is_leap(year)
calendar.isleap(year)
calendar.checkleap(year)

Answer: calendar.isleap(year)


These are answers of The Joy of Computing using Python Assignment 11 Answers


The Joy of Computing using Python Programming Assignmnet

Question 1
Take 3 sides of a triangle as an input and find whether that triangle is a right angled triangle or not. Print ‘YES’ if a triangle is right angled triangle or ‘NO’ if it’s not.
Input:
3
4
5
Output
YES

Solution:

a1=int(input())
b3=int(input())
c=int(input())
L=[a1,b3,c]
h=max(L)
L.remove(h)
if h**2==L[0]**2+L[1]**2:
  print("YES",end="")
else:
  print("NO",end="")

These are answers of The Joy of Computing using Python Assignment 11 Answers


Question 2
Write a program that accepts a hash-separated sequence of words as input and prints the words in a hash-separated sequence after sorting them alphabetically in reverse order.
Input:
hey#input#bye
Output:
input#hey#bye

Solution:

LGF=sorted(input().split("#"),reverse=True)
print("#".join(LGF),end="")

These are answers of The Joy of Computing using Python Assignment 11 Answers


Question 3
Write a program which takes two integer a and b and prints all composite numbers between a and b.(both numbers are inclusive)
Input:
10
20
Output:
10
12
14
15
16
18
20

Solution:

prime_nb=[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 
       59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113,
       127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 
       191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251,
       257, 263, 269, 271, 277, 281, 283, 293]
a=int(input())
b=int(input())
for i in range(a,b+1):
    if i not in prime_nb:
      print(i)

These are answers of The Joy of Computing using Python Assignment 11 Answers

More Weeks of The Joy of Computing Using Python: Click here

More Nptel Courses: Click here


Session Jan-Apr 2023

Course Name:  The Joy of Computing using Python

Course Link: Click Here

These are answers of The Joy of Computing using Python Assignment 11 Answers


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


Q2. By which statement can we come out of the loop?
a. continue
b. leave
c. catch
d. break

Answer: d. break


These are answers of The Joy of Computing using Python Assignment 11 Answers


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


Q4. Which library used to get all timezones?
a. selenium
b. calender
c. nltk
d. pytz

Answer: d. pytz


These are answers of The Joy of Computing using Python Assignment 11 Answers


Q5. What is the output of the following code:

image 28

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.


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


These are answers of The Joy of Computing using Python Assignment 11 Answers


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


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


These are answers of The Joy of Computing using Python Assignment 11 Answers


Q9. Which statement is correct about the following program?

image 29

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


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


These are answers of The Joy of Computing using Python Assignment 11 Answers


The Joy of Computing using Python Programming Assignmnet

Question 1

Take 3 sides of a triangle as an input and find whether that triangle is a right angled triangle or not. Print ‘YES’ if a triangle is right angled triangle or ‘NO’ if it’s not.
Input:
3
4
5
Output
YES

Solution:

a=int(input())
b=int(input())
c=int(input())
L=[a,b,c]
h=max(L)
L.remove(h)
if h**2==L[0]**2+L[1]**2:
  print("YES",end="")
else:
  print("NO",end="")

These are answers of The Joy of Computing using Python Assignment 11 Answers


Question 2

Write a program that accepts a hash-separated sequence of words as input and prints the words in a hash-separated sequence after sorting them alphabetically in reverse order.
Input:
hey#input#bye
Output:
input#hey#bye

Solution:

L=sorted(input().split("#"), reverse=True)
print("#".join(L),end="")

These are answers of The Joy of Computing using Python Assignment 11 Answers


Question 3

Write a program which takes two integer a and b and prints all composite numbers between a and b.(both numbers are inclusive)
Input:
10
20
Output:
10
12
14
15
16
18
20

Solution:

prime=[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53,
       59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113,
       127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181,
       191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251,
       257, 263, 269, 271, 277, 281, 283, 293]
a=int(input())
b=int(input())
for i in range(a,b+1):
    if i not in prime:
      print(i)

These are answers of The Joy of Computing using Python Assignment 11 Answers

More Weeks of The Joy of Computing using Python: Click Here

More Nptel courses: http://13.235.254.184/nptel/


These are answers of The Joy of Computing using Python Assignment 11 Answers