CSC 1701B Computing: Science and Creativity. Outline  Types  Variables  Operators  Control: sequence, selection, repetition  Functions (block headings.

Slides:



Advertisements
Similar presentations
JavaScript I. JavaScript is an object oriented programming language used to add interactivity to web pages. Different from Java, even though bears some.
Advertisements

Introduction to Macromedia Director 8.5 – Lingo
Programming with App Inventor Computing Institute for K-12 Teachers Summer 2012 Workshop.
CATHERINE AND ANNIE Python: Part 3. Intro to Loops Do you remember in Alice when you could use a loop to make a character perform an action multiple times?
String and Lists Dr. Benito Mendoza. 2 Outline What is a string String operations Traversing strings String slices What is a list Traversing a list List.
Mr. Wortzman INTRO. TO COMPUTER SCIENCE. UNIT 1 – CUSTOM BLOCKS.
Designing Algorithms Csci 107 Lecture 4. Outline Last time Computing 1+2+…+n Adding 2 n-digit numbers Today: More algorithms Sequential search Variations.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie July 5, 2005.
1 Objectives You should be able to describe: Relational Expressions The if-else Statement Nested if Statements The switch Statement Common Programming.
Lecture 7 Sept 17 Goals: Complete Chapter 4 Chapters 5 and 6.
COMP 14 Introduction to Programming Miguel A. Otaduy May 20, 2004.
Precedence Parentheses Arithemetic ^ * / + - (exception logical not ~ ) Relational > =
COMP 110 Introduction to Programming Mr. Joshua Stough September 24, 2007.
Programming Concepts MIT - AITI. Variables l A variable is a name associated with a piece of data l Variables allow you to store and manipulate data in.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Ten String Manipulation and Menus.
Chapter 4 MATLAB Programming Combining Loops and Logic Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Working with Numbers in Alice - Converting to integers and to strings - Rounding numbers. - Truncating Numbers Samantha Huerta under the direction of Professor.
Institute for Personal Robots in Education (IPRE)‏ CSC 170 Computing: Science and Creativity.
ECS 10 10/8. Outline Announcements Homework 2 questions Boolean expressions If/else statements State variables and avoiding sys.exit(…) Example: Coin.
CS190/295 Programming in Python for Life Sciences: Lecture 3 Instructor: Xiaohui Xie University of California, Irvine.
UC Berkeley EECS Sr Lecturer SOE Dan Garcia printing-aims-to-prevent-a-piracy-plague/ Quest.
Java Programming: From Problem Analysis to Program Design, Second Edition1 Lecture 4 Objectives  Learn about repetition (looping) control structures.
More on Input Output Input Stream : A sequence of characters from an input device (like the keyboard) to the computer (the program running). Output Stream.
Institute for Personal Robots in Education (IPRE)‏ CSC 170 Computing: Science and Creativity.
2 Objectives You should be able to describe: Relational Expressions Relational Expressions The if-else Statement The if-else Statement Nested if Statements.
The role of data mining in the last presidential election. A mind-blowing piece on how the Obama campaign used various sources of data to target voters.
Summer Computing Workshop. Introduction  Boolean Expressions – In programming, a Boolean expression is an expression that is either true or false. In.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
CSC 110 Using Python [Reading: chapter 1] CSC 110 B 1.
CS161 Topic #16 1 Today in CS161 Lecture #16 Prepare for the Final Reviewing all Topics this term Variables If Statements Loops (do while, while, for)
Introduction to Strings Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg 1.
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
HTML, Third Edition--Illustrated Brief 1 HTML, Third Edition Illustrated Brief Unit C Formatting Page Elements with HTML.
Python Let’s get started!.
INTRODUCTION TO MATLAB DAVID COOPER SUMMER Course Layout SundayMondayTuesdayWednesdayThursdayFridaySaturday 67 Intro 89 Scripts 1011 Work
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Fluency with Information Technology Third Edition by Lawrence Snyder Chapter.
Introduction to Computer Programming - Project 2 Intro to Digital Technology.
LISTS. LEARNING OBJECTIVES Create a block that accepts a parameter Create a block that returns a value Create scripts that manipulates lists Incorporate.
Language Find the latest version of this document at
CS190/295 Programming in Python for Life Sciences: Lecture 6 Instructor: Xiaohui Xie University of California, Irvine.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Tevfik Bultan Lecture 4: Introduction to C: Control Flow.
UC Berkeley EECS Sr Lecturer SOE Dan Garcia printing-aims-to-prevent-a-piracy-plague/ Quest.
CS 104 – Fall 2011 Exploring Computer Science Build Your Own Blocks September 19, 2011.
Loops and Arrays Chapter 19 and Material Adapted from Fluency Text book.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
String and Lists Dr. José M. Reyes Álamo. 2 Outline What is a string String operations Traversing strings String slices What is a list Traversing a list.
UC Berkeley EECS Lecturer SOE Dan Garcia The success of Apple’s Siri (only available on the iPhone 4S) has sparked competition, to be sure. Google’s IRIS.
CS10 The Beauty and Joy of Computing Lecture #4 : Functions UC Berkeley EECS Lecturer SOE Dan Garcia Researchers at Microsoft and UW are working.
UC Berkeley EECS Sr Lecturer SOE Dan Garcia Valve (video game makers of Half-Life) believes the future of video games may not be in the input device (ala.
1 COMS 261 Computer Science I Title: C++ Fundamentals Date: September 23, 2005 Lecture Number: 11.
String and Lists Dr. José M. Reyes Álamo.
Chapter 5: Control Structures II
Madlib-Input, Strings, and Lists in Scratch
Python Let’s get started!.
Big-O notation Linked lists
The Beauty and Joy of Computing Lecture #4 Functions
Intro to CS Sept 22/23, 2015.
Chapter 5: Control Structures II
Variables and Arithmetic Operations
Chapter 17 JavaScript.
© Akhilesh Bajaj, All rights reserved.
Scratch: selection / branching/ if / If…else / compound conditionals / error trapping by Mr. Clausen.
CS190/295 Programming in Python for Life Sciences: Lecture 6
Types, Truth, and Expressions (Part 2)
T. Jumana Abu Shmais – AOU - Riyadh
String and Lists Dr. José M. Reyes Álamo.
Computer Science Core Concepts
EECE.2160 ECE Application Programming
Types, Truth, and Expressions
Introduction to Strings
Presentation transcript:

CSC 1701B Computing: Science and Creativity

Outline  Types  Variables  Operators  Control: sequence, selection, repetition  Functions (block headings will be given)  Lists

Types  Character  Single character like A 5 or $  Digit  0 through 9 only  Number   Word  1 or more characters, no space A_word Cat  Sentence  One or more words with spaces

Variables and Scripts  Names that can store values that change  May be global (known everywhere) like this:  Or a script variable known only in that script

Operators  Some operators only allow digits or numbers + - x / mod round  Some operators allow many types  BTW, case does not matter  Others allow a mix of types

Control  Sequential  one block call after another  Selection  if if…else  Repetition  repeat until for  Selection and repetition can be nested  You won’t need to write nested control on the Midterm

Functions  Functions take in 0 or more inputs and return exactly 1 output  The same inputs MUST yield same outputs  Output function of input only  Other rules of functions  No state (prior history)  No mutation (no variables get modified)  No side effects (nothing else happens) CS Illustrated function metaphor

 Domain  The type “class” of input a function accepts  Examples  Sqrt of  Positive numbers  Length of  Sentence, word, number  _ < _  Both: Sentence, word, number  _ and _  Booleans  Letter _ of _  Number from 1 to input length  Sentence, word, number  Range  All the possible return values of a function  Examples  Sqrt of  Non-negative numbers or Nan  Length of  Non-negative integer  _ < _  Boolean (true or false)  _ and _  Boolean (true or false)  Letter _ of _  Letter More Terminology (from Math)

Why use functions? (1) The power of generalization!

Why use functions? (2)  Functions can be composed together to make even more magnificent things  Functions are the building blocks of almost everything we create when programming  Functional decomposition: the process of breaking big problems down into smaller tasks

 Command  No outputs  Meant for side-effects  Not a function…  Not on Midterm  Reporter (Function)  Any type of output  Predicate (Function)  Only Boolean output  (true or false)  You will not need to write any block headings on the MidTerm Types of Blocks

 You will be asked to complete blocks on the midterm, given the block heading  Example: Complete this custom block to return the smaller of two values: write the text, use ( and ) if (a < b) set smaller to a else set smaller to b report smaller Writing Snap! On Paper

 would be written as ((a > b) and (a < 999))  Practice test question shows how to write Snap! Writing Snap! On Paper

We often need to store a collection of items Snap! has the list block Found under Variables The following list has 3 elements It is considered an anonymous list as it has no nameno name Lists 14

 By default, a list has 1 item that is an empty word  To create an empty list, click the left arrow to remove it New lists can have one nothing ITEM 15

A named list with 3 elements 16  Give a name to an “empty” list, add 3 names  Show all, first, last, and any element in the list known as names names is a list with zero elements

Other blocks you may need 17  These will be added to the question ifthey will be needed (no need to memorize Snap blocks)  length is # items in the list  add adds at the end  insert places a new thing at the given index 1..length  delete removes the thing at the given index

 No need to memorize blocks  You will see needed blocks in other questions on the Midterm  Or they will be given for that problem  Give a preview of the practice test And finally