File: med_quadratic.tr

package info (click to toggle)
turing 0.11-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 10,340 kB
  • sloc: python: 106,582; xml: 101; makefile: 53; sh: 29
file content (1 line) | stat: -rw-r--r-- 2,100 bytes parent folder | download | duplicates (4)
1
BlockStmt([CommentStmt('Finds the roots of a second-degree polynomial using the quadratic formula.'), DisplayStmt(StringNode('f(x) = ax² + bx + c'), True), InputStmt(IdentifierNode('a'), None), InputStmt(IdentifierNode('b'), None), InputStmt(IdentifierNode('c'), None), AssignStmt(IdentifierNode('D'), BinOpNode(BinOpNode(IdentifierNode('b'), NumberNode(2), '^'), BinOpNode(BinOpNode(NumberNode(4), IdentifierNode('a'), '*'), IdentifierNode('c'), '*'), '-')), DisplayStmt(BinOpNode(StringNode('Δ = '), IdentifierNode('D'), '+'), True), IfStmt(BinOpNode(IdentifierNode('a'), NumberNode(0), '!='), [AssignStmt(IdentifierNode('alpha'), BinOpNode(BinOpNode(UnaryOpNode(IdentifierNode('b'), '-'), NumberNode(2), '/'), IdentifierNode('a'), '*')), AssignStmt(IdentifierNode('beta'), BinOpNode(BinOpNode(IdentifierNode('D'), NumberNode(4), '/'), IdentifierNode('a'), '*')), DisplayStmt(BinOpNode(StringNode('α = '), IdentifierNode('alpha'), '+'), True), DisplayStmt(BinOpNode(StringNode('β = '), IdentifierNode('beta'), '+'), True)]), IfStmt(BinOpNode(IdentifierNode('D'), NumberNode(0), '<'), [DisplayStmt(StringNode('No real roots'), True)]), ElseStmt([IfStmt(BinOpNode(IdentifierNode('D'), NumberNode(0), '=='), [AssignStmt(IdentifierNode('x0'), BinOpNode(BinOpNode(UnaryOpNode(IdentifierNode('b'), '-'), NumberNode(2), '/'), IdentifierNode('a'), '*')), DisplayStmt(BinOpNode(StringNode('Unique real root - x0 = '), IdentifierNode('x0'), '+'), True)]), ElseStmt([AssignStmt(IdentifierNode('x1'), BinOpNode(BinOpNode(BinOpNode(UnaryOpNode(IdentifierNode('b'), '-'), CallNode(IdentifierNode('sqrt'), [IdentifierNode('D')]), '-'), NumberNode(2), '/'), IdentifierNode('a'), '*')), AssignStmt(IdentifierNode('x2'), BinOpNode(BinOpNode(BinOpNode(UnaryOpNode(IdentifierNode('b'), '-'), CallNode(IdentifierNode('sqrt'), [IdentifierNode('D')]), '+'), NumberNode(2), '/'), IdentifierNode('a'), '*')), DisplayStmt(StringNode('Two real roots:'), True), DisplayStmt(BinOpNode(StringNode('x1 = '), IdentifierNode('x1'), '+'), True), DisplayStmt(BinOpNode(StringNode('x2 = '), IdentifierNode('x2'), '+'), True)])])])