Fundamentals of Programming: Difference between revisions

wikademia>Emesee
m kitty cats
No edit summary
 
(7 intermediate revisions by 4 users not shown)
Line 1: Line 1:
__NOTOC__
'''Fundamentals of programming''' are the small set of ideas that sit underneath every programming language: how values are stored, how instructions are ordered, how decisions and repetition are expressed, and how a large problem is broken into pieces a machine can carry out. This page serves self-taught beginners, instructors, and AI agents that need a compact map of the subject. The ideas carry over between languages, whether the first one is Python, JavaScript, or a spreadsheet macro language such as VBA.
==About This Course==
==About This Course==
{{IT-160_Info}}
{{IT-160_Info}}
Line 4: Line 6:
==The Instructor==
==The Instructor==
The primary instructor for this course is: [[User:Ryan524|Ryan]], however anyone is free to edit the associated course pages and contribute as they feel so inclined.  If you wish to be the instructor for your own class feel free to do so, a tutorial on how to do so is coming soon.
The primary instructor for this course is: [[User:Ryan524|Ryan]], however anyone is free to edit the associated course pages and contribute as they feel so inclined.  If you wish to be the instructor for your own class feel free to do so, a tutorial on how to do so is coming soon.
==Core concepts==
{{Col}}
* '''Values and types''': numbers, text, and true or false, each with its own operations.
* '''Variables''': names for stored values that a program can update.
* '''Expressions''': combinations of values and operators that produce a new value, such as <code>price * quantity</code>.
* '''Control flow''': the order statements run in, shaped by conditionals and loops.
{{break}}
* '''Functions''': named, reusable blocks of code that take inputs and return results.
* '''Data structures''': lists, dictionaries, sets, and records for organizing many values at once.
* '''Input and output''': reading from keyboard, files, or network, and writing results.
* '''Errors and debugging''': reading error messages, forming a guess about the cause, and testing it.
{{break}}
* '''Decomposition''': splitting a task into smaller tasks until each one is easy to write.
* '''Abstraction''': hiding detail behind a clear interface so the rest of the program can ignore it.
* '''Testing''': checks that confirm code does what it claims, rerun after every change.
* '''Version control''': recording each change with Git so mistakes can be undone.
{{colend}}
==How to learn programming==
Programming is learned by doing. A good rhythm is to read a short explanation, type the example by hand, run it, then change one thing and predict the result before running it again. When the prediction is wrong, that gap is where learning happens.
Reading and modifying existing code matters as much as writing new code. Practice opening a small open source project, finding where a particular behavior lives, and changing it on purpose.
Debugging is a skill in its own right: reproduce the problem, shrink it to the smallest failing input, inspect values at each step, and change one thing at a time.
Small finished projects teach more than large abandoned ones. Related lessons on this wiki include [[Introduction to and setup of Python]], [[Truth and flow control in Python]], and the archived book chapters at [[Archive:Think Python]].
==Why fundamentals matter more with AI coding assistants==
AI coding assistants can produce working code from a plain language request, so why learn the basics? Because the human role shifts from typing code to directing and checking it, and both depend on fundamentals.
A request to an assistant is a specification. One that names the inputs, expected outputs, edge cases, and error behavior tends to produce something usable, and writing it is the same skill as designing a function.
Generated code is often plausible but wrong. It may fail on an empty list, confuse inclusive and exclusive ranges, silently swallow an error, or call a library function that does not exist. Catching this takes fluent code reading and tests that would expose the failure. Verification, not generation, becomes the bottleneck. Anyone who lets an agent run code also needs to see what a script will delete, send, or install before it runs; see [[Sovereign AI agents and prompt injection]].
==Programming for everyday living==
Programming lets one person automate the repetitive parts of ordinary life. A short script can total household spending from a bank export, back up photos, log garden watering, or turn a messy spreadsheet into a clean report. Each saves a little time every week and puts the person in control of their own tools and data, themes explored in [[Local-first software and data ownership]], [[Open-source software that should exist]], and [[Community-run AI]].
==Example==
This Python program uses variables, a list, a loop, a conditional, a function, and a test. It totals expenses and flags any above a limit.
<pre>
def summarize(expenses, limit):
    # Return the total and a list of items that cost more than the limit.
    total = 0
    large = []
    for name, amount in expenses:
        total = total + amount
        if amount > limit:
            large.append(name)
    return total, large
