Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

# This project will find roots of a quadratic equation. Coefficients (a, b, c) are assumed to be in binary number system. Each bits of

# This project will find roots of a quadratic equation. Coefficients (a, b, c) are assumed to be in binary number system. Each bits of the binary number is randomly generated. Then the binary number will be converted to decimal number. After converting a, b, and c to decimal we will get the roots of the quadratic equation from random import randint, seed from datetime import datetime from cmath import sqrt seed(datetime.now()) # calculator for power and remainder def calculator(a, b, mode): # if/else block return result # random binary number generator def randBinary(): binar = [] bitSize = 5 for i in range(bitSize): rand = randint(0, 1) # will append here using rand on binar list return binar # function for bin to decimal # input a list of binary digits index 0 should have the leftmost bit def bintodec(binary): dec = 0 # loop for the calculation return dec def randNumberGenerator(): # call randBinary() and assign to a varible # call bintodec() with the variable assigned above as the argument and assign the call with a variable named decimal return decimal # finding root of a quadratic function given a, b, and c of ax^2+bx+c. def findRoot(): # call randNumberGenerator() three times and assign those calls to a, b, and c respectively if(a): # find the two roots and assign those as r1 and r2. return a, b, c, r1, r2 else: findRoot() a, b, c, root1, root2 = findRoot() print('a: {}, b: {}, c: {}, root1: {}, root 2: {}'.format(a, b, c, root1, root2)) 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Programming questions