@dhruvbaldawa on twitter
'coz code speaks louder than words
print "Hello World"
#include <iostream>
using namespace std;
int main (int argc, char** argv)
{
cout << "Hello World!";
return 0;
}
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
for line in open("filename"):
print line
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main () {
string line;
ifstream myfile ("filename");
if (myfile.is_open()) {
while ( myfile.good() ) {
getline(myfile,line);
cout << line << endl;
}
myfile.close();
}
else cout << "Unable to open file";
return 0;
}
import java.io.*;
class FileRead {
public static void main(String args[]){
try{
FileInputStream fstream = new
FileInputStream("textfile.txt");
DataInputStream in = new
DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
while ((strLine = br.readLine()) != null) {
System.out.println (strLine);
}
in.close();
}
catch (Exception e){
System.err.println("Error: " + e.getMessage());
}
}
}
a, b = b, a
Everybody is using Python to teach Programming
“Udacity’s courses so far have been using Python because it is overall, the most convenient language for teaching and learning. The natural syntax means students spend less 6me grokking code than with terser languages.”-- Chris Chew, Software Engineer, Udacity Inc.[3]
Contact me at: http://www.dhruvb.com/
Submit feedback: http://www.dhruvb.com/pyfeedback