Cuko T.

asked • 12/24/20

Can someone convert this c++ code to python?

#include<iostream>

#include<cmath>

using namespace std;

int main()

{

for (int a=1; a<=3;a++){
int i_velo;

cout<<"Please Enter Initial velocity (m/s): "<<endl;

cin >> i_velo ;

double weight;

cout<<"Please Enter weight (kg): "<<endl;

cin >> weight ;

int angle;

cout<<"Please Enter Angle: "<< endl;

cin >> angle;

double f_time;

f_time = 2*i_velo/(weight*9.8);


double hmax;

hmax=i_velo*cos(angle*3.14/180)*f_time;

cout<<"Max Heigh = "<<hmax<<" metre"<<endl;

double range;

range=(i_velo*i_velo*sin(2*angle)/(weight*9.8))/2;
if (range < 0){
range = range*-1;
cout<<"Range = "<<range<<" metre"<<endl;

double time_peak;
time_peak= f_time/2;
cout<<"Time to peak: "<<time_peak<<" seconds"<<endl;
}
system("pause");
}

Patrick B.

source code uploaded to RESROUCES section... I notice you are not changing the angle to radians in the sine function call
Report

12/24/20

1 Expert Answer

By:

Patrick B. answered • 12/24/20

Tutor
4.7 (31)

Math and computer tutor/teacher

Cuko T.

thank you so much. you re great.
Report

12/24/20

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.