miscon:programming.functions.print-is-return · draft · trust low · v0.1.1 · kind misapplied-analogy

Printing a value is the same as returning it

A function gives its result back by printing it, so a function that prints its answer can be used in an expression, and return is just another way to display.

Stable URI
https://open-misconceptions.github.io/miscon-data/m/programming.functions.print-is-return
UUID
c75e0b4a-c9c4-41af-af83-a095635ace63
Domain
programming.functions
Level band
secondary, undergraduate
Locale
en
About
https://open-misconceptions.github.io/miscon-data/c/programming.functions.return (Miscon)

Evidence patterns

Pattern 0: use the result of a function that prints instead of returning

expects the printed value to be available to the caller

Itemdef double(n): print(n * 2) x = double(4) print(x + 1)
Expected8 then TypeError (x is None)
Response9

Pattern 1: write a function that should return a value

prints the value and omits return

ItemWrite square(n) so that square(3) + 1 is 10.
Expecteddef square(n): return n * n
Responsedef square(n): print(n * n)

Discriminators

vs a slip. A slip is one missing return the learner spots on rereading. The belief is a stated equivalence ('print gives it back') and persists after seeing None.

Relations

conflicts_with
return hands a value back to the caller and ends the call (external)
resolved_by
return hands a value back to the caller and ends the call (external)

Provenance

Origin: llm-drafted

  1. Sorva, J. (2012). Visual Program Simulation in Introductory Programming Education (Doctoral dissertation, Aalto University). Appendix A catalogues introductory programming misconceptions from the literature. link
    Catalogue entry on confusing output with return values.
  2. Kaczmarczyk, L. C., Petrick, E. R., East, J. P., & Herman, G. L. (2010). Identifying student misconceptions of programming. In Proceedings of the 41st ACM Technical Symposium on Computer Science Education (SIGCSE '10), 107-111. doi:10.1145/1734263.1734299
  3. Qian, Y., & Lehman, J. (2017). Students' misconceptions and other difficulties in introductory programming: A literature review. ACM Transactions on Computing Education, 18(1), Article 1. doi:10.1145/3077618

Drafted from the cited literature for the Open Misconceptions seed pack; statement, examples and discriminators are original text. Awaiting maintainer review.

Review status

Status draft, trust low (computed from the reviews below against the reviewer registry).

No reviews yet.

Formats

Cite

miscon:programming.functions.print-is-return
https://open-misconceptions.github.io/miscon-data/m/programming.functions.print-is-return