Do the question with only python
Write a program in which you need to
Create a class called ‘SHAPE’ (should be made an abstract class) having two instance variable Length (double), Height (double)
instance method Get Data () to get and assign the values (to length &Height) from the user
it also has a method Display Area () to compute and display the area of the geometrical object.
Inherit two specific classes ‘TRIANGLE’ and ‘RECTANGLE’ from the base class that utilize the base class method.
Using these three classes design a program that will accept dimension of a triangle/rectangle interactively and display the area.
Hint:
Area of Triangle=1/2(L*h)
Area of Rectangle=L*h
Create a Python script that will display the next 5 numbers in the sequence where each number is the sum of the previous two.
TEXT FILE
8 3
4 5
6 2
Output
8 3 11 14 25 39 64
4 5 9 14 23 37 50
6 2 8 10 18 28 46
Python Problem Solving
You're given a positive integer: Perform the sequence of operations as per below guidelines until the value reaches 1:
If N is even --> N / 2
If N is odd --> N * 3 + 1
Print the total number of steps it took to reach 1.
Input
The first line of input contains an integer.
Output
The output should be a single integer denoting the total number of steps.
Explanation
For Example, using N = 10 as the input, with 6 steps.
10 is even - 10/2 = 5
5 is odd - 5 * 3 + 1 = 16
16 is even - 16 / 2 = 8
8 is even - 8 /2 = 4
4 is even - 4/2 = 2
2 is even - 2/2 = 1 --> Reached 1.
So the output should be 6.
Sample Input1
10
Sample Output1
6
Sample Input2
345
Sample Output2
125
Python Program
Write a python program to print the following output.
Input
The first line contains a string S representing a unique id.
The second line contains an integer N representing group length.
Output
The output should be a single string representing the new unique id.
Sample Input1
2-4A0r7-4k
3
Sample Output1
24-A0R-74K
Python Program
Write a program to print the following, Given a word W and pattern P, you need to check whether the pattern matches the given word.The word will only contain letters(can be Uppercase and Lowercase). The pattern can contain letters, ? and *.
? : Can be matched with any single letter.
* : Can be matched with any sequence of letters (including an empty sequence).
If the pattern matches with the given word, print True else False.
Sample Input1
3
Hello *l?
Hell He?ll
Hell ?*
Sample Output1
True
False
True
Sample Input1
3
Hello Hell*
Hell He*ll
Hell hell*
Sample Output1
True
True
False
Write a program to print the following output.
Input
The first line contains a string.
The second line contains some space-separated strings.
Output
The output should be a single integer.
Explanation
scramble word = "tacren"
guessed words = ["trance", "recant"]
Since "trance" and "recant" both have length 6 then you score 54 pts each.
So the output is 108.
Sample Input1
rceast
cat create sat
Sample Output1
2
Sample Input2
tacren
trance recant
Sample Output2
108
Write a python program to print the following output.
Input
The first line of input contains a single line positive integer N.
The second line of input contains a space-separated integers denoting the cost of the item.
Output
The output is a single line integer.
Explanation
For example, Given N = 2 and cost = 10 200
Ram has to pay for both the items, he won't get anything for free.
So the output is 210.
Sample Input1
4
1 1 2 2
Sample Output1
4
Sample Input2
2
10 200
Sample Output2
210
Create a Python script that will display the next 5 numbers in the sequence where each number is the sum of the previous two.
This is my text file:
8 3
4 5
6 2
The sample output should be like this when I run the code:
8 3 11 14 25 39 64
4 5 9 14 23 37 50
6 2 8 10 18 28 46
I need the code to have the python script that will display the next 5 numbers from my text file stated above.
Python Program
Write a python program to print the following output.
Input
The first line contains a string S representing a unique id.
The second line contains an integer N representing group length.
Output
The output should be a single string representing the new unique id.
Sample Input1
2-4A0r7-4k
3
Sample Output1
24-A0R-74K
Python Program
Write a python program to print the following output.
Input
The first line contains a string S representing a unique id.
The second line contains an integer N representing group length.
Output
The output should be a single string representing the new unique id.
Sample Input1
2-4A0r7-4k
3
Sample Output1
24-A0R-74K