MathubLearn / Practice / Excel
CSCI 127 Joy and Beauty of Data · Unit 4: Data science · on Final exam (Exam 3)

4.4 Python vs C vs Java, and the final

Study notes for Python vs C vs Java, and the final in CSCI 127 Joy and Beauty of Data at Montana State University: the big ideas, code you should know, a worked example, common mistakes and an exam tip. The same topic has endless practice questions and flashcards in Mathub.

Big ideas

Code you should know

The same loop in three languages (only Python runs here)
# Python
total = 0
for i in range(1, 6):
    total += i
print(total)

# C
# int total = 0;
# for (int i = 1; i <= 5; i++) { total += i; }
# printf("%d\n", total);

# Java
# int total = 0;
# for (int i = 1; i <= 5; i++) { total += i; }
# System.out.println(total);
Output
15

Worked example

Name two advantages of Python over C and two of C over Python.
Show the solution
Python: shorter code, no compile step, dynamic typing and huge libraries (NumPy, pandas). C: much faster execution, control over memory and hardware, errors caught at compile time.

Common mistakes

Exam tipFor the final, redo Labs 11–14 and Program 5, then run through the Unit 4 flashcards and the practice quiz in the Exam prep page.

Keep going in Mathub

Mathub is free for Montana State students: an endless quizzer with worked explanations, one-question lessons, flashcards, exam prep checklists, the class calendar with every deadline, a grade calculator and a study board for CSCI 127.