How JustAnswer Works:

  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.

Ask R.R. Jha Your Own Question

R.R. Jha
R.R. Jha, Tutor
Category: Homework
Satisfied Customers: 5471
Experience:  B.Tech
Type Your Homework Question Here...
R.R. Jha is online now
A new question is answered every 9 seconds

Help my homework please!!!Im using Python 2.7.3Write

This answer was rated:

Help my homework please!!! I'm using Python 2.7.3 Write a program to solve Ax^2 + Bx + C = 0 where A, B, and C can be any real number and x can be complex (x = a + bi). Note: A, B, and/or C can be zero so you must consider ALL possibilities for the coefficients. General Instructions: In all that follows replace 999 with your assigned classid and $ represents the Unix command prompt. create a directory named mp1id999 and cd into it and create four files:,, abc.txt (to test your program), and README. Your program will consist of two modules (i.e. two .py files). - The module will contain the main() function for your program and possibly a few helper functions if needed. - The module will contain the functions roots1(), roots2(), ... , roots6() and possibly a few helper functions if needed. The function main() will contain four variables named a,b,c and d for the 3 three coefficients and the discriminant. You must open two files: abc.txt for reading only and output.txt for writing only. Each row of abc.txt will contain 3 real numbers for the coefficients a, b and c. The files should be closed with close() before terminating the program. In reading abc.txt, assume that each number in the file can begin/end with any kind of whitespace like tabs, spaces and newline characters. In addition assume that there might be lines of white space at the end of the file. You should test for these so they do not crash your program. Input and process each set of coefficients in the file. -There are six different cases that that need to be considered. Three for a equal to zero and three for a not zero. Use an if-elif structure to determine the case and call one of 6 functions named roots1(), roots2(), ... , roots6() with no return value. - The variables a, b, c, d should be passed to each of the functions along with the output file stream that you opened. - The functions, roots1(), through roots6(), should be called to calculate the roots and print the results to the file named roots999.txt. The output should be similar to the sample output below. - In addition, include a heading at the top of the output file. The 1 of 4heading should be very simple with a border around it. Use a function call to print your heading. It should have the following form: Your Name UID MCS260, Spring 2013 mp1id999 Your program should never take the square root of a negative number or divide by zero. Otherwise, points will be deducted from your program score even if the program works. Some computers will crash if you do (Windows 98). When possible, you should always write your programs so they work on other computers. README will contain very simple instructions and information that would be useful to someone using your program. However, your README file will not change the way your program is tested. All programs will be run and tested the same way. In the if-elif structure the last else should result in printing an error message. ( i.e. "ERROR: Never get here!" message ). This is considered good programming. Your source code must be formatted using a style similar to that in the textbook or class examples and the first few lines of the file must begin with a comment giving the complete file name, information about you and what is in the file. Include a doc-string for each module and each function definition. For example >>> import quadroots followed by >>> help(quadroots) should provide useful information about the module and each of the functions in it. Make sure you test your code for all possible types of input values. You can check your answers using a calculator or a program like Maple, Matlab (available in pc-labs) or Octave (on raphael or icarus). Sample input: from file abc.txt (Yours will most likely be different than this) 0 0 0 0 0 1 0 2 4 1 2 1 1 5 6 1.1 2.2 3.3 -3.14159 2.71828 1.414 --------Sample output in file named roots999.txt:------------- ===================== ==Your very nice heading here. == ===================== 0.0*x^2 + 0.0*x + 0.0 = 0 has as an infinity of roots: all complex numbers are roots ===================================================== 0.0*x^2 + 0.0*x + 1.0 = 0 has no roots ===================================================== 0.0*x^2 + 2.0*x + 4.0 = 0 has one root: x = -2.0 ===================================================== 1.0*x^2 + 2.0*x + 1.0 = 0, d = 0.0000 has a double root: x = -1.0 ===================================================== 1.0*x^2 + 5.0*x + 6.0 = 0, d = 1.0000 has two real roots: x1 = -2.0 x2 = -3.0 ===================================================== 1.1*x^2 + 2.2*x + 3.3 = 0, d = -9.6800 has two complex roots: x1 = -1.0 + i*1.4142 x2 = -1.0 - i*1.4142 ===================================================== -3.1416*x^2 + 2.7183*x + 1.4140 = 0, d = 25.1579 has two real roots: x1 = -0.3657 x2 = 1.2309 =====================================================


I'd be glad to help. Please upload on your original question document and the codes you've so far.

Customer: replied 3 years ago.

I don't have any codes :(


The following is the original question document.


Received it. What's the deadline?
Customer: replied 3 years ago.


How long do you think it will take to get the homework done?

I can have it ready by tomorrow.
Customer: replied 3 years ago.

The homework is due tomorrow. Thank you so much.

you're welcome
Customer: replied 3 years ago.

How are you coming, sir?


Working through, would post it by sometime tonight.
Customer: replied 3 years ago.



Have completed most of it. I'll finish the rest and post your answer in about an hour.

You need to spend $3 to view this post. Add Funds to your account and buy credits.
R.R. Jha and 2 other Homework Specialists are ready to help you

Related Homework Questions