Questions: 5 831

Answers by our Experts: 5 728

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

Given two polynomials A and B, write a program that adds the given two polynomials A and B.

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.

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.


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"

sampel input 1

4

0 5

1 0

2 10

3 6

3

0 1

1 2

2 4

output

6x^3 + 14x^2 + 2x + 6

samplel input 2

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



Please help me rearrange this code again and please correct it. I can't run it. Thank you!

n = int(input())


for i in range(n):

  1st = list(map(int,input().split()))

  lst1 = lst[1:]


  elem = lst1[0]

  counter = 1


for j in range (1,len(lst1)):


  if 2*elem > lst1[j]:

    counter = 0

    break

  elem = lst1[j]


  if counter == 1:

    print("Denominations: " lst1)

    print("Good coin denominations !")

    else:

      print("Denominations: " lst1)

      print("Bad coin denominations !")



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 characters. You can ignore replacing all characters that are not letters.


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

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

secret Message

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'. You need to mirror both uppercase and lowercase characters. You can ignore mirroring for all characters that are not letters.

abcdefghijklmzyxwvutsrqpon nopqrstuvwxyzmlkjihgfedcbaInput

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


Given two polynomials A and B, write a program that adds the given two polynomials A and B.

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.

sampel input 1

4

0 5

1 0

2 10

3 6

3

0 1

1 2

2 4

output

6x^3 + 14x^2 + 2x + 6

samplel input 2

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



Non-Adjacent Combinations of Two Words

Given a sentence as input, find all the unique combinations of two words and print the word combinations that are not adjacent in the original sentence in lexicographical order.

Input


The input will be a single line containing a sentence.

Output


The output should be multiple lines, each line containing a valid unique combination of two words. The words in each line should be lexicographical order and the lines as well should be in lexicographical order. A valid combination will not contain the words that appear adjacent in the given sentence. Print "No Combinations" if there are no valid combinations.

Explanation

Sample Input 1

raju always plays cricket

Sample Output 1

always cricket

cricket raju

plays raju

Sample Input 2

python is a programming language

Sample Output 2

a language

a python

is language

is programming

language python

programming python

Sample Input 3

to be or not to be

Sample Output 3

be be

be not

or to

to to


3.Write an Employee class that keeps data attributes for the following pieces of information:

a. Employee name

b. Employee number Next, write a class named ProductionWorker that is a subclass of the Employee class. The ProductionWorker class should keep data attributes for the following information:

c. Shift number (an integer, such as1 for morning shift, 2 for evening shift)

d. Hourly pay rate Write the appropriate accessor and mutator methods for each class.


2. Write a class named Pet, which should have the following data attributes:

a) __name (for the name of a pet) __animal_type (for the type of animal that a pet is. Example values are ‘Dog’, ‘Cat’, and ‘Bird’) __age (for the pet’s age)

The Pet class should have an __init__ method that creates these attributes. It should also have the following methods:

b) set_name: This method assigns a value to the __name field. set_animal_type: This method assigns a value to the __animal_type field. set_age: This method assigns a value to the __age field. get_name: This method returns the value of the __name field. get_animal_type: This method returns the value of the __animal_type field. get_age: This method returns the value of the __age field.


1.Write a class named Car that has the following data attributes:

a) __year_model (for the car’s year model) __make (for the make of the car) __speed (for the car’s current speed)

The Car class should have an __init__ method that accepts the car’s year model and make as arguments. These values should be assigned to the object’s __year_model and __make data attributes. It should also assign 0 to the __speed data attribute.

The class should also have the following methods:

b)Accelerate: The accelerate method should add 5 to the speed data attribute each time it is called. Brake: The brake method should subtract 5 from the speed data attribute each time it is called. get_speed: The get_speed method should return the current speed


1. Design a recursive function that accepts an integer argument, n, and prints every second number from n down to a minimum of 0. Assume that n is always a positive integer.


LATEST TUTORIALS
APPROVED BY CLIENTS