Question

In: Computer Science

python . The two csv files will contain lines in the following format: Angle, time, speed...

python .

The two csv files will contain lines in the following format: Angle, time, speed - where each action will be specified as:
• A, t, s = Move at an angle of A degrees with respect to East direction (positive horizontal axis) for t seconds with speed s meters per second.
  
The function should return 3 numpy arrays:
• The expected horizontal displacements for each microcar
• The expected vertical displacements for each microcar
• The expected distances travelled by each microcar

All displacements and distances are to be presented in meters and rounded to 2 decimal places for the final returned lists. Keep the data rounded to at least 10 decimal places for all intermediate computations.

please make a code ignoring cvs files

Solutions

Expert Solution

import math
import numpy as np

# since you said to ignore the read of csv files i am ignoring it and doing the rest
# A,t,s as said in question and d is distance
# distance can be calculated normally i.e expected distance covered
d=s*t

#vd,vertical displacement is sin(theta) of d as python uses radians to compute everything we convert degree to radians
#hd,horizontal displacement is cos(theta) of d as  python uses radians to compute everything we convert degree to radians
hd=d*math.cos(math.radians(A))
vd=d*math.sin(math.radians(A))

#rounding off to 2 dec places

hd=round(hd,2)
vd=round(vd,2)
d=round(d,2)
ans=[hd,vd,d]

#we need to repeat this whole process for each row so i hope you know it as you said to ignore the csv file part
# so for each row in csv file repeat everything.

#since we are calculating for each row the numpy array would be a nd array so we make a list [ans] and append it to finals
#The axis is an optional integer along which define how the array is going to be displayed. 
# If the axis is not specified, the array structure will be flattened 


finalans = np.append(finalans, [ans], axis = 0)

Related Solutions

Create two files, file1.csv and file2.csv Write the following information in file1.csv: Apple 1.69 001 Banana...
Create two files, file1.csv and file2.csv Write the following information in file1.csv: Apple 1.69 001 Banana 1.39 002 Write the following information in file2.csv: Apple 1.69 001 Carrot 1.09 003 Beef 6.99 004 You have two files, both of the two files have some information about products: • Read these two files, find out which products exist in both files, and then save these products in a new file. You can use the two files you created in Lab 1...
using python In the directory rootdir some of the files contain randomly generated content while others...
using python In the directory rootdir some of the files contain randomly generated content while others are written by human authors. Determine how many of the files contained in the directory are written by human authors. Store your answer in the variable number_human_authored.
Using python: In the directory rootdir some of the files contain randomly generated content while others...
Using python: In the directory rootdir some of the files contain randomly generated content while others are written by human authors. Determine how many of the files contained in the directory are written by human authors. Store your answer in the variable number_human_authored.
Using python: In the directory rootdir some of the files contain randomly generated content while others...
Using python: In the directory rootdir some of the files contain randomly generated content while others are written by human authors. Determine how many of the files contained in the directory are written by human authors. Store your answer in the variable number_human_authored
Compare C++ speed to Python speed. To compare Execution Time of: c++ vs. Py : //...
Compare C++ speed to Python speed. To compare Execution Time of: c++ vs. Py : // this is c++ code // covert this code to python and compare their execution time #include<time.h> #include <iostream> using namespace std; #include <chrono> //for time using namespace std::chrono; void doSomething() //to insert any execution code here to measure its running time { int x=6795; // cout << "Enter 4-digit integer x ?\n"; cin >> x; for (int i = 1000; i < 2000000; i++)...
Complete the Python function called 'greetings(time)' that accepts a time in "HH:MM" format as a string....
Complete the Python function called 'greetings(time)' that accepts a time in "HH:MM" format as a string. The function should return a greeting message based on the hour given in the time object as follow: If the time is before noon: 'Good Morning.', if it is in the afternoon: 'Good Day.' Please use the following template for your python script to define the greetings() function and name it as mt_q3.py. Replace the place holder [seneca_id] with your Seneca email user name....
CODE BLOCK E import csv filename = "D:/python/Week8/files/green.csv" with open(filename) as file: data_from_file = csv.reader(file) header_row...
CODE BLOCK E import csv filename = "D:/python/Week8/files/green.csv" with open(filename) as file: data_from_file = csv.reader(file) header_row = next(data_from_file) for index,column_header in enumerate(header_row): print(index,column_header) How many COUMNS (not rows!) will be printed in the above code?
Two ramps, each with the same shape angle, and height from the base contain two different...
Two ramps, each with the same shape angle, and height from the base contain two different objects. One ramp has a solid sphere located at the top while the other ramp has a solid cube located at the top. The mass of the sphere is equal to the mass of the cube. The objects are released from the same height. The sphere rolls without slipping, and the cube travels without friction. After leaving the ramp, which object will travel higher?...
Please use C++. You will be provided with two files. The first file (accounts.txt) will contain...
Please use C++. You will be provided with two files. The first file (accounts.txt) will contain account numbers (10 digits) along with the account type (L:Loan and S:Savings) and their current balance. The second file (transactions.txt) will contain transactions on the accounts. It will specifically include the account number, an indication if it is a withdrawal/deposit and an amount. Both files will be pipe delimited (|) and their format will be the following: accounts.txt : File with bank account info...
1) Equations for two lines L1 and L2 are given. Find the angle between L1 and...
1) Equations for two lines L1 and L2 are given. Find the angle between L1 and L2. L1: ? = 7 + 2?, ? = 8 − 4?, ? = −9 + ? L2: ? = −8 − ?, ? = 3 − 3?, ? = 4 + 3? 2) Find polar form of complex number z : ?) ? = 4√3 − 4? ?) ? = 2√3 − 2i
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT