Writing our First Programs
CS 110
1
How to login to PollEverywhere!
On your phone / tablet, either scan the QR code here (or up on the screen) or go to pollev.com/baincs110
Step 1. CLICK LOGIN
Step 2. USE @U.NORTHWESTERN EMAIL ADDRESS
Step 3. CLICK LOGIN WITH NORTHWESTERN
Step 4. Follow sign-in steps with MFA
Step 5. You may need to go back to pollev.com/baincs110 after you've setup your account. Make sure to set your NetID as your Screen Name!!!
Announcements
Next Week
A typical week…
Monday - Attend lecture, take a look at tutorial, and homework
Tuesday - Watch the pre-recorded lecture for Wednesday; peruse the tutorial
Wednesday - Come to the tutorial session, try your best to iron out all of your questions; see if you can do any of the HW
Thursday - by now, you should have a strong sense of how long it will take you to complete HW Exercise; if you need more time, apply for late penalty waiver
Friday - come to class, participate in activities; finish up HW
Sat/Sun - take the weekend off
Resources available throughout the week: Canvas, Class, Office Hours, and edSTEM
Turtle activities!
On our course web page
5
Understanding the Words / Atoms of Programming
6
Python is made up of different kinds of “words”, which can be used to construct sentences and paragraphs (statements and code blocks). Some types of ‘words’ in Python include:
The first rule of programming!
Python will only do something you ask it to.
Arithmetic Operators
�
8
+ | Addition | Adds values on either side of the operator |
- | Subtraction | Subtracts right hand operand from left hand operand |
* | Multiplication | Multiplies values on either side of the operator |
/ | Division | Divides left hand operand by right hand operand |
** | Exponent | Performs exponential (power) calculation on operators |
% | Modulus | Divides left hand operand by right hand operand; returns remainder |
// | Quotient | Divides left hand operand by right hand operand; returns quotient |
Variables
Named containers that allow us to store and access data in Python.
Variables
variable_name = piece_of_data
10
Variables
Turn the following statement into a sentence:
�favorite_cookie = "oreo"�
11
Variables
Turn the following statement into a sentence:
�favorite_cookie = "oreo"�
12
Variables
Turn the following statement into a sentence:
�favorite_cookie = "oreo"�
Assign the text "oreo" to a container called favorite_cookie.
13
Variables
Turn the following statement into a sentence:
�favorite_cookie = "oreo"�
Assign the text "oreo" to a container called favorite_cookie.
Big Idea: Our goal for any line of Python we write is to be able to explain what it does in plain english.
14
Naming Variables
Example 1:
favorite_cookie = "oreo"
Example 2:
1st_cookie = "oreo"
15
Reminders
Next Week