Technology Club - ScribblersandRobots

Download Report

Transcript Technology Club - ScribblersandRobots

Week 5
Programming Basics

Variable
 Symbol representing varying values
○ y = x + 3, if x=1 then y = 4, if x=2 then y=5
○ Place holders
○ Example:
 color = ‘red’
 waitTime = 5
 robotTurnTime = 3

Types
 Number
○ whole numbers  integer (ex. 5, 6, 1000)
○ Decimal  float (ex. 1.2, 7.3, 0.5)
 Letters
○ Characters ‘a’, ‘b’, ‘A’, ‘B’, ‘!’
○ String ‘cat!’
Print Function

Print
 prints output e.x. print “hello world”
○ print “here is the counter:” + counter
○ print ‘c’ + 5
Function
List of instructions
 Building blocks
 Python syntax:

 def functionName( arguments ):
Making Robots Sing

beep(seconds, tone)
 Seconds is the amount of time the sound will
play for.
 Tone is a number between 20-20,000
(represents frequency/Hz)
 Play multiple beeps in order to make a song
Demo Song
Make your own song

Write your own custom song using the
beep command
Write a song program
Take provided music for Ode to Joy
 Write a program that plays the song
