Changes between Version 49 and Version 50 of ControlSystems/SoftwareTeam/IntroToPython
- Timestamp:
- Sep 4, 2017, 7:08:22 PM (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ControlSystems/SoftwareTeam/IntroToPython
v49 v50 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 … … 47 47 And, boom, now you're a programmer. The rest of learning how to code is just more details. This is the end of Lesson 1. 48 48 49 = Lesson 2: 49 = Lesson 2: Making Decisions = 50 50 In lesson 1, we had you create a program, "Hello World". Now, "Hello World" is not too exciting if you want to program robots, but its an important first step. We showed you how to run a function (or verb) `print`, which does something (shows on the screen the value of its argument `a`, where `a` is assigned the value "Hello World". 51 51 … … 186 186 1. If you want to loop over a set of numbers, use a `range()`. For example, `for x in range(0,5)` will make x go from 0 to 4 incrementing 1 each time it loops. The first number is where x starts, and the second number is where x will stop __minus 1__. Don't ask why---its just the way computers and programs work. Don't believe me? Fine. [https://softwareengineering.stackexchange.com/questions/110804/why-are-zero-based-arrays-the-norm Don't say I didn't warn you.] 187 187 188 The solution is [wiki:ProgrammingAnswerPotatoExercise here]. 189 190 = Lesson 3: 191 So are you tired of just printing stuff yet? 192 193 Functions do things in your code. You've already used two:print (yes that's a function), and range (assuming you did the last exercise of the last less and didn't cheat).194 195 The actual code run in these functions can be pretty big. Imagine if you had to type it out every time you wanted to use it.That would get old, confusing, and error prone fast.188 The solution is [wiki:ProgrammingAnswerPotatoExercise here]. This concludes Lesson 2. 189 190 = Lesson 3: Functions = 191 So are you tired of just printing stuff yet? In the last lesson, we introduced you to all sort of ways to make decisions and loop over code to make your program easier to read and shorter too. 192 193 Functions do things in your code. You've already used two: print (yes that's a function), and range (assuming you did the last exercise of the last less and didn't cheat). 194 195 The actual code run in these functions can be pretty big. Imagine if you had to type it out every time you wanted to use it. That would get old, confusing, and error prone fast. 196 196 197 197 Functions can take variables arguments as input, and may return variables as output. … … 199 199 Here's a few handy functions, with some examples: 200 200 201 ---- 201 input(prompt): Prompts the user for input by showing the prompt screen, returning whatever the user entered after they hit <enter>. 202 202 203 [[[wiki:ProgrammingReserve Programming]Archive | Programming Archive]]