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

polinom = {}

for i in range(2):

n = int(input())

for item in range(n):

p, c = input().split(' ')

p, c = int(p), int(c)

if p in polinom:

polinom[p] += c

else:

polinom[p] = c

res = ''

if len(polinom) == 0:

pass

else:

flag = True

for p in polinom:

if polinom[p] == 0:

continue

if polinom[p] < 0:

if flag:

res += '-'

else:

res += ' - '

else:

if not flag:

res += ' + '

flag = False

if (abs(polinom[p]) == 1) and p == 0:

res += '1'

continue

if abs(polinom[p]) != 1:

res += str(abs(polinom[p]))

if p < 0:

res += 'x^({})'.format(p)

elif p == 1:

res += 'x'

elif p > 0:

res += 'x^{}'.format(p)

if len(res) == 0:

print('0')

else:

print(res)

Output:6 + 2x + 14x^2 + 6x^3
Expected output:6x^3 + 14x^2 + 2x + 6

n = int(input())

polinom_a =[0 for item in range(n)]                      

for item in range(n):

  p, c = input().split(' ')

  polinom_a[int(p)] = int(c)

m = int(input())

polinom_b =[0 for item in range(m)]

for item in range(m):

  p, c = input().split(' ')

  polinom_b[int(p)] = int(c)

pol_max , pol_min = polinom_a , polinom_b

if len(pol_min) > len(pol_max):

  pol_max , pol_min = polinom_b , polinom_a 

for item in range(len(pol_min)):

  pol_max[item] += pol_min[item]

for item in range(len(pol_max)-1,0,-1):

  if item == 0:

    continue

  print (f'{pol_max[item]}x^{item} + ',end='')

print(pol_max[0])

ouput:6x^3 + 14x^2 + 2x^1 + 6
the ouput should be like this:6x^3 + 14x^2 + 2x + 6 
after adding two polynomials when we get "0" as output and it should print output as:"0"

so,please can anyone make correct code?


All Possible Subsets

Given a sentence as input, print all the unique combinations of the words of the sentence, considering different possible number of words each time (from one word to N unique words in lexicographical order).Input


The input will be a single line containing a sentence.Output


The output should be multiple lines, each line containing the unique combination from one word to N words in lexicographical order.Explanation


For example, if the given sentence is "apple is a fruit".

All possible one-word unique combinations are

a
apple
fruit
is


All possible two words unique combinations are

a apple
a fruit
a is
apple fruit
apple is
fruit is


All possible three words unique combinations are

a apple fruit
a apple is
a fruit is
apple fruit is


All possible four words unique combinations are

a apple fruit is

You are designing a quiz game to help elementry school students with fraction calculations

Your games should have a set of 25 addition, subtraction, multiplication, division questions located in a file. Each question should be formatted to look like:

  • 3/4+4/5
  • 5/8*9/4

The questions should be displayed to the player 1 question at a time and reward the player points for gettting the answer to that question correct.

  • Question was correct the first time (4 Points in Lowest Terms, 3 Points not in lowest terms)
  • Question was incorrect the first time but correct on second guess (2 Points in Lowest Terms, 1 Point not in lowest terms)
  • Question incorrect after second guess (0 Points)

Your program should always display the correct answer in lowest terms if the player didn't answer in lowest terms correctly

Your program should append the players name and score to a file when complete.

You must design and code a Fraction Object to complete this program

compute average numbers from 1 to n where n is a positiove integer value and assign it to the variable avg in python


inputString =input("");

sumDigits =0

numberDigits=0

# Looping through a string.

for character in inputString:

  if (character.isdigit()):

    # Calculate the sum of the digits of all numbers that appear in the string

    sumDigits+=int(character)

    numberDigits+=1

# Calculate the average of the digits of all numbers that appear in the string

average=sumDigits/numberDigits

# Print the sum of all digits(8) 

print(str(sumDigits))

# Print the average of all digits(2.0) in the new line.

print("%.1f" % average)

input:

Anjali25 is python4 Expert

ouput:
11
3.7
the output should be like this:
11
3.67

M, N = input().split(' ')

M, N = int(M), int(N)

matrix = []

for i in range(M):

row = [int(j) for j in input().split(' ')]

matrix.append(row)

values = [j for row in matrix for j in row]

values.sort()

output = matrix

for i in range(M):

for j in range(N):

output[i][j] = values[i * M + j]

for row in output:

print(*row)

input:

2 5

-50 20 3 25 -20

88 17 38 72 -10

output:-
50 -20 -10 3 17
-10 3 17 20 25
the output should be like this:-
50 -20 -10 3 17 
20 25 38 72 88


so can anyone please give correct code?


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




If the add polynomials is euqal to zero it should print output:"0"


MODULE 10:

Go ahead and try to write the code in this module. If you accomplished it and run without an issue, add

another feature of our calculator. Try to add the following: 

  • MODULUS DIVISION

SAMPLE OUTPUT:

what's the first number?:15

+

-

*

/

%

e

pick an operation:%

what's the number?: 4

15.0% 4.0=3.0

type 'y' to continue calculating with 3.0, or type 'n' to start a new calculation:


  • EXPONENT

SAMPLE OUTPUT:

what's the first number?:5

+

-

*

/

%

e

pick an operation:e

what's the number?: 3

5.0% 3.0= 125.0

type 'y' to continue calculating with 125.0, or type 'n' to start a new calculation:




You are making a 4 player dice game. Each of the four players starts the game by rolling one 5 sided dice and one 8 sided dice. The total is recorded.

  • If the player rolls an even number, they become an "EVEN" player.
  • If they roll an odd, then the player becomes an "ODD" player


  • If the Player is an "EVEN" Player, then he wins the total if that total is a 3 or 9 or 11
  • If the Player is an "ODD" Player, then he wins the total if that total is a 5 or 7 or 12



Player Object

Attributes:

  • The name
  • The total points
  • The type of the player "EVEN" or "ODD"

Constructor:

  • Accept name of the player as the parameter
  • Set the points accumulated to 0

Behaviours:

  • Set Type Function:
  • Accept a string either "EVEN" or "ODD"
  • Set the player type attribute


  • Roll Function:
  • Accept two dice objects as parameters
  • Return the sum of two dice rolls


  • Set Points Function:
  • Accept a value representing the sum of two dice
  • Return the number of points the player should earn based on that sum
LATEST TUTORIALS
APPROVED BY CLIENTS