Download presentation
Presentation is loading. Please wait.
Published bySurya Budiono Modified over 6 years ago
1
Python Versus C++: An Analysis of Student Struggle on Small Coding Exercises in Introductory Programming Courses Nabeel Alzahrani1, Frank Vahid1,3, Alex Edgcomb1,3, Kevin Nguyen1 and Roman Lysecky2,3
1 Computer Science and Engineering, University of California, Riverside
2 Electrical and Computer Engineering, University of Arizona
3 zyBooks, Los Gatos, California
Frank Vahid, UC Riverside, 2018
2
Frank Vahid, UC Riverside, 2018
CS 1 Before After C++ for majors + non-majors CS1 at 67 univ. Considering Python option for non-majors Easier to learn / less struggle? Demand Frank Vahid, UC Riverside, 2018
3
Similar C++ and Python zyBooks, widely-used
Frank Vahid, UC Riverside, 2018
4
Frank Vahid, UC Riverside, 2018
Python Frank Vahid, UC Riverside, 2018
5
Coding challenge activities (CAs) -- Homework
Frank Vahid, UC Riverside, 2018
6
Coding Challenge Activities -- CA (Homework)
Frank Vahid, UC Riverside, 2018
7
Frank Vahid, UC Riverside, 2018
8
Raw anonymized submissions for each CA
Time of submission User # Answer correct Submitted solution 3/10/2017 1:20:44 PM 0255 No while (userNum != 1){ cout << userNum << " "; userNum = userNum / 2; } ... 3/10/2017 1:24:51 PM while (userNum !=0){ while (userNum != 1){ cout << userNum << " "; userNum = userNum / 2; } cout << userNum << " "; 1:30:18 PM Yes while (userNum >= 1){ Frank Vahid, UC Riverside, 2018
9
Considered 11 ~identical CAs in C++ & Python
CA title Ch # Chapter Title 1 Tree Height 2 Vars / Assgnmt Basic while loop expression 4 Loops 3 Simon says Vector iteration: Sum excess 5 Arrays / Vectors Function call in expression 6 User-Def Fcts Function errors: Copying one function to create another 7 Function with loop: Shampoo. 8 Constructor overloading Objs & Classes 9 Basic inheritance 10 Inheritance Derived class membr override 11 Recursive function: Writing the base case 12 Recursion Frank Vahid, UC Riverside, 2018
10
Obtained anonymized submissions for 21 similar schools
School pair Total # students in C++ Total # students in Python 1 (Research universities) 153 105 2 (Community colleges) 13 33 3 (Teaching universities) 34 23 4 (Research universities) 277 176 5 (Same community college) 21 29 6 (Teaching universities) 48 35 7 (Research universities) 121 92 8 (Community colleges) 14 165 9 (Community colleges) 15 17 10 (Research universities) 167 195 11 (Teaching universities) 194 N/A Total number of students 1057 870 Frank Vahid, UC Riverside, 2018
11
Analyzed submissions for “struggle rate”
Struggling student = ((time > 5 min.) AND (# attempts > 3) AND (time > (2 * Baseline time)) AND (# attempts > (2 * Baseline attempts))) OR (time > 15 min.) Struggle rate = # struggling students / # students In other words: Excessive time or # of submissions Frank Vahid, UC Riverside, 2018
12
RESULTS: C++ vs. Python struggle rate (21 schools, 1,927 students)
Frank Vahid, UC Riverside, 2018
13
No computing prerequisites
Majors Non-Majors Frank Vahid, UC Riverside, 2018
14
Manually examined mistakes causing struggle
Simple geometry can compute the height of an object from the object's shadow length and shadow angle using the formula: tan(angleElevation) = treeHeight / shadowLength. 1. Using simple algebra, rearrange that equation to solve for treeHeight. 2. Write a statement to assign treeHeight with the height calculated from an expression using angleElevation and shadowLength. CA C++ Python 1 Struggle % = 5 treeHeight = tan(angleElevation) * shadowLength; Not knowing how to convert a math equation Using / instead of * Missing tan() for the angleElevation variable Mistyping variable names Struggle % = 9 tree_height = math.tan(angle_elev) * shadow_len Using tan() instead of math.tan() Wrong assignment (using two = symbols, assign to the wrong variable, reverse assignment, etc.) Frank Vahid, UC Riverside, 2018
15
Frank Vahid, UC Riverside, 2018
CA C++ Python 7 Struggle % = 27 void PrintShampooInstructions( int numCycles) { if (numCycles < 1) { cout << "Too few." << endl; } else if (numCycles > 4) { cout << "Too many." << endl; else { for (int N = 1; N <= numCycles; N++){ cout << N << ": Lather and rinse." << endl; } cout << "Done." << endl; } Missing for-loop Missing for-loop counter inside for-loop Wrong for-loop counter initial value Wrong for-loop condition Wrong for-loop location Wrong cout() argument inside for-loop Struggle % = 44 def shampoo_instructions(num_cycles): if num_cycles < 1: print('Too few.') elif num_cycles > 4: print('Too many.') else: for N in range(1,num_cycles+1): print(N, ': Lather and rinse.') print('Done.') Wrong while-loop update (when using while-loop) Wrong print() argument inside for-loop Missing with for-loop condition variable inside for-loop Frank Vahid, UC Riverside, 2018
16
Results from manual examination
Basic logic errors cause most struggle Similar errors in C++ and Python Just more common by Python students Frank Vahid, UC Riverside, 2018
17
Frank Vahid, UC Riverside, 2018
Conclusions Analyzed struggle for 11 same Python & C++ zyBook short coding activities across ~20 schools (~1,000 students each, at similar schools) Python struggle rate not lower; actually ~2x higher Most mistakes due to logic errors But… Other reasons for switching to Python Just one of many possible analyses Student/teacher populations might differ May help CS 1 teachers decide if should switch, or influence how taught Frank Vahid, UC Riverside, 2018
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.