CS 105: Intro to Computing, Non-technical Craig Zilles (Computer - - PowerPoint PPT Presentation

cs 105 intro to computing non technical
SMART_READER_LITE
LIVE PREVIEW

CS 105: Intro to Computing, Non-technical Craig Zilles (Computer - - PowerPoint PPT Presentation

CS 105: Intro to Computing, Non-technical Craig Zilles (Computer Science) Al Harris (Computer Science) https://go.illinois.edu/cs105fa19 September 6, 2019 To Today 1. Goals of this course (and why) 2. Structure of this course (and why) 3.


slide-1
SLIDE 1

CS 105: Intro to Computing, Non-technical

Craig Zilles (Computer Science) Al Harris (Computer Science) September 6, 2019 https://go.illinois.edu/cs105fa19

slide-2
SLIDE 2

To Today

  • 1. Goals of this course (and why)
  • 2. Structure of this course (and why)
  • 3. Some Computer Basics
  • 4. Programming Language & Python Basics
  • 5. Muddiest Points
  • input/print, types, type conversion, syntax and other errors
  • 6. Challenge questions

2

slide-3
SLIDE 3

Wha What is Comput puter Scienc nce?

“Computers are to Computer Science what telescopes are to astronomy”

  • Edsger Dijkstra

Computer Science is concerned with understanding:

  • what is computable,
  • how to [specify computations, perform computations, communicate

between computers] in the [fastest, most reliable, most secure, cheapest/lowest power] way,

  • how to help humans solve problems with computers

3

slide-4
SLIDE 4

The learning g objectives for this course

4

slide-5
SLIDE 5

What is “Progr gramming”?

  • A series of instructions that can be

carried out by a computer

  • A really useful skill for many people
  • Useful to even know what is possible

http://www.programmingbasics.org/en/beginner/img/commands4.png

slide-6
SLIDE 6

Al Alternate Terms

“Programs” “Software” “Application” “Code”

But not "Codes" – it's always singular!

slide-7
SLIDE 7

Progr grams are everywhere

https://openclipart.org/

slide-8
SLIDE 8

Progr grams do many things gs

slide-9
SLIDE 9

Three parts of writing g a progr gram

Algorithms:

  • A step-by-step process for achieving a result
  • Often expressed in pseudo-code (instead of a programming language)
  • Avoid distraction of details
  • Increases generality

Programming:

  • Expressing commands in a form that the computer understands

Testing and Debugging:

  • Making sure that the program (always) does what is intended

9

slide-10
SLIDE 10

Making g a Peanut Butter & Jelly Sandwich (a randomly selected student algorithm)

  • Step 1: Collect your ingredients which include a butter knife, peanut

butter, jelly, and two slices of bread.

  • Step 2: Spread peanut butter evenly on one slice of bread
  • Step 3: Spread jelly evenly on the other slice of bread
  • Step 4: Bring the two slices together
  • Step 5: Cut the sandwich in half
  • Step 6: Enjoy

10

slide-11
SLIDE 11

Natural langu guage (Engl glish) is too ambigu guous

  • “I saw the man in the park with the telescope”
  • Who had the telescope?
  • Who was in the park?

11

slide-12
SLIDE 12
  • Open the bag of bread and obtain two pieces, leaving the top piece behind
  • Obtain two knives from the kitchen
  • Open the jar of peanut butter using a twisting motion
  • Lay the lid aside for now
  • Using one knife, obtain a reasonable amount of peanut butter and spread evenly on one side of one

bread piece

  • Be gentle so that the bread does not deform
  • lay the bread piece on the counter with the peanut butter side facing up
  • Then discard the knife and close the jar of peanut butter
  • Open the jar of jelly and put the lid aside
  • Take second knife and pick up a reasonable about of jelly from the jar
  • Like with the peanut butter, spread the jelly over one side of the other piece of bread
  • Be gentle with your spreading strokes
  • Lay the bread piece on the counter, jelly side up
  • Discard the knife, and close the jelly jar using its original lid
  • Now, take the bread piece with the jelly, and press it against the piece with the butter
  • The peanut butter and jelly sides should be facing each other and the clean sides should be facing
  • ut
  • Voila! You have just made a peanut butter and jelly sandwich

12

slide-13
SLIDE 13

Ke Key Idea: Progr gramming g langu guages are design gned to be exact and unambigu guous

  • Everything in a programming language has a precise form (syntax) and

a precise meaning (semantics)

  • Syntax: Rules of what are acceptable programs
  • Semantics: Rules specifying what a program does
  • This need for exactness is challenging for many novices.

13

slide-14
SLIDE 14

Al Also, this stuff is totally arbitrary!

  • Computers and programming languages are human made
  • There is no reason that you should know any of this stuff if you

haven’t seen it before

  • People in this class that seem “smarter” have probably seen it before
  • The easiest bugs to find in your code are the ones that you made

before

  • There is no short cut around making mistakes

14

slide-15
SLIDE 15

St Stru ructure of

  • f t

this c cou

  • urse
  • The book
  • Pre-lecture activities
  • Lecture
  • Homework
  • Labs
  • Quizzes and Exams

15

slide-16
SLIDE 16

What is known about teaching g and learning g (1)

  • 1. No one can pay attention for 100 continuous minutes
  • We’ll have a 10 minute break in the middle of lecture
  • Please try to focus the rest of the time
  • 2. “Time on task” is a primary factor of how much gets learned.
  • My job, give you productive things to spend time on
  • 3. One learns much more by doing than by reading or listening.
  • You have to expend mental energy or it doesn’t stick

16

slide-17
SLIDE 17

What is known about teaching g and learning g (2)

  • 4. The things you can most efficiently learn are:
  • Those related to things that you already know
  • Those that are only slightly harder than the things you can currently do
  • 5. Long term retention comes from repeated, distributed practice
  • Retention comes from cycles of forgetting and re-learning
  • Spaced in time; cramming doesn’t work for long term retention

17

slide-18
SLIDE 18

Gr Growth th M Min indset

18

slide-19
SLIDE 19

Teaching g by diminishing g deception

  • Computers (like many things) are too complicated to understand all at
  • nce.
  • I’m going to glaze over unnecessary details until we’re ready for them
  • Feel free to ask questions, but I might defer some for after class / during

break

19

slide-20
SLIDE 20

St Stru ructure of

  • f t

this c cou

  • urse
  • The book
  • Pre-lecture activities
  • Lecture
  • I clickers, participation encouraged, ask questions, recorded
  • Homework
  • Labs
  • Quizzes and Exams

20

slide-21
SLIDE 21

We Weekly cycle:

  • each topic covered over a two week period
  • Book activities, Pre-lectures have strict deadlines
  • Homework has late deadline for 70% credit.
  • Lecture/Lab allows 2 excused/unexcused absences

21

Lecture M Tu Th W F Sa Su M Tu Th W F Sa Su M Tu W Read Book (Participation) Pre-Lecture Book (Challenge) Homework Lab

slide-22
SLIDE 22

We Weekly cycle:

22

Lecture M Tu Th W F Sa Su M Tu Th W F Sa Su M Tu W Read Book (Participation) Pre-Lecture Book (Challenge) Homework Lab Lecture Read Book (Participation) Pre-Lecture Book (Challenge) Homework Read Book (Participation) Pre-Lecture

slide-23
SLIDE 23

The homework plagi giarism/collaboration po policy in n CS 105 is:

Ic Iclicker ques questi tion: n: sel elect ect the the bes best t ans answer er

A) It is okay to hire random internet strangers to do all of your homework for you. B) You must do all of your homework alone (not even TAs can help) C) You can get any help you want as long as you type in the answers D) Students can only discuss the homework at a high level; code must not be shown to other students, but you can ask TAs for help E) Assignments can be done in groups of two students

23

slide-24
SLIDE 24

Fo Formative vs. Summative Assessment

  • Practice / Formative Assessment:
  • Primarily intended for learning, self-evaluation
  • CS 105: Participation/Challenge, Pre-lecture activities, Homework
  • You may get help from anyone, but you have to enter the solution
  • Summative Assessment:
  • An evaluation of how much has been learned
  • CS 105: Quizzes and Exams
  • To be done by yourself; you may not get help from anyone

24

slide-25
SLIDE 25

Qu Quizzes and Exams ms (all all to be e done e by yourself elf)

  • Four mid-term exams in the Computer-Based Testing Facility (CBTF):
  • Sign-up at https://cbtf.engr.illinois.edu/sched
  • 3-day window: Thursday – Saturday
  • 50 minutes
  • Four quizzes (basically required practice exams)
  • 50 minutes timed, self-proctored, wherever you want to take them.
  • Same 3-day window
  • One three-hour final exam in the CBTF

25

slide-26
SLIDE 26

An Announcements: see course web page

  • The spatial assessment is due at midnight tonight; please get it done
  • If you didn’t finish the reading/pre-lecture, deadline extended to Mon.
  • If you completed Lab Setup, you have no lab next week
  • If you haven’t completed Lab Setup or want help
  • Go to any lab section on Tuesday or Wednesday next week
  • You can sign up for the first exam now
  • We’re going to give up to 2% extra credit for the ~20 students that have

