Changes between Version 41 and Version 42 of ControlSystems/SoftwareTeam/IntroToPython
- Timestamp:
- Sep 4, 2017, 6:51:52 PM (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ControlSystems/SoftwareTeam/IntroToPython
v41 v42 27 27 print(a) 28 28 }}} 29 29 30 This tells the computer to print, you guessed it, "Hello World" 30 31 … … 44 45 Hello World! 45 46 }}} 47 46 48 The program told the computer to print the value of variable a on the screen. 47 49 … … 67 69 print("Hope you had a good time") 68 70 }}} 71 69 72 ''Go [https://www.tutorialspoint.com/execute_python3_online.php here] and run the code above.'' It should print: 70 73 … … 78 81 Hope you had a good time 79 82 }}} 83 80 84 Three things to note about this program: 81 85 … … 89 93 if location == 'Poughkeepsie, NY': 90 94 }}} 95 91 96 and run it again. What happens? It should print "Go away, we're out eating tacos". Why? If I was in Poughkeepsie, I'd be out eating tacos too. Yummmm, tacos. 92 97 … … 94 99 95 100 {{{ 96 medianSalary=98260 #Median annual salary of a software engineer in the US 101 #!python 102 medianSalary=98260 #Median annual salary of a software engineer in the US. Yes, really. 97 103 salary=90000 98 104 if salary > medianSalary: 99 105 print("Whohoo! Dinner's on you!") 100 106 }}} 107 101 108 ''Go [https://www.tutorialspoint.com/execute_python3_online.php here] and run the code above.'' It should print: 102 109 … … 104 111 105 112 }}} 113 106 114 Yep, nothing was output. Nada. In this case, we used variables which were numbers, and a greater-than expression to compare them. Since the condition was ''False'', nothing was printed. 107 115 … … 165 173 print("score!") 166 174 }}} 167 What does it output? See how the indenting works when nesting? Note that `count+=1` is shorthand for `count=count+1`because not typing those excess characters __could save your life__.175 What does it output? See how the indenting works when nesting? Note that `count+=1` is shorthand for `count=count+1` because not typing those excess characters __could save your life__. 168 176 169 177 Now, modify the code to make it repeat the word potato each time based on the current value of count. For example: