Top Banner
13

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.

Jan 01, 2016

Download

Documents

Jared Jacobs
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 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.
Page 2: 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.

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.

Page 3: 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.

Computers are dumb

Page 4: 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.

Language

Hint: its not English

Page 5: 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.

Jython

Python in Java

Page 6: 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.

Lesson 1: “Hello World!”

print “Hello World”

Page 7: 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.

Lesson 2: Data Types

Integer 4,-2,100

Float 4.878, 2.0

String “Hello!123#$”

Page 8: 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.

Lesson 3: Variables

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

Page 9: 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.

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

Page 10: 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.

JES

Page 11: 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.

How to start

def function():print “Hello World”

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

Indentation groups statements together

Page 12: 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.

And then…

Save then LOAD!! Call your function

Page 13: 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.

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