Changes between Version 41 and Version 42 of ControlSystems/SoftwareTeam/IntroToPython


Ignore:
Timestamp:
Sep 4, 2017, 6:51:52 PM (8 years ago)
Author:
cdelgigante
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ControlSystems/SoftwareTeam/IntroToPython

    v41 v42  
    2727print(a)
    2828}}}
     29
    2930This tells the computer to print, you guessed it, "Hello World"
    3031
     
    4445Hello World!
    4546}}}
     47
    4648The program told the computer to print the value of variable a on the screen.
    4749
     
    6769print("Hope you had a good time")
    6870}}}
     71
    6972''Go [https://www.tutorialspoint.com/execute_python3_online.php here] and run the code above.''  It should print:
    7073
     
    7881Hope you had a good time                                                                                                                                                                                                                               
    7982}}}
     83
    8084Three things to note about this program:
    8185
     
    8993if location == 'Poughkeepsie, NY':
    9094}}}
     95
    9196and 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.
    9297
     
    9499
    95100{{{
    96 medianSalary=98260 #Median annual salary of a software engineer in the US
     101#!python
     102medianSalary=98260 #Median annual salary of a software engineer in the US.  Yes, really.
    97103salary=90000
    98104if salary > medianSalary:
    99105   print("Whohoo! Dinner's on you!")
    100106}}}
     107
    101108''Go [https://www.tutorialspoint.com/execute_python3_online.php here] and run the code above.''  It should print:
    102109
     
    104111   
    105112}}}
     113
    106114Yep, 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.
    107115
     
    165173print("score!")
    166174}}}
    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__.
     175What 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__.
    168176
    169177Now, modify the code to make it repeat the word potato each time based on the current value of count.  For example: