

so far, I just have figured this and I'm not too sure how to to do the next steps;
import cmath
a=5
b=2
a=float(input('Enter the real part of the complex number: '))
b=float(input('Enter the imaginary part of the complex number: '))
c= complex(a,b);
print(c)
% Matlab program to calculate the three cubic roots of a complex number
% input of a and b
a = input(' Enter the real part of the complex number : ');
while(a == 0) % check if a is 0
a = input(' a cannot be 0. Enter the real part of the complex number : ');
end
b = input(' Enter the imaginary part of the complex number : ');
% print the complex number
fprintf(' The complex number is (%g+%gj)',a,b);
theta = atan(b/a); % calculate theta
r = a/cos(theta); % calculate r
% calculate the roots
root1 = (r^(1/3))*((cos(theta/3))+(1i*sin(theta/3)));
root2 = (r^(1/3))*((cos((2*pi+theta)/3))+(1i*sin((2*pi+theta)/3)));
root3 = (r^(1/3))*((cos((4*pi+theta)/3))+(1i*sin((4*pi+theta)/3)));
% print the output
fprintf(' root1 = %f%+fj',real(root1),imag(root1));
fprintf(' root1^3 = %f%+fj',real(root1^3),imag(root1^3));
fprintf(' root2 = %f%+fj',real(root2),imag(root2));
fprintf(' root2^3 = %f%+fj',real(root2^3),imag(root2^3));
fprintf(' root3 = %f%+fj',real(root3),imag(root3));
fprintf(' root3^3 = %f%+fj ',real(root3^3),imag(root3^3));
%end of programIn python how could I update my code to tell me the number of guesses it took my to get the correct number here is my working code so far import random number = random.randint(1,100) total_guess = 0 while total_guess<=100: guess = int(input("what is your guess?")) print (guess) total_guess = total_guess + 1 if guess<number: print("Too low") if guess>number: print("Too high") if guess==number: print("Correct!") break
Rule book: 1.)Must be Python - 2.) no imported module (ie cmath) - no can do on the imports... pure code.. 3.) numbers are float - not integer. Here's the prompt: (Algebra: solve quadratic equations) The two roots of a quadratic equation ax^2 + bx + c = 0 can be obtained using the following formula: r1 = (-b + sqrt(b^2 - 4ac)) / (2a) and r2 = (-b - sqrt(b^2 - 4ac)) / (2a) b^2 - 4ac is called...
Part 1: Python code; rewrite this code in C#, run the program and submit - include comments number= 4 guesscount=0 guess=int(input("Guess a number between 1 and 10: ")) while guess!=number: guesscount=guesscount+1 if guess<number: print("Your guess is too low") elif guess>number: print("Your guess is too high") else: print("You got it!!") guess=int(input("Guess again: ")) print("You figured it out in ",guesscount," guesses") Part 2: C++ code; rewrite the following code in C#. Run the program and submit. - include comments #include <iostream> using...
Create a class called Complex for performing arithmetic with complex numbers. Complex numbers have the form: realPart + imaginaryPart * i where i is √-1 Use double variables to represent the private data of the class. Provide a constructor that enables an object of this class to be initialized when it’s declared. The constructor should contain default values of (1,1) i.e. 1 for the real part and 1 for the imaginary part. Provide public member functions that perform the following...
Help with Python code. Right now I'm creating a code in Python to create a GUI. Here's my code: #All modules are built into Python so there is no need for any installation import tkinter from tkinter import Label from tkinter import Entry def calculatewages(): hours=float(nhours.get()) nsal=float(nwage.get()) wage=nsal*hours labelresult=Label(myGUI,text="Weekly Pay: $ %.2f" % wage).grid(row=7,column=2) return Tk = tkinter.Tk() myGUI=Tk myGUI.geometry('400x200+100+200') myGUI.title('Pay Calculator') nwage=float() nhours=float() label1=Label(myGUI,text='Enter the number of hours worked for the week').grid(row=1, column=0) label2=Label(myGUI,text='Enter the pay rate').grid(row=2, column=0)...
on python i need to code a guessing game. After the player has guessed the random number correctly, prompt the user to enter their name. Record the names in a list along with how many tries it took them to reach the unknown number. Record the score for each name in another list. When the game is quit, show who won with the least amount of tries. this is what i have so far: #Guess The Number HW assignment import...
I have to write this in Python and it must run in Python 3.
The last two pictures are what I have so far please correct me if
anything I have written so far is wrong.
anything interesting 6.8. Do addition Summary Now you will replace the pass statement inside the addition case of the iflelif ladder with something that actually does addition. Since the only number we have right now is the accumulator, you will need to ask the...
Python has the complex class for performing complex number arithmetic. For this assignment, you will design and implement your own Complex class. Note that the complex class in Python is named in lowercase, while our custom Complex class is named with C in uppercase. A complex number is of the form a + bi, where a and b are real numbers and i is √-1. The numbers a and b are known as the real part and the imaginary part...
Create a class for working with complex numbers. Only 2 private float members are needed, the real part of the complex number and the imaginary part of the complex number. The following methods should be in your class: a. A default constructor that uses default arguments in case no initializers are included in the main. b. Add two complex numbers and store the sum. c. Subtract two complex numbers and store the difference. d. Multiply two complex numbers and store...
The purpose of this question is to calculate the three cubic roots of a complex number. A complex number is of the form a + ib where i is v-1. The magnitude r of a complex number is Vab. The complex number a + ib can be written as r(cos θ + i sin θ). Therefore a -r cose and b rsin0 and b/a (r sin0)/(r cos0) - tane e- arctan(b/a). The 3 cubic roots of a complex number are...