+254 728 680 519

Data types and Objects Part 4

We need to finish up on oop so here it goes. We have collected a bunch of attributes from our model you can call it a database, same meaning because that's where we are getting our data from. Also note that this is only the scratch of the surface, in an actual system what we have as engine attribute e.g horsepower would not have been hardcoded as done here. Most likely this data might be fed using an API which leads to the world of REST frameworks which we will start looking at later. So we need to extract that data and do some functions with it to get the stats about the three cars. Let's start with the ‘acceleration_0_60_mph’ in seconds attribute. Now that we are more used to kilometers than miles, let's convert to something we can relate to.  To find the value we need to multiply 60 with 1.60934 (I mile = 1.60934 kilometers) to find the value in km/hr.

That was simple right? So our fastest car goes from 0 to 96.5 km/hr in 4.5 seconds. Pretty impressive right? What more can we do with this data?

1. Because we have the torque and the horsepower we can calculate the speed by multiplying the horsepower with  5252 and dividing that answer by the torque. We will be using the formula RPM  =HP * 5252  /  T, where RPM is the engine speed, T is the torque, and 5,252 is radians per second.

 

 

 

 

 

Jesse

Playing Basketball, Arsenal fan, Python, and coffee!