I am learning python because it looks very nice and i know a bit of ruby and perl.
The following is a C program to plot 3d points onto the screen. I used this as an example because it uses arrays, structures and function calls. I left out classes because i believe that sort of (OOP) thing is used simularly in all languages (correct me if im wrong). Understand that i do know how to write the following in python (with a bit of help from google), but i would like to know what sort of methods you would use and why.
Please dont feel the need to answer if you don't have the time or don't enjoy this kind of thing!
#include <stdlib.h>
int screenWidth = 10;
int screenHeight = 10;
char *buf;
inline void draw3dPoint(int *i3dPoint) {
buf[
(((i3dPoint[1] / i3dPoint[2]) + (screenHeight/2)) * screenWidth) +
(i3dPoint[0] / i3dPoint[2]) + (screenWidth/2)] = 1;
}
main() {
int x, y;
buf = malloc(sizeof(char)*screenWidth*screenHeight);
for(x = 0; x < screenWidth * screenHeight; x++)
buf[x] =0;
int *i3dPoint = malloc(sizeof(int)*3);
i3dPoint[0] = 3; i3dPoint[1] = 0; i3dPoint[2] = 5;
draw3dPoint(i3dPoint);
i3dPoint[0] = 0; i3dPoint[1] = 4; i3dPoint[2] = 2;
draw3dPoint(i3dPoint);
i3dPoint[0] = -3; i3dPoint[1] = -4; i3dPoint[2] = 3;
draw3dPoint(i3dPoint);
for(y = 0; y < screenHeight; y++) {
for(x = 0; x < screenWidth; x++)
if(buf[(y*screenWidth)+x])
printf("#");
else
printf(" ");
printf(".\n");
}
free(buf);
free(i3dPoint);
return 0;
}