BestPromptFinder
HomeCoding › Below is an instruction that describes a task. Write a respo...

Below is an instruction that describes a task. Write a respo...

Coding · Gemini, GPT-5.6, Claude · Coding
45Quality
89%Useful
86Reliability

The prompt

Below is an instruction that describes a task. Write a response that appropriately completes the request. ### Instruction: Create a program for solving a quadratic equation in Python. ### Input: Equation: x2 + 3x - 4 = 0 ### Output: import math def solveQuadratic(a, b, c): discriminant = (b**2) - (4*a*c); # If discriminant is negative there are no real roots. if (discriminant < 0): return { "status": false, "roots": [] } # If discriminant is zero, there is only one real roots. elif (discriminant == 0): x = -b/(2*a) return { "status": true, "roots": [x] } # Otherwise there are 2 real roots else: x1 = (-b + math.sqrt(discriminant)) / (2*a); x2 = (-b - math.sqrt(discriminant)) / (2*a); return { "status": true, "roots": [x1, x2] } a = 1 b = 3 c = -4 print(solveQuadratic(a, b, c)) #{'status': True, 'roots': [-4.0, 1.0]}
Find similar in the app →

Why this prompt

Source

Hugging Face

Related Coding prompts

PRD to MVP Technical Plan
Quality 93 · Claude Code
Full-Stack CRUD App Builder
Quality 93 · Claude Code
Legacy Refactor Planner
Quality 93 · Claude Code
Test Suite Generator
Quality 93 · Claude Code
Third-Party API Integration
Quality 93 · Claude Code
Database Schema and Migration
Quality 93 · Claude Code