CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm...
Transcript of CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm...
![Page 1: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/1.jpg)
CSCI 141
Lecture 3Introduction to Data:
Types, Values, Function Calls, Variables
![Page 2: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/2.jpg)
Happenings· CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions about writing resumes and cover letters will be answered while enjoying… PIZZA!
· Tech Talk: Google on Monday, October 7th 5-6pm in CF 115 Googlers share a day-in-the-life as a software engineer Resume review with Google on Monday, 10/7 during the day—sign up here
· Accenture on Tuesday October 8th 4-6pm CF 110 Resume prep, with interviews to follow October 30th-November 1st
· Tech Talk: Microsoft on Wednesday, October 9th 5-6:30pm in CF 115 Powershell: From Windows to the Cross-Platform Cloud
![Page 3: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/3.jpg)
Announcements
![Page 5: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/5.jpg)
• Assignment 1 will be released later today
• 3 small programming problems; Due next Monday night
Announcements
![Page 6: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/6.jpg)
• Assignment 1 will be released later today
• 3 small programming problems; Due next Monday night
• Everything you need to complete A1 will be covered by Wednesday.
Announcements
![Page 7: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/7.jpg)
• Assignment 1 will be released later today
• 3 small programming problems; Due next Monday night
• Everything you need to complete A1 will be covered by Wednesday.
• You can work on it in the labs (details on the syllabus) or on your own computer.
Announcements
![Page 8: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/8.jpg)
• Assignment 1 will be released later today
• 3 small programming problems; Due next Monday night
• Everything you need to complete A1 will be covered by Wednesday.
• You can work on it in the labs (details on the syllabus) or on your own computer.
• Reminder: You can download Thonny from thonny.org.
Announcements
![Page 9: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/9.jpg)
• Assignment 1 will be released later today
• 3 small programming problems; Due next Monday night
• Everything you need to complete A1 will be covered by Wednesday.
• You can work on it in the labs (details on the syllabus) or on your own computer.
• Reminder: You can download Thonny from thonny.org.
• Please keep track of the hours you spend
Announcements
![Page 10: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/10.jpg)
Socrative
Please log in at the beginning of class so you're ready when poll questions come up.
Reminder:
• socrative.com (or get the app)
• Room: 9AM141
• Student ID: Your WWU username.
![Page 11: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/11.jpg)
QOTD• You are given 3 "slip days" that allow you to
submit something 24 hours late without penalty. T/F: These can be used for labs, assignments, or QOTDs.
![Page 12: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/12.jpg)
QOTD• You are given 3 "slip days" that allow you to
submit something 24 hours late without penalty. T/F: These can be used for labs, assignments, or QOTDs.
False.
![Page 13: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/13.jpg)
QOTD• You are given 3 "slip days" that allow you to
submit something 24 hours late without penalty. T/F: These can be used for labs, assignments, or QOTDs.
False.
Slip days are only usable on programming assignments.
![Page 14: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/14.jpg)
QOTD• You are given 3 "slip days" that allow you to
submit something 24 hours late without penalty. T/F: These can be used for labs, assignments, or QOTDs.
False.
Slip days are only usable on programming assignments.
Special circumstances for missing lab or submitting late? Email me.
![Page 15: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/15.jpg)
QOTD• T/F: All programming assignments are
expected to take approximately the same amount of time to complete.
![Page 16: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/16.jpg)
QOTD• T/F: All programming assignments are
expected to take approximately the same amount of time to complete.
False.
![Page 17: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/17.jpg)
QOTDWhere are lecture slides posted after lecture?
A. Socrative
B. Gradescope
C. Canvas
D. The course webpage
![Page 18: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/18.jpg)
QOTDWhere are lecture slides posted after lecture?
A. Socrative
B. Gradescope
C. Canvas
D. The course webpage
![Page 19: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/19.jpg)
QOTDAccording to the academic honesty policy, which of the following are permitted?A. Talking about your code with your classmates. B. Looking at a classmate's code, then immediately
sitting down and typing out a very similar program, but with different variable names.
C. Submitting someone else's program as your own. D. Copying a few lines of someone else's code into
your solution, if you understand those lines in detail.
![Page 20: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/20.jpg)
QOTDAccording to the academic honesty policy, which of the following are permitted?A. Talking about your code with your classmates. B. Looking at a classmate's code, then immediately
sitting down and typing out a very similar program, but with different variable names.
C. Submitting someone else's program as your own. D. Copying a few lines of someone else's code into
your solution, if you understand those lines in detail.
![Page 21: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/21.jpg)
QOTDAccording to the academic honesty policy, which of the following are permitted?A. Talking about your code with your classmates. B. Looking at a classmate's code, then immediately
sitting down and typing out a very similar program, but with different variable names.
C. Submitting someone else's program as your own. D. Copying a few lines of someone else's code into
your solution, if you understand those lines in detail.
![Page 22: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/22.jpg)
QOTDAccording to the academic honesty policy, which of the following are permitted?A. Talking about your code with your classmates. B. Looking at a classmate's code, then immediately
sitting down and typing out a very similar program, but with different variable names.
C. Submitting someone else's program as your own. D. Copying a few lines of someone else's code into
your solution, if you understand those lines in detail.
![Page 23: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/23.jpg)
QOTDAccording to the academic honesty policy, which of the following are permitted?A. Talking about your code with your classmates. B. Looking at a classmate's code, then immediately
sitting down and typing out a very similar program, but with different variable names.
C. Submitting someone else's program as your own. D. Copying a few lines of someone else's code into
your solution, if you understand those lines in detail.
![Page 24: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/24.jpg)
Goals• Understand that data of different types is represented on a computer
in different ways, and know the meaning of the following types:
• str, int, float
• Know how to use the type conversion functions int, float, str
• Understand the syntax for calling functions with arguments, and know how to use the following functions:
• print (with multiple arguments) input (with a prompt argument)
• type
• Know how to name and store values using variables and the assignment operator
![Page 25: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/25.jpg)
Last time…
![Page 26: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/26.jpg)
Last time…• An algorithm is a step by step procedure to
solve a problem.
![Page 27: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/27.jpg)
Last time…• An algorithm is a step by step procedure to
solve a problem.
• We sometimes use pseudocode - a description of the steps of an algorithm that is not in any particular programming language.
![Page 28: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/28.jpg)
Last time…• An algorithm is a step by step procedure to
solve a problem.
• We sometimes use pseudocode - a description of the steps of an algorithm that is not in any particular programming language.
• Functions and function calls...
![Page 29: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/29.jpg)
Last time: Function Calls
![Page 30: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/30.jpg)
Last time: Function Calls• We’ve seen two functions so far:
![Page 31: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/31.jpg)
Last time: Function Calls• We’ve seen two functions so far:
• print and input
![Page 32: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/32.jpg)
Last time: Function Calls• We’ve seen two functions so far:
• print and input
• Functions can take inputs, called arguments
![Page 33: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/33.jpg)
Last time: Function Calls• We’ve seen two functions so far:
• print and input
• Functions can take inputs, called arguments print("some text")
![Page 34: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/34.jpg)
Last time: Function Calls• We’ve seen two functions so far:
• print and input
• Functions can take inputs, called arguments
"some text" is an argument to the print function call
print("some text")
![Page 35: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/35.jpg)
Last time: Function Calls• We’ve seen two functions so far:
• print and input
• Functions can take inputs, called arguments
• or not:"some text" is an argument to the print function call
print("some text")
![Page 36: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/36.jpg)
Last time: Function Calls• We’ve seen two functions so far:
• print and input
• Functions can take inputs, called arguments
• or not:"some text" is an argument to the print function call
print("some text")
input()
![Page 37: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/37.jpg)
Last time: Function Calls• We’ve seen two functions so far:
• print and input
• Functions can take inputs, called arguments
• or not:"some text" is an argument to the print function call
input is called with no arguments here
print("some text")
input()
![Page 38: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/38.jpg)
Function Calls• Syntax for a function call:
print("I am", 31, "years old")
![Page 39: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/39.jpg)
Function Calls• Syntax for a function call:
Function name
print("I am", 31, "years old")
![Page 40: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/40.jpg)
Function Calls• Syntax for a function call:
Function name
Open paren
print("I am", 31, "years old")
![Page 41: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/41.jpg)
Function Calls• Syntax for a function call:
Function name
Open paren
Comma-separated list of arguments
print("I am", 31, "years old")
![Page 42: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/42.jpg)
Function Calls• Syntax for a function call:
Function name
Open paren Close paren
Comma-separated list of arguments
print("I am", 31, "years old")
![Page 43: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/43.jpg)
Poll: Print 1What does the following code print?
print("CSCI", 99 + 42, "at WWU")
A. CSCI141atWWUB. "CSCI 141 at WWU"C. CSCI 141 at WWUD. CSCI 99 + 42 at WWU
![Page 44: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/44.jpg)
How many arguments are there to the following call to the print function?
Poll: Print 2
print("CSCI", 99 + 42, "at WWU")
![Page 45: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/45.jpg)
Today: DataWhat is data, anyway?
![Page 46: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/46.jpg)
Today: DataWhat is data, anyway?
![Page 47: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/47.jpg)
Data Types
![Page 48: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/48.jpg)
Data Types• Different kinds of data are stored differently.
![Page 49: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/49.jpg)
Data Types• Different kinds of data are stored differently.
• All pieces of data have a type (sometimes also called class)
![Page 50: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/50.jpg)
Data Types• Different kinds of data are stored differently.
• All pieces of data have a type (sometimes also called class)
• We’ve seen 2 already:
• “Hello world!”
• 3 (as in 3 * 4 + 2)
![Page 51: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/51.jpg)
Data Types• Different kinds of data are stored differently.
• All pieces of data have a type (sometimes also called class)
• We’ve seen 2 already:
• “Hello world!”
• 3 (as in 3 * 4 + 2)
String (type str)
![Page 52: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/52.jpg)
Data Types• Different kinds of data are stored differently.
• All pieces of data have a type (sometimes also called class)
• We’ve seen 2 already:
• “Hello world!”
• 3 (as in 3 * 4 + 2)
String (type str)
Integer (type int)
![Page 53: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/53.jpg)
Data Types• Different kinds of data are stored differently.
• All pieces of data have a type (sometimes also called class)
• We’ve seen 2 already:
• “Hello world!”
• 3 (as in 3 * 4 + 2)
• Here’s another:
• 3.14
String (type str)
Integer (type int)
![Page 54: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/54.jpg)
Data Types• Different kinds of data are stored differently.
• All pieces of data have a type (sometimes also called class)
• We’ve seen 2 already:
• “Hello world!”
• 3 (as in 3 * 4 + 2)
• Here’s another:
• 3.14
String (type str)
Integer (type int)
Floating-point number (type float):a number with a decimal point
![Page 55: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/55.jpg)
Data Types: Why?
![Page 56: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/56.jpg)
Data Types: Why?• All pieces of data have a type (sometimes
also called class)
![Page 57: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/57.jpg)
Data Types: Why?• All pieces of data have a type (sometimes
also called class)
• Practical reasons:
![Page 58: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/58.jpg)
Data Types: Why?• All pieces of data have a type (sometimes
also called class)
• Practical reasons:
• Need to know how to store it in memory(how to encode it as 1’s and 0’s)
![Page 59: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/59.jpg)
Data Types: Why?• All pieces of data have a type (sometimes
also called class)
• Practical reasons:
• Need to know how to store it in memory(how to encode it as 1’s and 0’s)
• Need to know what you can do with it
![Page 60: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/60.jpg)
Data Types: Why?• All pieces of data have a type (sometimes
also called class)
• Practical reasons:
• Need to know how to store it in memory(how to encode it as 1’s and 0’s)
• Need to know what you can do with it • can you compute 10 + "Scott"?
![Page 61: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/61.jpg)
Data Types: Why?• All pieces of data have a type (sometimes
also called class)
• Practical reasons:
• Need to know how to store it in memory(how to encode it as 1’s and 0’s)
• Need to know what you can do with it • can you compute 10 + "Scott"?• what about 1.1 + 2?
![Page 62: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/62.jpg)
Data Types• How do you find out what type a piece of
data is?
• Just ask!
• Python has a function called type which tells you the type, or class, of any value.
![Page 63: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/63.jpg)
The type Function• The type function takes one piece of data (a
value) and gives back the type of the value.
• Examples:
type(16) <class ‘int’>
type(“CSCI 141”) <class ‘str’>
type(16.0) <class ‘float’>
Function call: Result:
16.0 is (mathematically) an integer, but the decimal point causes it to be interpreted as a float.
![Page 64: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/64.jpg)
Got that?What will be the result of calling:
A. <class ‘str’>
B. <class ‘float’>
C. <class ‘int’>
D. <class ‘String’>
type(1.2)
![Page 65: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/65.jpg)
Got that?What will be the result of calling:
A. <class ‘str’>
B. <class ‘float’>
C. <class ‘int’>
D. <class ‘String’>
type(“1.2”)
![Page 66: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/66.jpg)
Data Type Conversions• What if you have “1.4” (class str)
but you want 1.4 (class float)?
• Here are three more functions:
• Each tries to convert its argument to the given type, and throws an error if it’s not possible.
int()
float()
str()
![Page 67: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/67.jpg)
type and type conversions: demo
![Page 68: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/68.jpg)
Types and type conversions: demo
• int to int
• int to string
• float to int
• string to int
• string to float
![Page 69: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/69.jpg)
print and input• print can take any number of arguments, of
any type.
• Non-string arguments will be converted into strings
• Arguments are printed in sequence, separated by a space
• input can take zero or one arguments
• If given one argument, the argument is printed as a prompt before waiting for input.
![Page 70: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/70.jpg)
Advanced Print and Input: Demo
![Page 71: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/71.jpg)
Advanced Print and Input: Demo
• Print with multiple arguments, including non-strings
• Print with no arguments
• Input with a prompt
![Page 72: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/72.jpg)
Variables
![Page 73: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/73.jpg)
Variables• Variables are a basic component of all
programming languages
![Page 74: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/74.jpg)
Variables• Variables are a basic component of all
programming languages
• They simply allow you to store (or remember) values.
![Page 75: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/75.jpg)
Variables• Variables are a basic component of all
programming languages
• They simply allow you to store (or remember) values.
![Page 76: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/76.jpg)
Variables• Variables are a basic component of all
programming languages
• They simply allow you to store (or remember) values.
• Computers are pretty dumb, but they're really good at a few things, for example:
![Page 77: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/77.jpg)
Variables• Variables are a basic component of all
programming languages
• They simply allow you to store (or remember) values.
• Computers are pretty dumb, but they're really good at a few things, for example:
• arithmetic
![Page 78: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/78.jpg)
Variables• Variables are a basic component of all
programming languages
• They simply allow you to store (or remember) values.
• Computers are pretty dumb, but they're really good at a few things, for example:
• arithmetic
• remembering things
![Page 79: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/79.jpg)
Variables: Definition• A variable is a name in your program that
refers to a piece of data (or a value).
![Page 80: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/80.jpg)
Variables: Usage
![Page 81: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/81.jpg)
Variables: Usage• A variable is a name in your program that
refers to a piece of data (or a value).
• How do you use them?
![Page 82: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/82.jpg)
Variables: Usage• A variable is a name in your program that
refers to a piece of data (or a value).
• How do you use them?1. Decide what value you want to store in the variable
![Page 83: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/83.jpg)
Variables: Usage• A variable is a name in your program that
refers to a piece of data (or a value).
• How do you use them?1. Decide what value you want to store in the variable
31
![Page 84: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/84.jpg)
Variables: Usage• A variable is a name in your program that
refers to a piece of data (or a value).
• How do you use them?1. Decide what value you want to store in the variable
2. Decide on a sensible name
31
![Page 85: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/85.jpg)
Variables: Usage• A variable is a name in your program that
refers to a piece of data (or a value).
• How do you use them?1. Decide what value you want to store in the variable
2. Decide on a sensible name
31my_age
![Page 86: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/86.jpg)
Variables: Usage• A variable is a name in your program that
refers to a piece of data (or a value).
• How do you use them?1. Decide what value you want to store in the variable
2. Decide on a sensible name
3. In your program, use the assignment operator to assign that variable name to the value:
31my_age
![Page 87: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/87.jpg)
Variables: Usage• A variable is a name in your program that
refers to a piece of data (or a value).
• How do you use them?1. Decide what value you want to store in the variable
2. Decide on a sensible name
3. In your program, use the assignment operator to assign that variable name to the value:
31my_age =
![Page 88: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/88.jpg)
Variables: Usage• A variable is a name in your program that
refers to a piece of data (or a value).
• How do you use them?1. Decide what value you want to store in the variable
2. Decide on a sensible name
3. In your program, use the assignment operator to assign that variable name to the value:
31my_age =
The assignment operator.
![Page 89: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/89.jpg)
Variables: Usage31my_age =
The assignment operator.
![Page 90: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/90.jpg)
Variables: Usage
• For now, think of my_age as a named place where we can store any value.
• You can replace the current value with a different one:
31my_age =
The assignment operator.
![Page 91: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/91.jpg)
Variables: Usage
• For now, think of my_age as a named place where we can store any value.
• You can replace the current value with a different one:
31my_age =
The assignment operator.
32my_age =
![Page 92: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/92.jpg)
Variables: Usage
• For now, think of my_age as a named place where we can store any value.
• You can replace the current value with a different one:
31my_age =
The assignment operator.
32my_age =
![Page 93: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/93.jpg)
The Assignment Operator: Not “Equals”
• This is not stating an equality, like in math.
• It is associating a name with a value.
32my_age =
The assignment operator.
my_age = 31my_age = 32
(whiteboard) a simple diagram of what's happening here
![Page 94: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/94.jpg)
• Assigning a value is not stating an equality, like in math: it’s storing a value.
A variable’s value can be updated (overwritten) by a new value using the assignment operator.
Using Variables
my_age = 31my_age = 32
“my_age equals 32”
“my_age becomes 32”
“my_age gets 32”
“the variable my_age takes on the value 32”
![Page 95: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/95.jpg)
• Assigning a value is not stating an equality, like in math: it’s storing a value.
A variable’s value can be updated (overwritten) by a new value using the assignment operator.
Using Variables
my_age = 31my_age = 32
“my_age equals 32”
“my_age becomes 32”
“my_age gets 32”
“the variable my_age takes on the value 32”
![Page 96: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/96.jpg)
• Assigning a value is not stating an equality, like in math: it’s storing a value.
A variable’s value can be updated (overwritten) by a new value using the assignment operator.
Using Variables
my_age = 31my_age = 32
“my_age equals 32”
“my_age becomes 32”
“my_age gets 32”
“the variable my_age takes on the value 32”
![Page 97: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/97.jpg)
• Assigning a value is not stating an equality, like in math: it’s storing a value.
A variable’s value can be updated (overwritten) by a new value using the assignment operator.
Using Variables
my_age = 31my_age = 32
“my_age equals 32”
“my_age becomes 32”
“my_age gets 32”
“the variable my_age takes on the value 32”
![Page 98: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/98.jpg)
• Assigning a value is not stating an equality, like in math: it’s storing a value.
A variable’s value can be updated (overwritten) by a new value using the assignment operator.
Using Variables
my_age = 31my_age = 32
“my_age equals 32”
“my_age becomes 32”
“my_age gets 32”
“the variable my_age takes on the value 32”
![Page 99: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/99.jpg)
What can you do with variables?
Use them anywhere you’d use a value!
These two programs both print 5.
print(5) a = 5print(a)
![Page 100: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/100.jpg)
Variable Names
![Page 101: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/101.jpg)
Variable Names• How do you use variables?
1. Decide what value you want to store in the variable
2. Decide on a sensible name
3. In your program, use the assignment operator to store that value in the variable
![Page 102: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/102.jpg)
Variable Names• How do you use variables?
1. Decide what value you want to store in the variable
2. Decide on a sensible name
3. In your program, use the assignment operator to store that value in the variable
• Great power, great responsibility:variables names can be almost anything!
![Page 103: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/103.jpg)
Variable Names• Great power, great responsibility:
variables names can be almost anything!
• Valid variable names:
• start with a letter or an underscore ( _ )
• can contain any letters and digits
• are case-sensitive (name is not the same as Name)
• are not the same as any Python language keywords (words that already mean something else):
False, None, True, and, as, assert, async, await, break, class, continue, def, del, elif, else, except, finally, for, from, global, if, import, in, is, lambda, nonlocal, not, or, pass, raise, return, try, while, with, yield
2plus2True a_number firstOfThreeValues
![Page 104: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/104.jpg)
Variable Names• Great power, great responsibility:
variables names can be almost anything!
• Valid variable names:
• start with a letter or an underscore ( _ )
• can contain any letters and digits
• are case-sensitive (name is not the same as Name)
• are not the same as any Python language keywords (words that already mean something else):
False, None, True, and, as, assert, async, await, break, class, continue, def, del, elif, else, except, finally, for, from, global, if, import, in, is, lambda, nonlocal, not, or, pass, raise, return, try, while, with, yield
2plus2True a_number firstOfThreeValues
![Page 105: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/105.jpg)
Variable Names• Great power, great responsibility:
variables names can be almost anything!
• Valid variable names:
• start with a letter or an underscore ( _ )
• can contain any letters and digits
• are case-sensitive (name is not the same as Name)
• are not the same as any Python language keywords (words that already mean something else):
False, None, True, and, as, assert, async, await, break, class, continue, def, del, elif, else, except, finally, for, from, global, if, import, in, is, lambda, nonlocal, not, or, pass, raise, return, try, while, with, yield
2plus2True a_number firstOfThreeValues
![Page 106: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/106.jpg)
Variable Names• Great power, great responsibility:
variables names can be almost anything!
• Valid variable names:
• start with a letter or an underscore ( _ )
• can contain any letters and digits
• are case-sensitive (name is not the same as Name)
• are not the same as any Python language keywords (words that already mean something else):
False, None, True, and, as, assert, async, await, break, class, continue, def, del, elif, else, except, finally, for, from, global, if, import, in, is, lambda, nonlocal, not, or, pass, raise, return, try, while, with, yield
2plus2True a_number firstOfThreeValues
![Page 107: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/107.jpg)
Variable Names• Great power, great responsibility:
variables names can be almost anything!
• Valid variable names:
• start with a letter or an underscore ( _ )
• can contain any letters and digits
• are case-sensitive (name is not the same as Name)
• are not the same as any Python language keywords (words that already mean something else):
False, None, True, and, as, assert, async, await, break, class, continue, def, del, elif, else, except, finally, for, from, global, if, import, in, is, lambda, nonlocal, not, or, pass, raise, return, try, while, with, yield
2plus2True a_number firstOfThreeValues
![Page 108: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/108.jpg)
Variable Names• Great power, great responsibility:
variables names can be almost anything!
• A good variable name:
• is descriptive - tell a reader what data they refer to
• is not too long
• follows a standard naming convention, e.g.:
• starts with lower case letter
• words are separated by underscores
current_time hair_color
midterm_exam_grade_as_a_percent
a4
![Page 109: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/109.jpg)
Variable Names• Great power, great responsibility:
variables names can be almost anything!
• A good variable name:
• is descriptive - tell a reader what data they refer to
• is not too long
• follows a standard naming convention, e.g.:
• starts with lower case letter
• words are separated by underscores
current_time hair_color
midterm_exam_grade_as_a_percent
a4
![Page 110: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/110.jpg)
Variable Names• Great power, great responsibility:
variables names can be almost anything!
• A good variable name:
• is descriptive - tell a reader what data they refer to
• is not too long
• follows a standard naming convention, e.g.:
• starts with lower case letter
• words are separated by underscores
current_time hair_color
midterm_exam_grade_as_a_percent
a4
![Page 111: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/111.jpg)
Variable Names• Great power, great responsibility:
variables names can be almost anything!
• A good variable name:
• is descriptive - tell a reader what data they refer to
• is not too long
• follows a standard naming convention, e.g.:
• starts with lower case letter
• words are separated by underscores
current_time hair_color
midterm_exam_grade_as_a_percent
a4
![Page 112: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/112.jpg)
Variable Names• Great power, great responsibility:
variables names can be almost anything!
• A good variable name:
• is descriptive - tell a reader what data they refer to
• is not too long
• follows a standard naming convention, e.g.:
• starts with lower case letter
• words are separated by underscores
current_time hair_color
midterm_exam_grade_as_a_percent
a4
![Page 113: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/113.jpg)
Variable Names• Great power, great responsibility:
variables names can be almost anything!
• A good variable name:
• is descriptive - tell a reader what data they refer to
• is not too long
• follows a standard naming convention, e.g.:
• starts with lower case letter
• words are separated by underscores
current_time hair_color
midterm_exam_grade_as_a_percent
a4
these depend on context!
![Page 114: CSCI 141 - WWU Computer Science Faculty Web Pageswehrwes/courses/... · · CS Resume Workshop 5-6pm on Wednesday, October 2nd CF 115 Presented by Filip Jagodzinski, students questions](https://reader035.fdocuments.us/reader035/viewer/2022070809/5f07f7a17e708231d41fa931/html5/thumbnails/114.jpg)
Next time• More variables
• Operators
• Expressions
• Arithmetic