the most Piazza answers marked as good answers.

26

slide-27
SLIDE 27

Comp Computer r basics: ma major

  • r part

rts

27

slide-28
SLIDE 28

Mo Modern CPUs like those in laptops, tablets, and phones ex execute how many instructions per second:

Ic Iclicker ques question: n: sel elec ect the he bes best ans nswer er

A) Thousands B) Millions C) Billions D) Trillions E) Quadrillions

28

slide-29
SLIDE 29

Comp Computers are:

Ic Iclicker ques question: n: sel elec ect the he bes best ans nswer er

A) Smart B) Not smart

29

slide-30
SLIDE 30

Comp Computers are ru run very low-le level el in instr tructio tions

  • Things like:
  • Move a number from one storage location to another
  • Add two numbers together
  • Check if one number is larger than another
  • Go to a different place in the code
  • Computers can be programmed at this level, but
  • It is very tedious and error prone
  • You have to write a lot of code to do anything significant
  • This code isn’t portable across different processor types (e.g., laptops vs phones)

30

slide-31
SLIDE 31

High gh-level Langu guages (& Python)

  • HLLs: productive, safer, portable
  • Python: very useful language, gentle learning curve
  • Once you learn one language, much easier to learn others (same concepts)
  • Python2 vs. Python3
  • Interpreted language
  • Three ways to run the Python interpreter (at least)
  • Interpreter, Jupyter notebook, and running scripts from the command line

31

slide-32
SLIDE 32

(I (In Python) ) x + y is is: Ic

Iclicker ques question: n: sel elec ect the he bes best ans nswer er

a) an assignment b) a statement c) a variable d) an expression e) a comment

33

slide-33
SLIDE 33

Py Python values have ve types

  • We’ve met two kinds so far:
  • Strings: e.g., our string literals like “Hello CS 105!”
  • Integers: whole numbers of arbitrary precision
  • You can ask a value what its type is using: type(expression)
  • You can convert between them with str() and int()
  • It is important that you keep track of the types of your values!

34

slide-34
SLIDE 34

35

A E D C B

Whe Where do does Pytho hon n run un on n the he comput puter?

Ic Iclicker ques question: n: sel elec ect the he bes best ans nswer er

slide-35
SLIDE 35

The The input() fu function gets s use ser input

  • Can take a string as an argument to be used as a prompt
  • Returns a string

36

slide-36
SLIDE 36

The The print() fu function

  • Assuming there is a variable x with the value 7, which of the following

statements prints: count = 7 A) print(“count =” value) B) print(“count =”, end=“value”) C) print(“count =”, value) D) print(“count =” + value) E) print(“count = $value”)

37

slide-37
SLIDE 37

Test often to minimize debuggi ging g time

  • Write at most a few lines of code before testing!
  • If you made a mistake, the problem must be in those few lines
  • Biggest novice mistake: write a lot of code before testing any of it
  • When it doesn’t work, it takes a long time to find the bug

38

slide-38
SLIDE 38

Getting g help from Python

  • Use the help function in the Python interpreter. E.g.,

help(print) help(input)

39

slide-39
SLIDE 39

Ot Othe her Muddi uddiest Points

  • Also, are we supposed to press "enter" after every line we do? Some

practice activities were requiring it and others were not so I was confused.

  • When should one use double quotes instead of a single quote?

40

slide-40
SLIDE 40

Ch Challenge Qu Question

  • ns: con
  • ncepts needed
  • Printing string literals:

print(‘string literal inside quotes’)

  • Knowing that by default print outputs a new line
  • You can use multiple print statements to print multiple lines
  • User input can be assigned to variables:

var_name = input()

  • Input can be converted to integers:

int_var_name = int(input())

  • Integers can be added and multiplied:

var1 + var2 and var1 * var2

  • Expressions can be printed:

print(number1 – 13)

41