Secret Message - 2
Given a string, write a program to print a secret message that replaces characters with numbers 'a' with 1, 'b' with 2, ..., 'z' with 26 where characters are separated by '-'.
Note: You need to replace both uppercase and lowercase
a b c d e f g h i j
1 2 3 4 5 6 7 8 9 10
k l m n o p q r
11 12 13 14 15 16 17 18
s t u v w x y z
19 20 21 22 23 24 25 26
Input
The input will be a string in the single line containing spaces and letters (both uppercase and lowercase).
Output
The output should be a single line containing the secret message. All characters in the output should be in lower case.
For example, if the given input is "python", "p" should replaced with "16", similarly"y" with "25","t" with "20","h" with "8","o" with "15","n" with "14". So the output should be "16-25-20-8-15-14".
Sample Input 1
python
Sample Output 1
16-25-20-8-15-14
Sample Input 2
Foundations
Sample Output 2
6-15-21-14-4-1-20-9-15-14-19Secret Message - 1
Given a string, write a program to mirror the characters of the string in alphabetical order to create a secret message.
Note: Mirroring the characters in alphabetical order replacing the letters 'a' with 'z', 'b' with 'y', ... , 'z' with 'a'.
a b c d e f g h i j k l m
z y x w v u t s r q p o n
n o p q r s t u v w x y z
m l k j i h g f e d c b a
Input
The input will be a string in the single line containing spaces and letters (both uppercase and lowercase).
Output
The output should be a single line containing the secret message. All characters in the output should be in lower case.
Explanation
For example, if the given input is "python", "p" should replaced with "k", similarly "y" with "b", "t" with "g", "h" with "s", "o" with "l", "n" with "m". So the output should be "kbgslm".
Sample Input 1
python
Sample Output 1
kbgslm
Sample Input 2
Foundations
Sample Output 2
ulfmwzgrlmhAdd two polynomials
Given two polynomials A and B, write a program that adds the given two polynomials A and B
Output
Print the addition of polynomials A and B.
If the degree of polynomial is zero and the constant term is also zero, then just print 0 to represent the polynomial.
For term Cix^Pi, if the coefficient of the term Ci is 1, simply print x^Pi instead of 1x^Pi.Explanation
Hint:-
We can use dictionaries to maintain polynomial coeffients and powers.
Test Case 1:-
Input:-
6
0 -20
1 23
2 30
3 19
4 6
5 17
9
0 -100
5 -89
6 -20
7 -1
1 20
2 4
3 99
4 -45
8 12
Output:-
12x^8 - x^7 - 20x^6 - 72x^5 - 39x^4 + 118x^3 + 34x^2 + 43x - 120
Note :- Need Space between - and + operators
Test Case 2:-
Input:-
4
0 5
1 0
2 10
3 6
3
0 1
1 2
2 4
Output :-
6x^3 + 14x^2 + 2x + 6
Note:- Need Space between - and + operators
Test Case 3:-
Input:-
5
0 -2
3 6
4 7
1 -3
2 -1
5
0 1
1 2
2 -4
3 3
4 5
Output:-
12x^4 + 9x^3 - 5x^2 - x - 1
Note:- Need Space between - and + operators
We need all test cases can be came when code was run
Write a method/function SHOw_TODO0 in python to read contents from a text
file ABC.TXT and display those lines which have occurrence of the word "TO" or
DO"
For example IMPORTANT : If content TO of the NOTE file is THAT SUcCESS IS THE REsULT OF
HARD wORK. WE ATI. ARE EXPFcTED TO DO HARD WORK. AFTER
ALL EXPERIENCE cOMES FROM HARDwORK.
The method/funetiom should displays
THIS IS IMPORTANT TO NOTE THAT SUCCESS IS THE RESULT
OF HARD wORK.
WE ALL ARE EXPECTED to do hard work
Given a parent class "Standard Calculator" consisting of one child class "Scientific Calculator".
Create the required parent class and child class using(Object-oriented programming concept) means to use the python class object to create this relationship.
The standard calculator(parent) can perform two types of operations: an addition and a subtraction
The standard calculator(child)is capable of inputting only two integers. But the scientific calculators(child) can also interpret decimal values.
The scientific calculator(child) is capable of four operations: addition, subtraction, cosine and sine of values.
Replace Elements with Zeros
Given a MxN matrix, write a program to replace all elements that do not belong to principal-diagonal & anti-diagonal with Zeros.
Principal-diagonal elements are the set of elements of a matrix that lie on the line joining the top left corner to the bottom right corner.
Anti-diagonal elements are the set of elements of a matrix that lie on the line joining the bottom left corner to the top right corner.Input
The first line of input will contain two space-separated integers, denoting MxN matrix.
The next M lines will contain N space-separated integers.Output
The output should be MxN matrix by replacing elements that do not belong to principal-diagonal and anti-diagonal with Zeros. Print each row as a space separated integers in a single line.Explanation
For example if the M and N are 5 and 5. Read the elements of 5 rows in next 5 lines. If the given elements are
Write a Python program using text files to create a Smart Phone book that collects contact details from the user. Contact details refer to the contact’s full name (first name and last name), phone number, date of birth and a category that the contact belongs to (Friends, Family, Work, Other). The Phone Book will display the following Menu and will support the corresponding functionality:
Enter your choice: 1: Add a new contact 2: Remove an existing contact 3: Look up a contact 4: Update a contact phone number 5: Display all contacts 6: Delete all contacts 7: Exit phonebook
n = input().split()
d=[]
z = []
for i in n:
if (i.isdigit()):
if (int(i) > 0):
print(i)
z = z + [i]
c = n.index(i)
d.append(c)
d.sort(reverse = True)
for i in range(len(d)):
n[d[i]] = z[i];
m = ""
for i in n:
m = m + i + " "
print(m)what is wrong in this code, please explain it. sir
Section 6.9 of your textbook ("Debugging") lists three possibilities to consider if a function is not working.
What is the definition of precondition and post condition statement