Weekends
Given two dates D1 and D2, write a program to count the number of Saturdays and Sundays from D1 to D2 (including D1 and D2).
The date in string format is like "8 Feb 2021".Input
The first line of input will contain date D1 in the string format.
The second line of input will contain date D2 in the string format.
Output
The output should be a single line containing two integers separated by space
Explanation
For example, if the given dates are "25 Jan 2021" and "14 Feb 2021", the Saturdays and Sundays dates from "25 Jan 2021" to "14 Feb 2021" are
"30 Jan 2021" is a Saturday
"31 Jan 2021" is a Sunday
"6 Feb 2021" is a Saturday
"7 Feb 2021" is a Sunday
"13 Feb 2021" is a Saturday
"14 Feb 2021" is a Sunday
output
Saturday: 3
Sunday: 3
Sample Input 1
25 Jan 2021
14 Feb 2021
Sample Output 1
Saturday: 3
Sunday: 3
Sample Input 2
25 May 2019
22 Dec 2021
Sample Output 2
Saturday: 135
Sunday: 135
Add two polynomials
Given two polynomials A and B, write a program that adds the given two polynomials A and B.
Input
The first line contains a single integer M.
Next M lines contain two integers Pi, Ci separated with space, where Pi denotes power and Ci denotes co-efficient of Pi for polynomial A.
After that next line contains a single integer N.
Next N lines contain two integers Pj, Cj separated with space, where Pj denotes power and Cj denotes co-efficient of Pj for polynomial B.
Output
Explanation
If M = 4 and for polynomial A
For power 0, co-efficient is 5
For power 1, co-efficient is 0
For power 2, co-efficient is 10
For power 3, co-efficient is 6.
If N = 3 and for polynomial B
For power 0, co-efficient is 1
For power 1, co-efficient is 2
For power 2, co-efficient is 4.
Then polynomial A represents "6x^3 + 10x^2 + 5", the polynomial B represents "4x^2 + 2x + 1" and the addition of A and B is "6x^3 + 14x^2 + 2x + 6"Find the perimeter of overlapping rectangles , given the top right and bottom left corners.
While executing the above code, when I am giving the input as ("correct","wrong"). I am getting the output as r. And the expected output is No overlapping.
Please suggest the changes.
Add two polynomials
Given two polynomials A and B, write a program that adds the given two polynomials A and B.
Sample Input
4
0 5
1 0
2 10
3 6
3
0 1
1 2
2 4
Sample Output
6x^3 + 14x^2 + 2x + 6
Sample input
4
0 5
1 0
2 10
3 6
4
0 -5
1 0
2 -10
3 -6
Sample Output
Sample Input
5
0 2
1 0
2 1
4 7
3 6
5
2 4
3 3
4 5
0 1
1 0
Sample Output
12x^4 + 9x^3 + 5x^2 + 3
Write a GUI to visualize electric field lines of point charges located in a plane.
After the Python code below has run, what happens if 'the_file' does not already exist?
try:
fin = open('the_file', 'r')
except:
fin = open('the_file', 'w')
fin.close()
Given a M x N matrix, write a program to print the matrix after ordering all the elements of the matrix in increasing order.
Given date-time D, write a program to print the time left for the next New Year.
Write a program that reads all the match outcomes and summarizes the information of all the matches.
Points are given to the teams based on the outcome of the match.
A win earns a team 3 points. A draw earns 1. A loss earns 0.
The following information is expected:
MP: Matches Played
W: Matches Won
D: Matches Drawn (Tied)
L: Matches Lost
P: Points
see sample output for better understanding.
The team information should be displayed in descending order of points.Input.
100 >= N >= 0 HINT:you can maintain all match outcomes in dictionaries.
Sample Input
6
CSK;RR;loss
RR;DD;draw
MI;KKR;win
KKR;RR;loss
CSK;DD;draw
MI;DD;draw
Sample Output
Team: RR, Matches Played: 3, Won: 2, Lost: 0, Draw: 1, Points: 7
Team: MI, Matches Played: 2, Won: 1, Lost: 0, Draw: 1, Points: 4
Team: DD, Matches Played: 3, Won: 0, Lost: 0, Draw: 3, Points: 3
Team: CSK, Matches Played: 2, Won: 0, Lost: 1, Draw: 1, Points: 1
Team: KKR, Matches Played: 2, Won: 0, Lost: 2, Draw: 0, Points: 0