Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can identify which of the structure is in the code, and explain why it is used so... thank you 1.) Sequential Structures 2.) Decision Structures

Can identify which of the structure is in the code, and explain why it is used so... thank you

1.) Sequential Structures

2.) Decision Structures

3.) Repetition Structures

4.) String Methods

5.) Text File Manipulation

6.) Lists and Dictionaries

7.) Functions

8.) Program Modularization

import numpy px_terms = int(input('Enter number of terms in px: ')) qx_terms = int(input('Enter number of terms in qx: ')) poly = {} for i in range(px_terms): ele = int(input('Enter coefficient {} for px: '.format(i + 1))) # if 'px' is not present already, add empty list with 'px' as key if 'px' not in poly: poly['px'] = [] # after adding empty list with 'px' as key, append input to the list # I added this line because it also add 1st coefficient to the list. poly['px'].append(ele) # else, append input to the list else: poly['px'].append(ele) for i in range(qx_terms): ele = int(input('enter coefficient {} for qx: '.format(i + 1))) # if 'qx' is not present already, add empty list with 'qx' as key if 'qx' not in poly: poly['qx'] = [] # after adding empty list with 'qx' as key, append input to the list. # I added this line because it also add 1st coefficient to the list. poly['qx'].append(ele) # else, append input to the list else: poly['qx'].append(ele) option = input('Select Addition, Subtraction, Multiplication, Division: ') if option.lower() == "addition": print(numpy.polynomial.polynomial.polyadd(poly['px'], poly['qx'])) if option.lower() == "subtraction": print(numpy.polynomial.polynomial.polysub(poly['px'], poly['qx'])) if option.lower() == "multiplication": total = 0 for i in range(px_terms): ans = poly['px'][i] * poly['qx'][i] print(f"answer{i+1} = ", ans) total += ans print(f"total = {total}") if option.lower() == "division": qu, re = numpy.polynomial.polynomial.polydiv(poly['px'], poly['qx']) print("Quotient: ", qu) print("Remainder: ", re)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

2. Discuss the steps in preparing a manager to go overseas.

Answered: 1 week ago

Question

8. Measure the effectiveness of the succession planning process.

Answered: 1 week ago