Skip to main content
CS Teaching Tips

Main navigation

  • Browse All Tips
  • Tags
  • 3D
  • About
  • Rate Tips
  • Tip Sheets

Misconception: Students have trouble understanding that when the value of a variable is reassigned its previous value is irrelevant.

Share Misconception: Students have trouble understanding that when the value of a variable is reassigned its previous value is irrelevant. with FacebookShare Misconception: Students have trouble understanding that when the value of a variable is reassigned its previous value is irrelevant. with Twitter
  • Students struggle to understand that the prior value of a variable essentially disappears because it is written over.
  • Consider the following code:
      X=1
      X=10

      Students are confused about the value of X after this code has run. They’re not sure whether X is 1 or 10, and sometimes even think that the two numbers are added and X is now 11.

More about this tip

Tags

  • Content Misconceptions
  • CS 1
  • Intro Programming
External Source

Interview with Michael Lee.

Other Tips By
Other Tips By Michael Lee

Similar tips

Explain nested for loops using a car odometer, the innermost loop controlling the ones digit must cycle fully before the outer loops steps forward, to help students better understand nested loops through a real world example.
Provide additional support for students with less experience programming so they appreciate the level of detail and specificity computers require from instructions to perform even simple tasks.
Remind students to match types on both sides of the equations because they often try to combine types when creating variables.
  • CSTT Facebook
  • CSTT Twitter

For more information or to report a bug, contact us at admin@csteachingtips.org. Built with Bootstrap. Footer Icons by Mohammed Alyousfi. Powered by Drupal.

Privacy Policy

  • National Science Foundation
  • Sage Fox Group
  • Harvey Mudd College