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.
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
How to start
def function():print “Hello World”
def otherFunction():print “Hello World Again!”
Indentation groups statements together
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