Programming


html

Html is one language used in all websites, this is the code for the page you are on right now.

Logo

by telling the turtles how to move, you can make many different patterns more complex
then a person can do, like below

Math in programming

Math is importent to remember when programming. Making the equations in a function will put less work on you.

Major Tools of Programming

There are a few things that will be in every programming language. With them, you can do programming in most language

Loops

Looping an action will allow you to repeat the same function without restating it

Variables

Variables allow you to change a number in an equation within the same equation, like the example below, to make the y tree above

conditionals

Conditions let you do something automatic inside a function when condition/s are meat.

functions

A function gives a name to a series of commands to be done at any time. This also will let other functions
refer to a previous function with a simple name to do those commands.

comments

Comments remind you what everything does, so when you are doing programs with hundreds of lines of code, you'll remember
what everything does.

Colony program

In NetLogo, programming the turtles to move, breed and eat made a simulation of how the turtles would survive in the environment.
With the field set to fully grown at the beginning, the population goes up, but will go down as there are too many and little grass.
like in the example below. In the program, you need to put in code for there energy, or life, so they will die and breed at the right times.
In the move command, I gave the red turtles a advantage by having them move slightly faster, leading to them being the lest alive at the end.
I also made yellow have more starting population, 10 minimum starting. Red still won out most the time, but yellow would always last around
100-200 ticks more then others before dying out.
Green would have 2 offspring at a time, but this actually made it harder to live as the turtles would stay in one area.
And I had pink get more food from eating then others, this let them survive better, but red would still win out more.
Speed op.

Python programming

On Wednesday of week two, we began learning python programming, learning how to write in it as well as loops, variables, functions,
and conditionals. We made a name game, and this is the code.

Equations

Making an equation to solve a problem is easy, complicated equations are fast for a computer. In class we made a code to solve a
large variety of problems

Prime solver

On Thursday, we made a code in python to check if any number put in is prime. First we made a code to see if a number is divisible by another.
Using that, the code loops through all numbers less than itself, putting them in the division code. If a number that can divide into it is
found, it will say what it is and then stop. If none are found, then it will tell it is prime. This code can handle numbers that people
can't

random code

Home