Write Quadratic Equation

Write Quadratic Equation

Simple
English UK

Quadratic Equation may be expressed as a product

a(x-x1)(x-x2) = 0,
where x1 and x2 are the solutions of equation, so called roots. After opening the brackets you receive well known form
a*x**2 + b*x + c = 0.
This is what you should do in this mission. You have input list with integers - a, x1 [, x2]. If it has length 2, it means, x1 == x2: equation has two equal roots (one distinct root). Your function should return quadratic equation as a string. Pay attention to specific cases. Use Quadratic Formula Calculator for recheck. Good luck!

Input: List with 2-3 integers.

Output: String.

Examples:

assert quadr_equation([2, 4, 6]) == "2*x**2 - 20*x + 48 = 0"
assert quadr_equation([-2, 4, 6]) == "-2*x**2 + 20*x - 48 = 0"
assert quadr_equation([2, 4, -4]) == "2*x**2 - 32 = 0"
assert quadr_equation([2, 4, 0]) == "2*x**2 - 8*x = 0"

How it’s used: Practice of automatic representing human-friendly view of equations.

Preconditions:

  • a != 0; abs(a) == 1 -> '[-]x**2'; a != abs(1) - > '[-]a*x**2'
  • exactly one whitespace around signs: [-]a*x**2 sign b*x sign c = 0
  • abs(b) == 1 -> [-]a*x**2 sign x sign c = 0
  • keep correct view and spacing when x1=x2=0, x1 or x2 = 0, x1=-x2

Settings
Code:
Other:
Invalid hot key. Each hot key should be unique and valid
Hot keys:
CheckiO Extensions

CheckiO Extensions allow you to use local files to solve missions. More info in a blog post.

In order to install CheckiO client you'll need installed Python (version at least 3.8)

Install CheckiO Client first:

pip3 install checkio_client

Configure your tool

checkio --domain=py config --key=

Sync solutions into your local folder

checkio sync

(in beta testing) Launch local server so your browser can use it and sync solution between local file end extension on the fly. (doesn't work for safari)

checkio serv -d

Alternatevly, you can install Chrome extension or FF addon

checkio install-plugin
checkio install-plugin --ff
checkio install-plugin --chromium

Read more here about other functionality that the checkio client provides. Feel free to submit an issue in case of any difficulties.

Pair Programming (Beta-version)

Welcome to Pair Programming! Engage in real-time collaboration on coding projects by starting a session and sharing the provided unique URL with friends or colleagues. This feature is perfect for joint project development, debugging, or learning new skills together. Simply click 'Start Session' to begin your collaborative coding journey!

Waiting for Pair Programming to start...

You are trying to join a pair programming session that has not started yet.

Please wait for the session creator to join.

Waiting for Pair Programming to reconnect...

It looks like the creator of the pair programming session closed the editor window.

It might happen accidentally, so that you can wait for reconnection.

×
 
 
<< <
> >>
exec show

Whats Next?

Free accounts will see Best CheckiO solutions with some delay.
Best Solutions will be opened in a moment
Become Awesome and Don't wait
The next stage is ""
Will be activated in
View More Solutions Random Review Solutions Go to the next mission