CSE 115 Introduction to Computer Science I Announcements Finish - - PowerPoint PPT Presentation

cse 115
SMART_READER_LITE
LIVE PREVIEW

CSE 115 Introduction to Computer Science I Announcements Finish - - PowerPoint PPT Presentation

CSE 115 Introduction to Computer Science I Announcements Finish module pre-lab *before* lab exam For each lab exam you have a second chance, after the next lab exam. Road map Review expressions/variables/assignment functions


slide-1
SLIDE 1

CSE 115

Introduction to Computer Science I

slide-2
SLIDE 2

Announcements

Finish module pre-lab *before* lab exam For each lab exam you have a second chance, after the next lab exam.

slide-3
SLIDE 3

Road map

▶︎ Review ◀ expressions/variables/assignment functions JavaScript on codenvy.io

slide-4
SLIDE 4

Review

Expressions Variables Assignment Defining functions: parameters, header, body Calling functions: arguments, returned value, environments Control flow: sequencing and selection (if/elif/else)

slide-5
SLIDE 5

Road map

Review ▶︎ expressions/variables/assignment ◀ functions JavaScript on codenvy.io

slide-6
SLIDE 6

JavaScript

expressions/variables/assignment

Simple expressions: Literals (null, true, false, numeric literal, string literal) All numbers are floating point.

slide-7
SLIDE 7

JavaScript

expressions/variables/assignment

Compound expressions: binary: expression operator expression unary: operator expression or expression operator

slide-8
SLIDE 8

JavaScript

expressions/variables/assignment

Some binary operators: arithmetic: +, -, *, /, %, ** string: + relational: <, <=, >, >=, ==, != Boolean (short circuiting): &&, ||

slide-9
SLIDE 9

JavaScript

expressions/variables/assignment

Some unary operators: arithmetic: +, - Boolean: !

slide-10
SLIDE 10

JavaScript

expressions/variables/assignment

Variables must be declared before use, and statements end with ';' var x; x = 13; var y = 17;

slide-11
SLIDE 11

Road map

Review expressions/variables/assignment ▶︎ functions ◀ JavaScript on codenvy.io

slide-12
SLIDE 12

JavaScript

defining and calling functions

Functions have same parts: header + body def area(w, h): return w * h function area(w, h) { return w * h; }

slide-13
SLIDE 13

JavaScript

defining and calling functions

keywords are different def area(w, h): return w * h function area(w, h) { return w * h; }

slide-14
SLIDE 14

JavaScript

defining and calling functions

Delimiters are different def area(w, h): return w * h function area(w, h) { return w * h; }

slide-15
SLIDE 15

Extra slide: this came up during class

Delimiter names ( ) are parentheses (singular: parenthesis) [ ] are brackets { } are braces The first of each pair is an opening or left delimiter, the second is a closing or right delimiter.

slide-16
SLIDE 16

Extra slide: this came up during class

Comments # This is a Python single-line comment // This is a JavaScript single-line comment /* This is a JavaScript comment that spans many lines. */

slide-17
SLIDE 17

Extra slide: this came up during class

Additional Operators

= == === && || ! & | ~ assignment equality under type conversion ("loose" equality) equality without type conversion ("strict" equality) logical AND logical OR logical NOT bitwise AND bitwise OR bitwise NOT

We'll explain these operators (and what we mean by type conversion) later.

slide-18
SLIDE 18

JavaScript

defining and calling functions

statement terminators needed in JavaScript* def area(w, h): return w * h function area(w, h) { return w * h; }

* While the language will allow semicolons to be omitted

sometimes, it is safer to always insert them. This avoids subtle and difficult to track down bugs which can otherwise occur.

slide-19
SLIDE 19

JavaScript

defining and calling functions

Functions calls look similar def area(w, h): return w * h x = area(3, 7) function area(w, h) { return w * h; } var x = area(3, 7);

slide-20
SLIDE 20

Printing

console.log( 3 * 5 ); print( 3 * 5 )

slide-21
SLIDE 21

Road map

Review expressions/variables/assignment functions ▶︎ JavaScript on codenvy.io ◀

slide-22
SLIDE 22

JavaScript

  • n codenvy.io

To code along: Create a workspace with 'node-defaut' stack Create custom run command with: commandLine: cd ${current.project.path} && node hello.js preview URL: http://${server.port.8000}