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

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.

I am not getting correct answer for this i have tried lot but coming please help me


1. Consider the loop from Section 8.3 of your textbook.


prefixes = 'JKLMNOPQ'

suffix = 'ack'

for letter in prefixes:

   print(letter + suffix)

Put this code into a Python script and run it. Notice that it prints the names "Oack" and "Qack".

Modify the program so that it prints "Ouack" and "Quack" but leaves the other names the same.

Include the modified Python code and the output in your submission.

2. Give at least three examples that show different features of string slices. Describe the feature illustrated by each example. Invent your own examples. Do not copy them for the textbook or any other source.



Armstrong numbers between two intervals


Write a program to print all the Armstrong numbers in the given range A to B(including A and B). An N-digit number is an Armstrong number if the number equals the sum of the Nth power of its digit.


Input

The first line has an integer A.

The second line has an integer B.


Output

Print all Armstrong numbers separated by a space.

If there are no Armstrong numbers in the given range,print -1.


Sample Input 1

1

3

Sample Input 1

1 2 3


Sample Input 2

10

15

Sample Input 2

-1


call this function

def test_sqrt():

a = 1

while a < 26:

print('a =', a,'| my_sqrt(a) =',my_sqrt(a),'| math.sqrt(a) =', math.sqrt(a),'| diff =', abs(math.sqrt(a)-my_sqrt(a)))

a = a + 1

return 0


Given a set of text files containing synonyms for different words, complete the main program to output the synonyms for a specific word. Each text file contains synonyms for the word specified in the file’s name, and each row within the file lists the word’s synonyms that begin with the same letter, separated by a space. The program reads a word and a letter from the user and opens the text file associated with the input word. The program then stores the contents of the text file into a dictionary predefined in the program. Finally the program searches the dictionary and outputs all the synonyms that begin with the input letter, one synonym per line, or a message if no synonyms that begin with the input letter are found.


Hints: Use the first letter of a synonym as the key when storing the synonym into the dictionary. Assume all letters are in lowercase.






Student ID Map


you are given a sequence of student names Ni and their ids Di(corresponding to the student at the same index in Ni).


Write a program to print the student name and his ID from Ni and Di in alphabetical order of the name.


Explanation


For Example, if the given student names sequence and IDs sequenceare the following.


Anand,Ramesh,Kiran

ID102, ID101, ID100


Grouping of Scores


A player has collected few colored balls which have a number on them.

To calculate score, we have to group the colored balls picked by user and sum up the numbers on them.


write a program to create a dictionary, grouping of colored balls and the corresponding total score.


Write a function named test_sqrt that prints a table like the following using a while loop, where "diff" is the absolute value of the difference between my_sqrt(a) and math.sqrt(a). 

a = 1 | my_sqrt(a) = 1 | math.sqrt(a) = 1.0 | diff = 0.0

a = 2 | my_sqrt(a) = 1.41421356237 | math.sqrt(a) = 1.41421356237 | diff = 2.22044604925e-16

a = 3 | my_sqrt(a) = 1.73205080757 | math.sqrt(a) = 1.73205080757 | diff = 0.0

a = 4 | my_sqrt(a) = 2.0 | math.sqrt(a) = 2.0 | diff = 0.0

a = 5 | my_sqrt(a) = 2.2360679775 | math.sqrt(a) = 2.2360679775 | diff = 0.0

a = 6 | my_sqrt(a) = 2.44948974278 | math.sqrt(a) = 2.44948974278 | diff = 0.0

a = 7 | my_sqrt(a) = 2.64575131106 | math.sqrt(a) = 2.64575131106 | diff = 0.0

a = 8 | my_sqrt(a) = 2.82842712475 | math.sqrt(a) = 2.82842712475 | diff = 4.4408920985e-16

a = 9 | my_sqrt(a) = 3.0 | math.sqrt(a) = 3.0 | diff = 0.0 

Modify your program so that it outputs lines for a values from 1 to 25 instead of just 1 to 9. 


You should submit a script file and a plain text output file (.txt) that contains the test output. Multiple file uploads are permitted.

Your submission will be assessed using the following Aspects.

Does the submission include a my_sqrt function that takes a single argument and includes the while loop from the instructions?
Does the my_sqrt function initialize x and return its final value?
Does the test_sqrt function print a values from 1 to 25?
Does the test_sqrt function print the values returned by my_sqrt for each value of a?
Does the test_sqrt function print correct values from math.sqrt for each value of a?
Does the test_sqrt function print the absolute value of the differences between my_sqrt and math.sqrt for each value of a?
Does the my_sqrt function compute values that are almost identical to math.sqrt ("diff" less than 1e-14)?
Part 2

Write a function named test_sqrt that prints a table like the following using a while loop, where "diff" is the absolute value of the difference between my_sqrt(a) and math.sqrt(a).

a = 1 | my_sqrt(a) = 1 | math.sqrt(a) = 1.0 | diff = 0.0
a = 2 | my_sqrt(a) = 1.41421356237 | math.sqrt(a) = 1.41421356237 | diff = 2.22044604925e-16
a = 3 | my_sqrt(a) = 1.73205080757 | math.sqrt(a) = 1.73205080757 | diff = 0.0
a = 4 | my_sqrt(a) = 2.0 | math.sqrt(a) = 2.0 | diff = 0.0
a = 5 | my_sqrt(a) = 2.2360679775 | math.sqrt(a) = 2.2360679775 | diff = 0.0
a = 6 | my_sqrt(a) = 2.44948974278 | math.sqrt(a) = 2.44948974278 | diff = 0.0
a = 7 | my_sqrt(a) = 2.64575131106 | math.sqrt(a) = 2.64575131106 | diff = 0.0
a = 8 | my_sqrt(a) = 2.82842712475 | math.sqrt(a) = 2.82842712475 | diff = 4.4408920985e-16
a = 9 | my_sqrt(a) = 3.0 | math.sqrt(a) = 3.0 | diff = 0.0

Modify your program so that it outputs lines for a values from 1 to 25 instead of just 1 to 9.
LATEST TUTORIALS
APPROVED BY CLIENTS