•Create a class named Shape with a function that prints "This is a shape". Create another class named Polygon inheriting the Shape class with the same function that prints "Polygon is a shape". Create two other classes named Rectangle and Triangle having the same function and inherited from polygon class, which prints "Rectangle is a polygon" and "Triangle is a polygon" respectively. Again, make another class named Square inherited from rectangle having the same function which prints "Square is a rectangle".
Now, try calling the function by the object of each of these classes.
•Create two classes named Mammals and MarineAnimals. Create another class named BlueWhale which inherits both the above classes. Now, create a function in each of these classes which prints "I am mammal", "I am a marine animal" and "I belong to both the categories: Mammals as well as Marine Animals" respectively. Now, create an object for each of the above class and try calling
1 - function of Mammals by the object of Mammal
2 - function of MarineAnimal by the object of MarineAnimal
3 - function of BlueWhale by the object of BlueWhale
4 - function of each of its parent by the object of BlueWhale
Create a binary file with roll no name and marks. Input a roll no and update the mark
by CodeChum Admin
Did you know that you can also reverse lists and group them according to your liking with proper code? Let's try it to believe it.
Instructions:
Create a variable that accepts a positive odd integer.
Create an empty list. Then, using loops, add random integer values into the list one by one. The number of values to be stored is dependent on the inputted odd integer on the first instruction.
Reverse the order of the list. Then, print out the list's new order in this manner:
[first-half values]-[middle value]-[second-half values], just like that of the sample output. Make use of list slicing that you’ve learned from the past lessons to easily achieve this segment.
Input
The first line contains an odd positive integer.
The next lines contains an integer.
7
1
2
3
4
5
6
7
Output
A line containing a list.
[7,6,5]-[4]-[3,2,1]
Did you know that you can also reverse lists and group them according to your liking with proper code? Let's try it to believe it.
Instructions:
Create a variable that accepts a positive odd integer.
Create an empty list. Then, using loops, add random integer values into the list one by one. The number of values to be stored is dependent on the inputted odd integer on the first instruction.
Reverse the order of the list. Then, print out the list's new order in this manner:
[first-half values]-[middle value]-[second-half values], just like that of the sample output. Make use of list slicing that you’ve learned from the past lessons to easily achieve this segment.
Input
The first line contains an odd positive integer.
The next lines contains an integer.
7
1
2
3
4
5
6
7
Output
A line containing a list.
[7,6,5]-[4]-[3,2,1]
IPL Match Details
Write a program that reads all the match outcomes and summarizes the information of all the matches.
Points are given to the terms 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
The team information should be displayed in descending order of points.
Sample input 1
6
CSK;RR;loss
RR;DD;draw
MI;KKR;win
KKR;RR;loss
CSK;DD;draw
MI;DD; draw
Sample output 1
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
IPL Match Details
Write a program that reads all the match outcomes and summarizes the information of all the matches.
Points are given to the terms 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
The team information should be displayed in descending order of points.
Sample input 1
6
CSK;RR;loss
RR;DD;draw
MI;KKR;win
KKR;RR;loss
CSK;DD;draw
MI;DD; draw
Sample output 1
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
IPL Match Details
Write a program that reads all the match outcomes and summarizes the information of all the matches.
Points are given to the terms 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
The team information should be displayed in descending order of points.
Sample input 1
6
CSK;RR;loss
RR;DD;draw
MI;KKR;win
KKR;RR;loss
CSK;DD;draw
MI;DD; draw
Sample output 1
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
pythagoras triplets
a pythagoras triplet is a set of three integers a,b,and c such that a2 + b2 = c2 in the given limit L ,find the number of pythagoras triplets R that can be formed (such that a<b<c)
for L = 20 pythagoras triplets satisfying the condition a<b<c
(3,4,5),(6,8,10),(5,12,13),(9,12,15),(8,15,17),(12,16,20).
hence output is 6
1) input is 5
output is 1
2) input is 20
output is 6
Don't you find it amazing to discover words and sentences that have the same first and last letter? We just don't usually notice them, so we can try it out by coding out this problem instead! Print out "Yes" if the first and last characters of the given string are the same, and "No" otherwise. It doesn't matter if they're in lowercase or uppercase, as long as it's the same letter, it fits the description.
So, what are you waiting for? Code now!
Input
A line containing a string.
Pop·it·up
Output
A line containing a string.
Yes