Difference between revisions of "Quadratic Formula Assignment"
From WLCS
(10 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | '''Objective:''' | + | '''Objective:''' |
+ | * You will create a program that calculates the quadratic formula from given user input | ||
− | # Create a program | + | '''Competencies:''' |
+ | * 016 Demonstrate job-specific mathematics skills. | ||
+ | * 053 Write a program that uses variables and constants. | ||
+ | * 054 Write a program accepting user input. | ||
+ | |||
+ | '''Resources:''' | ||
+ | * [[Media:PythonInputOutput.ppt]] | ||
+ | * [[Media:PythonMathOperations.pptx]] | ||
+ | * [http://en.wikipedia.org/wiki/Quadratic_equation#Quadratic_formula Quadratic Formula] | ||
+ | |||
+ | '''Directions:''' | ||
+ | # Create a program named '''quad.py''' | ||
+ | # Prompt the user (ask the user for input) for variables a, b, and c | ||
+ | #* Don't forget to convert if necessary | ||
# Calculate both real solutions using the quadratic formula (look it up on the internets) | # Calculate both real solutions using the quadratic formula (look it up on the internets) | ||
− | # | + | #* There are two roots to calculate |
− | ## | + | #* You should have two variables x1 and x2 as the two solutions to the quadratic formula |
− | # | + | #* Exponentiation: x**y (x to the y power) |
+ | #* Square root is the same as taking something to the power 0.5 | ||
+ | #* Remember to use parentheses | ||
+ | #* Watch out for order of operations! | ||
# Print the quadratic equation: a*x^2 + b*x + c = 0 | # Print the quadratic equation: a*x^2 + b*x + c = 0 | ||
− | # Print the two | + | #* Be sure to print a, b, c using the variables, so that the equation has the original inputs |
+ | # Print the two solutions of the quadratic formula | ||
+ | |||
+ | CHALLENGE: check if the solutions are real or imaginary | ||
+ | |||
+ | '''Examples:''' | ||
+ | <pre> | ||
+ | Please enter a: 1 | ||
+ | Please enter b: 3 | ||
+ | Please enter c: 2 | ||
+ | |||
+ | Your equation is 1*x^2+3*x+2=0 | ||
+ | The roots are: | ||
+ | -1.0 | ||
+ | -2.0 | ||
+ | |||
+ | --- | ||
+ | |||
+ | Please enter a: 2 | ||
+ | Please enter b: 3 | ||
+ | Please enter c: 1 | ||
+ | Your equation is 2*x^2+3*x+1=0 | ||
+ | The roots are: | ||
+ | -0.5 | ||
+ | -1.0 | ||
− | + | </pre> | |
− |
Latest revision as of 09:35, 18 September 2017
Objective:
- You will create a program that calculates the quadratic formula from given user input
Competencies:
- 016 Demonstrate job-specific mathematics skills.
- 053 Write a program that uses variables and constants.
- 054 Write a program accepting user input.
Resources:
Directions:
- Create a program named quad.py
- Prompt the user (ask the user for input) for variables a, b, and c
- Don't forget to convert if necessary
- Calculate both real solutions using the quadratic formula (look it up on the internets)
- There are two roots to calculate
- You should have two variables x1 and x2 as the two solutions to the quadratic formula
- Exponentiation: x**y (x to the y power)
- Square root is the same as taking something to the power 0.5
- Remember to use parentheses
- Watch out for order of operations!
- Print the quadratic equation: a*x^2 + b*x + c = 0
- Be sure to print a, b, c using the variables, so that the equation has the original inputs
- Print the two solutions of the quadratic formula
CHALLENGE: check if the solutions are real or imaginary
Examples:
Please enter a: 1 Please enter b: 3 Please enter c: 2 Your equation is 1*x^2+3*x+2=0 The roots are: -1.0 -2.0 --- Please enter a: 2 Please enter b: 3 Please enter c: 1 Your equation is 2*x^2+3*x+1=0 The roots are: -0.5 -1.0