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
def double(n):
print(n * 2)
x = double(4)
print(x + 1)8 then TypeError (x is None)9Pattern 1: write a function that should return a value
prints the value and omits return
Write square(n) so that square(3) + 1 is 10.def square(n):
return n * ndef 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
- 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. - 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
- 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
- Raw JSON
- CASE 1.1 package (CFItem
c75e0b4a-c9c4-41af-af83-a095635ace63) - Source on GitHub
Cite
miscon:programming.functions.print-is-return
https://open-misconceptions.github.io/miscon-data/m/programming.functions.print-is-return