items = [("rent", 1200), ("food", 340), ("bus pass", 60)]
print(summarize(items, 300))
# A simple test: an empty list should give a total of zero.
assert summarize([], 100) == (0, [])
</pre>
==Suggested practice projects==
* A number guessing game that uses a loop and gives higher or lower hints.
* A to-do list stored in a text file, with commands to add, list, and remove items.
* A script that renames every photo in a folder by the date it was taken.
* A budget summarizer that reads a CSV export and totals spending by category.
* A unit converter with tests for each conversion.
* A spreadsheet macro that cleans a weekly report.
==Discussion questions, essay ideas, and learning related AI prompt ideas==
'''Discussion questions'''
* Which concept here was hardest to grasp, and what made it click?
* Why might two programs with the same output differ greatly in quality?
'''Essay ideas'''
* Programming as literacy: what changes when ordinary people automate their own tasks.
* Specification, testing, and review as core skills in an era of generated code.
'''AI prompt ideas'''
* "Give me five Python loop exercises of rising difficulty, without solutions, then review my answers."
* "Here is my function. Do not rewrite it; ask questions that help me find the bug."
* "Explain lists versus dictionaries using a household budget example."
==Readings==
{{Col}}
* [[Wikipedia:Computer programming|Computer programming]]
* [[Wikipedia:Algorithm|Algorithm]]
* [[Wikipedia:Data type|Data type]]
* [[Wikipedia:Variable (computer science)|Variable (computer science)]]
* [[Wikipedia:Control flow|Control flow]]
{{break}}
* [[Wikipedia:Function (computer programming)|Function (computer programming)]]
* [[Wikipedia:Data structure|Data structure]]
* [[Wikipedia:Abstraction (computer science)|Abstraction (computer science)]]
* [[Wikipedia:Recursion (computer science)|Recursion (computer science)]]
* [[Wikipedia:Pseudocode|Pseudocode]]
{{break}}
* [[Wikipedia:Debugging|Debugging]]
* [[Wikipedia:Software testing|Software testing]]
* [[Wikipedia:Version control|Version control]]
{{colend}}
==External links==
* [https://ocw.mit.edu/courses/6-100l-introduction-to-cs-and-programming-using-python-fall-2022/ MIT OpenCourseWare 6.100L: Introduction to CS and Programming using Python]
* [https://ocw.mit.edu/courses/6-0001-introduction-to-computer-science-and-programming-in-python-fall-2016/ MIT OpenCourseWare 6.0001: Introduction to Computer Science and Programming in Python]
* [https://cs50.harvard.edu/x/ Harvard CS50: Introduction to Computer Science]
* [https://docs.python.org/3/tutorial/ The official Python tutorial]
* [https://allendowney.github.io/ThinkPython/ Think Python, third edition] ([https://greenteapress.com/wp/think-python-3rd-edition/ Green Tea Press])
* [https://htdp.org/ How to Design Programs]
* [https://mitp-content-server.mit.edu/books/content/sectbyfn/books_pres_0/6515/sicp.zip/index.html Structure and Interpretation of Computer Programs] (MIT Press open edition)
* [https://git-scm.com/book/en/v2 Pro Git], a free book on version control
==See also==
{{Col}}
* [[Programming]]
* [[Computer science]]
* [[Mathematics]]
* [[Python]]
{{break}}
* [[Introduction to and setup of Python]]
* [[Truth and flow control in Python]]
* [[Archive:Think Python]]
{{break}}
* [[Local-first software and data ownership]]
* [[Open-source software that should exist]]
* [[Sovereign AI agents and prompt injection]]
* [[Community-run AI]]
{{colend}}
* [https://ideawaza.com/index.php?search=programming&fulltext=Search Search this wiki for programming]


[[Category:Information technology]]
[[Category:Information technology]]
[[Category:Programming]]
[[Category:Programming]]
[[Category:Fundamentals]]
[[Category:Fundamentals]]{{ntnes}}