This is a program I worked on in a program called Python. Python is a programming language which allows you to function concepts using codes and such like that. In class today, we programmed a number guessing game. We first had an exampled of our game in real life by having someone think of a number and having the rest of the class guess what the number was. In Python, we had the computer think of a number while we guessed what it was. In the picture above, the right side of the screen is the controls we put into the computer. On the left is what we told the computer to do by running what was on the control side.
This is another program we made in class. Instead of guessing of the number the computer randomly chose, we made a program for the computer to guess of a number we were thinking of. I couldn't open up the page which showed the controls/functions, but this is the program we made. The guess range was from one to one hundred and instead of having the computer guess one hundred numbers, we made a simple way for it to determine whether the number is higher or lower.
The computers' first guess was always fifty because 100/2 is 50. We programmed it to do this because if the number I was guessing of was higher, the computer would know that my number isn't 1-50. After knowing 1-50 isn't the number I was thinking of, the computer determines half of 50-100 which is 75. 75 is the computers' second guess if it's higher that 50. If the number is lower than 50, what would the guess be? 25. If you've got the pattern already, the computer just cuts the range and guesses the number in the middle.
This is the face I made closer up:
In order to make the smiley face, we had to make ellipses and triangles. I screenshotted a reference from Processing.org so you would be able to see what the different codes meant when I put it in my smiley face program:
For the Ellipse's
For the Triangle's
This is the code and output for when I tested out the printing function. In JavaScript, the way you define variables isn't that difficult. I order to declare a variable and it's worth, all you have to do is write "var," write an equal sign (=), and then label what it's value is. Here's an example of mine.