Summary (version 2.0.x/UNIX) |
-Built-in (aka Primitive) Functions 1) move() Reeborg moves one block forward. 2) turn_left() Reeborg pivots 90 degrees to left. 3) pick_beeper() Reeborg removes a beeper from corner. 4) put_beeper() Reeborg places a beeper on corner. 5) turn_off() Reeborg turns off. -Specifying a Complete Program 7) # olaNNN BY student name, CSCI 1170-sec, ... # PROGRAM ID: source-name.py / one-line description # AUTHOR: student name # INSTALLATION: MTSU # REMARKS: short description and comments # . . . def main(): ...your Reeborg statements here... turn_off() . . . other function definitions # Invoke main() main() -The Mechanism for Defining New Function Procedures 8) def IDENTIFIER(): ...your Reeborg statements here... where the IDENTIFIER consists of the following characters: A-Z, a-z, 0-9, and underscore. The IDENTIFIER cannot contain any blanks and must begin with an alphabetic letter. -The Predicates for Testing the Environment 9) SIGHT: front_is_clear() not front_is_clear() left_is_clear() not left_is_clear() right_is_clear() not right_is_clear() 10) SOUND: on_beeper() not on_beeper() 11) COMPASS: facing_north() not facing_north() facing_south() not facing_south() facing_east() not facing_east() facing_west() not facing_west() 12) TOUCH: carrying_beepers() not carrying_beepers() -Conditional Instructions 13) if predicate: 15) if predicate: statement(s) statement(s) elif predicate: 14) if predicate: statement(s) statement(s) . . . else: else: statement(s) statement(s) Example: if front_is_clear(): move() else: turn_left() -Repetition (Looping) Instructions 16) for identifier in range(iteration-amount): statement(s) comprising body of loop; . . . Example: for x in range(3): turn_left() 17) while predicate: statement(s) comprising body of loop; . . . Example: while carrying_beepers(): put_beeper()