Python Answers

Questions answered by Experts: 5 288

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

You can use Cramer’s rule to solve the following 2 x 2 system of linear equations: Ax+By=E


Cx+Dy=f


X=ED-Bf/AD-Bc


Y= Af-Ec/AD-Bc



Write a program that prompts the user to enter A, B, C, D, E, and F nd display the


result. If AD – BC is 0, report that “The equation has no solution”.



Do all you can to make your program structure when running, conform with the sample runs


given below:



Enter a, b, c, d, e, f: 9.0, 4.0, 3.0, -5.0, -6.0, -21.0


x is -2.0 and y is 3.0



Enter a, b, c, d, e, f: 1.0, 2.0, 2.0, 4.0, 4.0, 5.0


The equation has no solution

(Geometry: area of a pentagon) Write a program that prompts the user to enter the

length from the center of a pentagon to a vertex and computes the area of the pen-

tagon, as shown in the following figure.

                               3V3

    The formula for computing the area of a pentagon is Area =

                               2

                                  where s is

    the length of a side. The side can be computed using the formula s = 2r sin

    where r is the length from the center of a pentagon to a vertex. Here is a sample

    run:

    Enter the length from the center to a vertex: 5.5

    The area of the pentagon is 108.61

                                JEnter


(Physics: find runway length) Given an airplane's acceleration a and take-of

speed v, you can compute the minimum runway length needed for an airplane to

take off using the following formula:

                 length

                      2a

  Write a program that prompts the user to enter v in meters/second (m/s) and the

acceleration a in meters/second squared (m/s), and displays the minimum runway

length. Here is a sample run:

Enter speed and acceleration: 60, 3.5 LEnter

The minimum runway length for this airplane is 514.286 meters


(Sum the digits in an integer) Write a program that reads an integer between 0 and

1000 and adds all the digits in the integer. For example, if an integer is 932, the

sum of all its digits is 14. (Hint: Use the % operator to extract digits, and use the //

operator to remove the extracted digit. For instance, 932 % 10 = 2 and 932 //

10 = 93.) Here is a sample run:

Enter a number between 0 and 1000: 999 Enter

The sum of the digits is 27


(Average speed) Assume a runner runs 14 kılometers in 45 minutes and 30 sec-

onds. Write a program that displays the average speed in miles per hour. (Note that

 1 mile is 1.6 kilometers.)


Create a program wherein any user should be able to search books by their title or its author.


Check the wrong of this code and show the exact code


dict1={}



class AddColumn:

def add_column(str1,list1):

dict1[str1].append(list1)

x=AddColumn()



x.add_column( "City name",["Adelaide", "Brisbane", "Darwin", "Hobart", "Sydney", "Melbourne", "Perth"])

x.add_column("Area", [1295,5905, 112, 1357, 2058, 1566, 5386])

x.add_column("Population", [1158259, 18557594, 120900, 205556, 4336374, 3306092, 1554769])

x.add_column("Annual Rainfall"[600.5, 1146.4, 1714.7, 619.5, 1214.8, 646.9,869.4])



print(dict1)




Check the Index Block on NO.25 and show the correct code

main_list = []

x = {}


field_names = [ "City name", "Area", "Population", "Annual Rainfall"]


list1 = [

["Adelaide", 1295, 1158259, 600.5],


["Brisbane", 5905, 1857594, 1146.4],


[ "Darwin", 112, 120900, 1714.7],


["Hobart", 135, 20556, 619.5],


["Sydney", 2058, 4336374, 1214.8],


["Melbourne", 1566, 3806092, 646.9],


["Perth", 5386, 1554769, 869.4]]



for i in range(0, len(list1)):

for key in field_names:

for value in list1[i]:

x[key] = value

list1[i].remove(value)

break


main_list.append(x)



print("Resultant Main list is : " + str(main_list))



Create a program to generate a text file to produce a quote for a customer wishing to purchase external hard drives from CGL Computer Products company. Create a dictionary of the following drives (item number is key and price is the value) bellow  

{335160:484.99,354732:221.44,3514676:257.42,3006905:315.55,3351600:447.50,357888:379.15}

 Open a new text file to create a quote for the customer. Ask the customer for the item number and quantity they wish to purchase. Search your dictionary to retrieve the price based on the item number. Allow the customer to purchase multiple items. Print a header for the quote, column headings, line items for the quantity and description of each item purchased and the total price. After all items have been listed, calculate shipping as 3% of the total, add the shipping to the total to display the total amount due. Tax calculation is not necessary. 


For this program I want an exact output as I given in the sample numbers position should not be changed.


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

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

matrix = []

for _ in range(M):

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

matrix.append(row)

K = int(input('Enter K: '))

values = matrix[0][:-1] + [x[-1] for x in matrix][:-1] + matrix[-1][::-1][:-1] + [x[0] for x in matrix][::-1][:-1]

values = values[-K:] + values[:-K]

output = matrix

idxs = [(0, j) for j in range(N)][:-1] + [(i, N - 1) for i in range(M)][:-1] + [(M - 1, j) for j in range(N)][::-1][:-1] + [(i, 0) for i in range(M)][::-1][:-1]

idx = 0

for i, j in idxs:

output[i][j] = values[idx]

idx += 1

for i in output:

for j in i:

print(j, end=' ')

print()


Sample Input 1

4 4

1 2 3 4

5 6 7 8

9 10 11 12

13 14 15 16

3

Sample Output 1

13 9 5 1

14 7 11 2

15 6 10 3

16 12 8 4

Sample Input 2

3 4

1 2 3 4

10 11 12 5

9 8 7 6

2

Sample Output 2

9 10 1 2

8 11 12 3

7 6 5 4


LATEST TUTORIALS
APPROVED BY CLIENTS