Code Basics

All Programs Combine Just a Few Basic Concepts
AI and coding can be intimidating to learn. But the entrance is framed in some simple ideas.

All code combines just a few key components—no matter the scale or complexity! Anything you want to build will be composed of these pieces layered together.

Data
Data are pieces of input to the machine. They are the information you are giving, manipulating, and getting back out.

Data types are all the different kinds of information you can store. Some languages ask you to specify which kind of variable you're creating, like Javascript. Others, like Python, can tell just by how the data is formatted.

Strings are simple lines of text (always seen in between single or double quotation marks).

Numbers include integers aka whole numbers like 100; floats are numbers with decimals like 0.25; sometimes other kinds too.

Booleans are either  or   (or a sneaky  ).

Variables
Variables are labeled containers for information. They are placeholders you can name and store things in to recall for later. Let's say. That means we declared  is a variable storing the data. Later we can ask, &quot;What was ?&quot; or say, &quot;Change   now.&quot; (And then next time we ask what   equals, the answer will be different.)

Naming has power. ENCODE &lt;&gt;&lt;&gt; DECODE
''Pssst... you decide what to name your variables.''

You are deciding what information means. e.g. the weight of a feature in a machine learning model or the threshold that demarcates one color from another.

Data in Groups
There are different data types we use to group collections of data together. They each have different benefits:

Arrays AKA Lists are simple run downs of data. They can usually be of any length and be of any kind of data:


 * Dictionaries contain pairs of information, where each pair has a key and a value assigned to match, like a label for each piece of info:
 * Sets are special lists that forbid duplicates, which can sometimes come in handy!
 * Dictionaries contain pairs of information, where each pair has a key and a value assigned to match, like a label for each piece of info:
 * Sets are special lists that forbid duplicates, which can sometimes come in handy!

Any of the above data types can be stored in a variable that you name (almost whatever you want).

Action! Calculations &amp; Operations
Now that you've got some data in your program, time to do something with it! One of the main things programs do is make calculations on data using mathematical operations like add, subtract, multiply, divide, etc., as well as Boolean operations that act as filters, for example AND and OR.

Functions: Take It with You
Functions are a way to organize and reuse code, along with its embedded ideas and values. Like putting snippets of code and ideas in a bag.

"Wow that's some useful code!" "What about those ideas, though?"

The more you organize your code into functions, the easier it is to reuse in later projects. And guess what, you also save your functions with almost any variable name you want!

Like variables, functions store stuff, but instead they can save a whole phrase that expresses an action. They can execute and act on whatever data you feed into them when you put them to work later.

The best (and sometimes worst) part about computation is that it's designed to make patterns to apply to multiple situations.

Do It Again! Loops &amp; Conditionals
A loop helps you repeat an action many times.

"What factors are overlooked when working at a large scale?" "How do we treat different things?" A conditional helps you decide whether to do an action or not.

"How do you decide on the right judgment call?" Computers can compound decision-making work at high speed and great volume, allowing for amazing automation but also enormous, unforeseen ethical impacts.

NO SUCH THING AS RAW DATA
, translation, recommendation, calculation, search result, prediction

Pro Tip: The quality of the information coming out cannot be better than the quality of the information coming in.

Garbage in, garbage out


Resources
Don't stop, don't give up!

Keep Going! Where to look next?

Creative Code Collective, Resource Hub

Sharon Lee De La Cruz: Can computers understand slang? Code Slang: crowdsourced library, flexible, visual output. &quot;Retaining a culture, meeting people where they're at, celebrating the way we communicate.&quot; &amp; the Digital Citizens Lab

Aesthetic Programming Exploratory Programming for the Arts and Humanities, 2nd Ed