Algorithms A sequence of instructions 1. Preheat oven to 350 degrees F (175 degrees C). Grease and flour a 9x9 inch pan or line a muffin pan with paper.

Post on 01-Jan-2016

215 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

Transcript

Algorithms

A sequenceof

instructions

1. Preheat oven to 350 degrees F (175 degrees C). Grease and flour a 9x9 inch pan or line a muffin pan with paper liners. 2. In a medium bowl, cream together the sugar and butter. Beat in the eggs, one at a time, then stir in the vanilla. 3.Combine flour and baking powder, add to the creamed mixture and mix well. Finally stir in the milk until batter is smooth. Pour or spoon batter into the prepared pan. 4. Bake for 30 to 40 minutes in the preheated oven. Cake is done when it springs back to the touch.

Computers are dumb

Language

Hint: its not English

Jython

Python in Java

Lesson 1: “Hello World!”

print “Hello World”

Lesson 2: Data Types

Integer 4,-2,100

Float 4.878, 2.0

String “Hello!123#$”

Lesson 3: Variables

Store data Jython gets it! X= “Hi” X = 5.67 X= 2

Quick Test

print 33 print “Hello” + “ “ + “World” + “!” print 22+3 print “22” + “3” print “22” + 3 print “22” * 3 print 5/3 x = 5

print x*3

JES

How to start

def function():print “Hello World”

def otherFunction():print “Hello World Again!”

Indentation groups statements together

And then…

Save then LOAD!! Call your function

Class Exercise

1. Define a function(using the def keyword) called Lab1Program

2. Create a variable called name and place in it your name, e.g. name = “Maha”

3. Print out the statement: “My name is “ + name

4. Create a new variable called myNum, place the value 5.5 in it

5. Calculate the value of myNum*4, place the answer in the variable myNum

6. Print out myNum+3

top related