Changes between Version 5 and Version 6 of ControlSystems/SoftwareTeam/IntroToPython
- Timestamp:
- Sep 4, 2017, 12:10:10 PM (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ControlSystems/SoftwareTeam/IntroToPython
v5 v6 1 1 Prerequisites: [wiki:SoftwareOverviewControl Control Systems Overview] 2 2 3 = Lesson 1: 3 = Lesson 1: Getting Started = 4 4 If 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. 5 5 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'''". 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''. 7 7 8 8 Hang on, it gets harder from here. 9 9 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.) 11 11 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.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. 13 13 14 14 Python, like every programming language, has a structure. Here are the big parts: … … 27 27 This tells the computer to print, you guessed it, "Hello World" on the screen. 28 28 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: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: 30 30 31 31 {{{ … … 84 84 }}} {{{#!td COLOR BLACK [[BR]] REPEAT 4[[BR]] 85 85 86 DRAW 10 [[BR]] RIGHT 90 [[BR]]86 DRAW 10 [[BR]] RIGHT 90 [[BR]] 87 87 88 88 NEXT }}} {{{#!td setColor(Color.Black); [[BR]] int edge = 0; [[BR]] while (edge < 4) { 89 89 90 edge = edge + 1; [[BR]] moveAndDraw(10); [[BR]]turn(90); [[BR]]90 edge = edge + 1; [[BR]] moveAndDraw(10); [[BR]] turn(90); [[BR]] 91 91 92 92 } }}} }}}