Changes between Version 5 and Version 6 of ControlSystems/SoftwareTeam/IntroToPython


Ignore:
Timestamp:
Sep 4, 2017, 12:10:10 PM (8 years ago)
Author:
cdelgigante
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ControlSystems/SoftwareTeam/IntroToPython

    v5 v6  
    11Prerequisites: [wiki:SoftwareOverviewControl Control Systems Overview]
    22
    3 = Lesson 1:  Getting Started =
     3= Lesson 1:  Getting Started =
    44If you want to tell a computer to do something, you have to communicate with the computer in a programming ''language''.  When we say language, we mean it.   A language has words and grammar and everything else, just like French.
    55
    6 Computers, despite what you may think, are dumb.  They do only exactly what you tell them to, and don't guess or interpret.  If say to your Mom or Dad "Hey, can you bring me that thing?", there's a (slim) chance they may bring you the right "thing".  A computer wont.  Ever.  Just a cold, unfeeling "'''ERROR'''".  A programming language is very precise, and to tell a computer what you want, you have to be precise too.   In this training session, we'll introduce programming to you, and make some things work.  You know, those ''things''.
     6Computers, despite what you may think, are dumb.  They do only exactly what you tell them to, and don't guess or interpret.  If say to your Mom or Dad "Hey, can you bring me that thing?", there's a (slim) chance they may bring you the right "thing".  A computer wont.  Ever.  Just a cold, unfeeling "'''ERROR'''".  A programming language is very precise, and to tell a computer what you want, you have to be precise too.   In this training session, we'll introduce programming to you, and make some things work.  You know, those ''things''.
    77
    88Hang on, it gets harder from here.
    99
    10 (A quick note...If you know all this already and are getting bored, CONGRATULATIONS! Here's a '''[https://www.youtube.com/watch?v=x94yTpv0T1k link]''' to some cute corgi puppy videos as your reward. Then, come back and dive into a later section. This is all self-paced.)
     10(A quick note...If you know all this already and are getting bored...CONGRATULATIONS! Here's a '''[https://www.youtube.com/watch?v=x94yTpv0T1k link]''' to some cute corgi puppy videos as your reward. Then, come back and dive into a later section. This is all self-paced.)
    1111
    12 We'll be starting with a programming language called [https://www.python.org/ Python], specifically Python 3.  There are a lot of programming languages.  Some are created because they're better for solving certain problems, others because people are bored and want to try something new.  Python has been around for a while, and its pretty popular because its easy to use.  The team uses Java to control the robot but that language is a little  trickier.  We'll get to that one later once you get a handle on the basics. 
     12We'll be starting with a programming language called [https://www.python.org/ Python], specifically Python 3.  There are a lot of programming languages.  Some are created because they're better for solving certain problems, others because people are bored and want to try something new.  Python has been around for a while, and its pretty popular because its easy to use.  The team uses Java to control the robot but that language is a little  trickier.  We'll get to that one later once you get a handle on the basics.
    1313
    1414Python, like every programming language, has a structure.  Here are the big parts:
     
    2727This tells the computer to print, you guessed it, "Hello World" on the screen.
    2828
    29 Now you try it:   Go [https://www.tutorialspoint.com/execute_python3_online.php here].   Its our code editor for this training exercise.   You can enter code in the center area of the page, click execute, and see the results below.  I recommend you bookmark that site, its pretty cool.  Now on that site, highlight all the text in the central area and hit back space (this we'll clear out all the sample code.   We'll call this "clear out the test code" from now on.   Then highlight the code above, and click copy, and paste the two lines above into that editor.   Then click "Execute".  (We'll call this series of actions "run the code" from now on.   After a bit, you'll  be rewarded with the message in the bottom window:
     29Now you try it:   Go [https://www.tutorialspoint.com/execute_python3_online.php here].   Its our code editor for this training exercise.   You can enter code in the center area of the page, click execute, and see the results below.  I recommend you bookmark that site, its pretty cool.  Now on that site, highlight all the text in the central area and hit back space (this we'll clear out all the sample code.   We'll call this "clear out the test code" from now on.   Then highlight the code above, and click copy, and paste the two lines above into that editor.   Then click "Execute".  (We'll call this series of actions "run the code" from now on.  After a bit, you'll  be rewarded with the message in the bottom window:
    3030
    3131{{{
     
    8484}}}  {{{#!td COLOR BLACK [[BR]] REPEAT 4[[BR]]
    8585
    86   DRAW 10 [[BR]]  RIGHT 90 [[BR]]
     86  DRAW 10 [[BR]]   RIGHT 90 [[BR]]
    8787
    8888NEXT  }}} {{{#!td setColor(Color.Black); [[BR]] int edge = 0; [[BR]] while (edge < 4) {
    8989
    90   edge = edge + 1; [[BR]]  moveAndDraw(10); [[BR]]  turn(90); [[BR]]
     90  edge = edge + 1; [[BR]]   moveAndDraw(10); [[BR]]   turn(90); [[BR]]
    9191
    9292} }}} }}}