Scripting with Praat. Day 3: Make Praat make decisions for you! 1

Size: px
Start display at page:

Download "Scripting with Praat. Day 3: Make Praat make decisions for you! 1"

Transcription

1 Scripting with Praat Day 3: Make Praat make decisions for you! 1

2 Housekeeping Please sign your name on this sheet and indicate Audit, P/F or letter grade Office Hours: moved to Library basement still Tuesday 5-6 and Thursday 4-5 2

3 Homework 1 Review Record yourself saying Hello, world! in any language that you like and save to a.wav file on your computer. Write a Praat script to read in this wav file and paint a spectrogram of this sound in the Picture window (please show 0 to 8000Hz). Let Praat garnish this spectrogram. Add a title to the figure of the form: Hello, world! in <X language> spoken by <your name> Calculate mean F0 of the sound file (hint: Pitch object) and print the text Mean F0 = <###> Hz below the plot (don t overlap the axis label!) Begin the script with a comment that gives your name and a brief description of what the script is meant to do. Hand in the script file (YourFullName.praat), your wav file, and a PDF of the spectrogram on Canvas. 3

4 Homework 1 solution: this works sound = Read from file: "/Users/penelope/Desktop/untitled.wav" sgram = To Spectrogram: 0.005, 8000, 0.002, 20, "Gaussian" Paint: 0, 0, 0, 8000, 100, "yes", 50, 6, 0, "yes" Text top: "no", """Hello, world!"" in Malagasy spoken by Penelope" selectobject: sound pitch = To Pitch: 0, 75, 600 f0 = Get mean: 0, 0, Hertz" f0$ = string$(f0) Text bottom: "no", "Mean f0 = " + f0$ + " Hz" Save as PDF file: "/Users/penelope/Desktop/helloworld.pdf" 4

5 Homework 1 solution: this is greatly improved # hw1-key.praat Paint a publishable spectrogram # Reads in a wav file, creates and paints a spectrogram of the sound, adds a meaningful title, # finds mean F0 of the sound and prints this value below the spectrogram, and saves a PDF file. # Penelope Howe <penelopehowe@gmail.com> # clean up the Picture window in case previous material was present Erase all # load sound file to unique Object ID variable and create spectrogram from sound file sound = Read from file: "/Users/penelope/Desktop/untitled.wav" sgram = To Spectrogram: 0.005, 8000, 0.002, 20, "Gaussian" # select the region of the Picture window to draw to Select outer viewport: 0, 6, 0, 4 # paint spectrogram (note: it was selected implicitly when it was created) and add title Paint: 0, 0, 0, 8000, 100, "yes", 50, 6, 0, "yes" Text top: "no", """Hello, world!"" in Malagasy spoken by Penelope Howe" # create Pitch object to get mean F0 (note: must select the Sound object first. why??) selectobject: sound pitch = To Pitch: 0, 75, 600 f0 = Get mean: 0, 0, "Hertz" # display F0 to 0 decimal places (note: fixed$( ) function returns a string value) f0$ = fixed$(f0, 0) Text bottom: "no", "Mean f0 = " + f0$ + " Hz" Save as PDF file: "/Users/penelope/Desktop/praat.pdf" # remove the objects we just created (note: avoid Remove all command. why??) removeobject: sound, sgram, pitch 5

6 Syntax Review 1 1. Text top: "no", """Hello, world!"" in Malagasy What does no mean? Will it work without quotes? What error will we get? Why? Boolean args have two alternatives: no$ = no Text top: no$, """Hello, world!"" in Malagasy no = 0 Text top: no, """Hello, world!"" in Malagasy What s going on with all the quotes in the 2nd argument? 6

7 Syntax Review 2 1. f0$ = 150 Text bottom: no, "Mean f0 = " + f0$ + " Hz What are the pluses for? Could we replace them with commas and why? Can we use a numeric variable ( f0 ) instead of f0$? 2. f0 = 150 writeinfoline: Mean f0 =, f0, Hz So how come commas are legal in this example? How come we can use a numeric variable in this example? What else do we have to change if we want to replace these commas with pluses? 7

8 Using Variables to Improve Readability/Flexibility Remember this: no = 0 Text top: no, """Hello, world!"" in Malagasy Why might we want to do this? 1) Variables help you remember what arguments refer to: # sgram = To Spectrogram: 0.005, 8000, 0.002, 20, Gaussian window_len = ; window length (broadband vs. narrowband) max_freq = 8000 ; maximum frequency analyzed time_step = ; time step freq_step = 20 ; frequency step win_shape$ = Gaussian sgram = To Spectrogram: window_len, max_freq, time_step,... freq_step, win_shape$ 8

9 Using Variables to Improve Readability/Flexibility Remember this: no = 0 Text top: no, """Hello, world!"" in Malagasy Why might we want to do this? 2) Variables also help you conveniently modify script function: # Select outer viewport: 0, 6, 0, 4 plot_x1 = 0 plot_x2 = 6 plot_y1 = 0 plot_y2 = 4 Select outer viewport: plot_x1, plot_x2, plot_y1, plot_y2 9

10 Exercise: fun with objects, selections, variables Use an existing short sound file or record a new one and save it to your Desktop. Remove it from the Objects window. Do the following in a script: 1. Store the directory path and file name of your sound file in a variable and read the sound file into Praat 2. Save the total duration of the sound file to a variable 3. Use ( Convert -> Lengthen ) to create a longer version of your original sound (how much longer is up to you) 4. Get the total duration of your new sound, and print the durations of each sound and the ratio between them to the Info window, to verify that the Lengthen function worked as expected 5. Create a TextGrid of your original sound (default settings fine) 6. Store the directory path and file name for the TextGrid to another variable by modifying the sound filename variable 7. Save the TextGrid to the same location as the sound file 8. Remove both the original Sound and the TextGrid from the Objects window 10

11 A solution: fun with objects, selections, variables # load sound file and store total duration sfilename$ = "/Users/penelope/Desktop/tone.wav" Read from file: sfilename$ sound = selected("sound") dur_orig = Get total duration # create new file with double the length, get new duration and ratio Lengthen (overlap-add): 75, 600, 2 dur_long = Get total duration dur_ratio = dur_long / dur_orig # print duration info to Info window writeinfoline: "The original duration is ", dur_orig, "s." appendinfoline: "The new duration is ", dur_long, "s." appendinfoline: "Duration increased by a factor of, dur_ratio,. #create TextGrid from original sound, make filename and save selectobject: sound To TextGrid: "Mary John bell", "bell" tgfilename$ = (sfilename$ -.wav ) + ".TextGrid" Save as text file: tgfilename$ # TextGrid is already selected, add original sound to selection, remove both plusobject: sound Remove 11

12 Conditional Statements 12

13 Making decisions Sometimes we need a program to perform different actions depending on input or outcomes of calculations As in natural language, in programming we call the expressions that introduce multiple possible worlds conditionals The simplest form of a conditional has the following structure: # note, this is not in any particular programming # language. This is an example of pseudocode. if <test> commands to execute if the test returns true endif 13

14 Making decisions Here's an example with real Praat code: # what does this code do when executed? if 7 > 9 writeinfoline: "hello, world!" endif # what about this? if hello > goodbye writeinfoline: "hello, world!" endif 14

15 if, elsif, else, endif Praat has four reserved words (i.e., don t use them for anything else, like variable names) set aside for conditional expressions: if introduces a conditional, must include a test condition. elsif / elif allows for the inclusion of another possible true outcome, in case the if condition was false ( Note the spelling, this is not a typo! ) else if none of the preceding tests returned true, execute this block of code endif ends the conditional statement 15

16 Layout best practices (manual) Notice the indentation: if 7 >= 9 # we have dropped through a wormhole into # a parallel (and inconsistent) universe writeinfoline: "hello, not our world!" else # the physical laws of our universe apply writeinfoline: "hello, world!" endif People typically use either a tab or 2 to 4 spaces (or sometimes more) to indent lines inside a block (programmers love to debate about using tabs vs. spaces) Blocks within blocks ( nested blocks) are further indented Most importantly, BE CONSISTENT! 16

17 Layout: where does white space matter? Praat IGNORES white space in the following places: At the beginning of any line of code (you can press space or tab as many times as you want) Completely blank lines (use blank space to separate chunks of code to make your script more readable) Between comma-separated arguments, within mathematical expressions, between and function and the parentheses containing its arguments (again, use spaces to make it readable) White space tells Praat where word boundaries are, so it is critical: To separate words within and at the end of a command name Text top: NOT Texttop: Text top: no NOT Text top: no As a literal character within strings 17

18 Conditional example # get F0 at a fixed time point, and if it is defined, # give its value relative to 150 Hz. selectobject: Pitch tone f0 = Get value at time: 0.01, Hertz, Linear writeinfoline: f0 =, f0 if f0 = undefined ; Notice NOT --undefined-- appendinfoline: F0 is undefined. Check measurement. elsif f0 = 150 appendinfoline: "F0 is exactly 150 Hz." elsif f0 < 150 appendinfoline: "F0 is less than 150 Hz." else appendinfoline: "F0 is greater than 150 Hz." endif appendinfoline: "wasn't that fun?" 18

19 Unknown Variable Praat will give you an "Unknown variable" error if you try to use a variable before you declare it. You will see this if you try either of the following: y = m * x + b text$ = "Please say what this word is " + bit$ 19

20 Declaring Variables The way around this problem is to always declare each variable prior to using it. We could fix our line formula with something like: deltax = 2 deltay = 4 b = 1 m = deltay / deltax x = 8 y = m * x + b writeinfoline: "y equals ", y, " when x is ", x 20

21 Unknown Variable Example You'll also get this Unknown Variable error if you try to use a variable in a test (conditional) prior to assigning it any value, e.g. # generates an error if variable$ = "" writeinfoline( "Variable has not been set yet" ) else writeinfoline( "It exists and it is """, variable$,"""" ) endif 21

22 Pseudocode script outlining Use comments and/or pseudocode to write an outline before you attempt to implement With more complicated scripts, it will be important to outline the flow of the script first flow control = conditionals, loops (next week), procedures (later), etc., which tell Praat which chunks of code to execute in what order 22

23 Pseudocode script outlining (NOT a real script!) # measure phonetic characteristics according to segment type for all TextGrids in given directory select the TextGrid tiername$ = Get name of first tier if tiername$ = fricative get start and end times of the labeled interval select the associated Sound measure things related to fricatives in that interval... use more elsif statements for other cons. types else ; it must be a vowel measure things related to vowels in that interval endif... repeat these for the 2nd tier in the TextGrid endfor 23

24 Exercise: Random Test Praat has a function randominteger(min, max) which is essentially telling Praat to pick a number between min and max (inclusive). e.g. randominteger(1, 10) could be read "pick a number from 1 to 10". Please write a script to: 1. Generate a random number between 1 and 10 and store it in a numeric variable. 2. Test whether this number is greater than or equal to 6. If so, write "The number was 6 or higher." to the Info window. 3. If the number is not equal to or greater than 6, write "Your number was 5 or lower." to the Info window. 24

25 Using functions Functions perform some action on their input, report some fact about that input, or give some value calculated from that input (some functions also take multiple inputs) Like commands, each function expects inputs of a certain type (numeric or string) in a designated order, separated by commas and contained within parentheses Each function returns either a string or a numeric value, indicated by presence or absence of $ in the function name Already seen some examples: string$(), number(), fixed$() 25

26 Using functions: example Praat has a length() function that simply determines and returns the length of a single string argument string$ = "what has it got in its pocketses?" length = length( string$ ) writeinfoline: "The string '", string$, "' is ", length,..." characters long." 26

27 Test expressions The test expression in a conditional ( the expression following if or elsif ) evaluates to a boolean true or false: 0 = false, other numbers = true You can verify this yourself with something like: n = -4 if n writeinfoline( "true!" ) endif We can also take advantage of this fact to use functions in conditionals... 27

28 Testing functions For example, to test if a file is a wav file or a TextGrid, you could write: if endswith( filename$, ".wav" ) # file is a wav, do sound file things to it #... elsif endswith( filename$, ".TextGrid" ) # file is a TextGrid, do TextGrid file things to it #... else # file is neither (or the case didn't match or typo, etc.) #... endif # endswith(): compares second string to end of first string, if they match, returns true (1), if they don t match, returns false (0) 28

29 Available functions The Praat documentation lists the available functions: Mathematical functions ( manual: Formulas 4 ) String functions ( manual: Formulas 5 ) 29

30 Predefined variables Praat comes with a number of pre-defined variables and constants, some of them are: Numeric: praatversion stores the current version of Praat you are running. macintosh, windows, and unix are true (1) if you are on that platform. pi, e, and undefined ( manual: constants ) String: praatversion$ version of Praat as a string. newline$, tab$ store your platform's take on newline and tab. defaultdirectory$ is the path containing the script file. homedirectory$, preferencesdirectory$, and temporarydirectory$ provide useful directory paths (manual). 30

31 Exercise: digits of π How many digits of π does Praat's constant give you? Input: Praat's pi constant Output: Info window should read: Praat stores pi to N decimal places. where 'N' is replaced with the correct number of decimal places. Hint: Praat will give you a number, but you probably want to work with it as a string. 31

32 Exercise: behavior of functions 1. Without hard-coding any numbers into your script, use string functions to do the following: From input string Welcome to the linguistics institute Produce the output string Welcome to the lingstitute 2. Use numeric and string functions to find for which vowel quality this speaker has maximum and minimum f0 values and the values themselves, given the following inputs: f0_a = 104 ; f0 for /a/ vowel onset f0_e = 110 ;... /e/ f0_o = 109 ;... /o/ f0_i = 117 ;... /i/ f0_u = 115 ;... /u/ order$ = aeoiu # Output: The speaker's minimum f0 is ## Hz on vowel /V1/. # The speaker s maximum f0 is ## Hz on vowel /V2/. 32

Scripting with Praat. Day 5: One loop to rule them all!

Scripting with Praat. Day 5: One loop to rule them all! Scripting with Praat Day 5: One loop to rule them all! 1 Praat manual index If you're having trouble finding the topic you want in the Praat manual because you don't know exactly what to search for, go

More information

Scripting 1. Your first scripts

Scripting 1. Your first scripts Scripting 1. Your first scripts Jan 3, 2011 Scripting 1. Your first scripts This page tells you how to create, run and save a script. To get a feel for how it works, you are advised to try out all the

More information

Scripting with Praat. Day 7: Praat Goodies

Scripting with Praat. Day 7: Praat Goodies Scripting with Praat Day 7: Praat Goodies 1 Forms ( manual ) Forms allow your script to ask for user input at the beginning of runtime You will use the form/endform reserved words to enclose a form block

More information

3.1. Peeping into the matrix Praat objects' attributes

3.1. Peeping into the matrix Praat objects' attributes Session 3 (09:00 13:00, Thurs.): Advanced Praat usage Peeping into the matrix: Praat objects' attributes; using attributes in formulas. Pimp my Praat: changing Praat's default settings, menus and buttons;

More information

Scripting with Praat. Day 8: More Goodies and the Way Forward

Scripting with Praat. Day 8: More Goodies and the Way Forward Scripting with Praat Day 8: More Goodies and the Way Forward 1 Today Note on arrays Regular expressions Editor scripts and extending Praat functionality Simple experiments with ExperimentMFC User interaction

More information

Contents. Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual

Contents. Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual Contents 1 Introduction...2 2 Lexical Conventions...2 3 Types...3 4 Syntax...3 5 Expressions...4 6 Declarations...8 7 Statements...9

More information

Activity: page 1/10 Introduction to Excel. Getting Started

Activity: page 1/10 Introduction to Excel. Getting Started Activity: page 1/10 Introduction to Excel Excel is a computer spreadsheet program. Spreadsheets are convenient to use for entering and analyzing data. Although Excel has many capabilities for analyzing

More information

Outline. Group project Sagittal diagram Intro to Praat: basics Praat exercise HW 2

Outline. Group project Sagittal diagram Intro to Praat: basics Praat exercise HW 2 L541 Lab Week 2 Outline Group project Sagittal diagram Intro to Praat: basics Praat exercise HW 2 Group Project Draft sketch (i.e. project ideas) is due at 5pm next Friday (1/31). Email both Prof. de Jong

More information

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG 1 Notice Reading Assignment Chapter 1: Introduction to Java Programming Homework 1 It is due this coming Sunday

More information

BASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I

BASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I BASIC COMPUTATION x public static void main(string [] args) Fundamentals of Computer Science I Outline Using Eclipse Data Types Variables Primitive and Class Data Types Expressions Declaration Assignment

More information

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming Intro to Programming Unit 7 Intro to Programming 1 What is Programming? 1. Programming Languages 2. Markup vs. Programming 1. Introduction 2. Print Statement 3. Strings 4. Types and Values 5. Math Externals

More information

TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA

TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA 1 TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by M. Guzdial and B. Ericson, and instructor materials prepared

More information

QUIZ: What value is stored in a after this

QUIZ: What value is stored in a after this QUIZ: What value is stored in a after this statement is executed? Why? a = 23/7; QUIZ evaluates to 16. Lesson 4 Statements, Expressions, Operators Statement = complete instruction that directs the computer

More information

Fundamentals. Fundamentals. Fundamentals. We build up instructions from three types of materials

Fundamentals. Fundamentals. Fundamentals. We build up instructions from three types of materials Fundamentals We build up instructions from three types of materials Constants Expressions Fundamentals Constants are just that, they are values that don t change as our macros are executing Fundamentals

More information

An interesting related problem is Buffon s Needle which was first proposed in the mid-1700 s.

An interesting related problem is Buffon s Needle which was first proposed in the mid-1700 s. Using Monte Carlo to Estimate π using Buffon s Needle Problem An interesting related problem is Buffon s Needle which was first proposed in the mid-1700 s. Here s the problem (in a simplified form). Suppose

More information

PRG PROGRAMMING ESSENTIALS. Lecture 2 Program flow, Conditionals, Loops

PRG PROGRAMMING ESSENTIALS. Lecture 2 Program flow, Conditionals, Loops PRG PROGRAMMING ESSENTIALS 1 Lecture 2 Program flow, Conditionals, Loops https://cw.fel.cvut.cz/wiki/courses/be5b33prg/start Michal Reinštein Czech Technical University in Prague, Faculty of Electrical

More information

Praat Scripting Workshop

Praat Scripting Workshop Praat Scripting Workshop North Carolina State University Friday, September 18, 2015 Why Scripting? What Even is Scripting? Objectives Why Scripting? Making measurements by hand is really tedious and repetitive.

More information

Splicing Instructions

Splicing Instructions Splicing Instructions When we create our experiments, we need to be able to play individual words as experiment stimuli. In order to get these individual words, we have a native speaker of whatever language

More information

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 8: SEP. 29TH INSTRUCTOR: JIAYIN WANG

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 8: SEP. 29TH INSTRUCTOR: JIAYIN WANG CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 8: SEP. 29TH INSTRUCTOR: JIAYIN WANG 1 Notice Prepare the Weekly Quiz The weekly quiz is for the knowledge we learned in the previous week (both the

More information

Intro. Scheme Basics. scm> 5 5. scm>

Intro. Scheme Basics. scm> 5 5. scm> Intro Let s take some time to talk about LISP. It stands for LISt Processing a way of coding using only lists! It sounds pretty radical, and it is. There are lots of cool things to know about LISP; if

More information

age = 23 age = age + 1 data types Integers Floating-point numbers Strings Booleans loosely typed age = In my 20s

age = 23 age = age + 1 data types Integers Floating-point numbers Strings Booleans loosely typed age = In my 20s Intro to Python Python Getting increasingly more common Designed to have intuitive and lightweight syntax In this class, we will be using Python 3.x Python 2.x is still very popular, and the differences

More information

Basics of Java Programming

Basics of Java Programming Basics of Java Programming Lecture 2 COP 3252 Summer 2017 May 16, 2017 Components of a Java Program statements - A statement is some action or sequence of actions, given as a command in code. A statement

More information

Our Strategy for Learning Fortran 90

Our Strategy for Learning Fortran 90 Our Strategy for Learning Fortran 90 We want to consider some computational problems which build in complexity. evaluating an integral solving nonlinear equations vector/matrix operations fitting data

More information

COMP-202: Foundations of Programming. Lecture 6: Conditionals Jackie Cheung, Winter 2016

COMP-202: Foundations of Programming. Lecture 6: Conditionals Jackie Cheung, Winter 2016 COMP-202: Foundations of Programming Lecture 6: Conditionals Jackie Cheung, Winter 2016 This Lecture Finish data types and order of operations Conditionals 2 Review Questions What is the difference between

More information

Antje Schweitzer, Nov. 2013, revised Sep. 2014, June 2015, Nov. 2015, Dec. 2015, Nov 2016

Antje Schweitzer, Nov. 2013, revised Sep. 2014, June 2015, Nov. 2015, Dec. 2015, Nov 2016 Praat Scripting Antje Schweitzer, Nov. 2013, revised Sep. 2014, June 2015, Nov. 2015, Dec. 2015, Nov 2016 antje.schweitzer@ims.uni-stuttgart.de Version: November 28, 2016-11:11 Intended users This tutorial

More information

5. Control Statements

5. Control Statements 5. Control Statements This section of the course will introduce you to the major control statements in C++. These control statements are used to specify the branching in an algorithm/recipe. Control statements

More information

= 3 + (5*4) + (1/2)*(4/2)^2.

= 3 + (5*4) + (1/2)*(4/2)^2. Physics 100 Lab 1: Use of a Spreadsheet to Analyze Data by Kenneth Hahn and Michael Goggin In this lab you will learn how to enter data into a spreadsheet and to manipulate the data in meaningful ways.

More information

Scripting Languages. Diana Trandabăț

Scripting Languages. Diana Trandabăț Scripting Languages Diana Trandabăț Master in Computational Linguistics - 1 st year 2017-2018 Today s lecture What is Perl? How to install Perl? How to write Perl progams? How to run a Perl program? perl

More information

CS 115 Lecture 8. Selection: the if statement. Neil Moore

CS 115 Lecture 8. Selection: the if statement. Neil Moore CS 115 Lecture 8 Selection: the if statement Neil Moore Department of Computer Science University of Kentucky Lexington, Kentucky 40506 neil@cs.uky.edu 24 September 2015 Selection Sometime we want to execute

More information

c) Comments do not cause any machine language object code to be generated. d) Lengthy comments can cause poor execution-time performance.

c) Comments do not cause any machine language object code to be generated. d) Lengthy comments can cause poor execution-time performance. 2.1 Introduction (No questions.) 2.2 A Simple Program: Printing a Line of Text 2.1 Which of the following must every C program have? (a) main (b) #include (c) /* (d) 2.2 Every statement in C

More information

COSC2031 Software Tools Introduction to C

COSC2031 Software Tools Introduction to C COSC2031 Software Tools Introduction to C Instructor: Matt Robinson matt@cs.yorku.ca http://www.cs.yorku.ca/course/2031/ From Last Day What this course is about A (brief) History of Unix and C Some sample

More information

Homework 1 Due Tuesday, January 30, 2018 at 8pm

Homework 1 Due Tuesday, January 30, 2018 at 8pm CSECE 374 A Spring 2018 Homework 1 Due Tuesday, January 30, 2018 at 8pm Starting with this homework, groups of up to three people can submit joint solutions. Each problem should be submitted by exactly

More information

STAT 113: R/RStudio Intro

STAT 113: R/RStudio Intro STAT 113: R/RStudio Intro Colin Reimer Dawson Last Revised September 1, 2017 1 Starting R/RStudio There are two ways you can run the software we will be using for labs, R and RStudio. Option 1 is to log

More information

Variables and Typing

Variables and Typing Variables and Typing Christopher M. Harden Contents 1 The basic workflow 2 2 Variables 3 2.1 Declaring a variable........................ 3 2.2 Assigning to a variable...................... 4 2.3 Other

More information

Lab # 2. For today s lab:

Lab # 2. For today s lab: 1 ITI 1120 Lab # 2 Contributors: G. Arbez, M. Eid, D. Inkpen, A. Williams, D. Amyot 1 For today s lab: Go the course webpage Follow the links to the lab notes for Lab 2. Save all the java programs you

More information

Chapter 17. Fundamental Concepts Expressed in JavaScript

Chapter 17. Fundamental Concepts Expressed in JavaScript Chapter 17 Fundamental Concepts Expressed in JavaScript Learning Objectives Tell the difference between name, value, and variable List three basic data types and the rules for specifying them in a program

More information

A PROGRAM IS A SEQUENCE of instructions that a computer can execute to

A PROGRAM IS A SEQUENCE of instructions that a computer can execute to A PROGRAM IS A SEQUENCE of instructions that a computer can execute to perform some task. A simple enough idea, but for the computer to make any use of the instructions, they must be written in a form

More information

Variables in C. Variables in C. What Are Variables in C? CMSC 104, Fall 2012 John Y. Park

Variables in C. Variables in C. What Are Variables in C? CMSC 104, Fall 2012 John Y. Park Variables in C CMSC 104, Fall 2012 John Y. Park 1 Variables in C Topics Naming Variables Declaring Variables Using Variables The Assignment Statement 2 What Are Variables in C? Variables in C have the

More information

1007 Imperative Programming Part II

1007 Imperative Programming Part II Agenda 1007 Imperative Programming Part II We ve seen the basic ideas of sequence, iteration and selection. Now let s look at what else we need to start writing useful programs. Details now start to be

More information

cs1114 REVIEW of details test closed laptop period

cs1114 REVIEW of details test closed laptop period python details DOES NOT COVER FUNCTIONS!!! This is a sample of some of the things that you are responsible for do not believe that if you know only the things on this test that they will get an A on any

More information

STAT 213: R/RStudio Intro

STAT 213: R/RStudio Intro STAT 213: R/RStudio Intro Colin Reimer Dawson Last Revised February 10, 2016 1 Starting R/RStudio Skip to the section below that is relevant to your choice of implementation. Installing R and RStudio Locally

More information

Applied Calculus. Lab 1: An Introduction to R

Applied Calculus. Lab 1: An Introduction to R 1 Math 131/135/194, Fall 2004 Applied Calculus Profs. Kaplan & Flath Macalester College Lab 1: An Introduction to R Goal of this lab To begin to see how to use R. What is R? R is a computer package for

More information

Desktop Command window

Desktop Command window Chapter 1 Matlab Overview EGR1302 Desktop Command window Current Directory window Tb Tabs to toggle between Current Directory & Workspace Windows Command History window 1 Desktop Default appearance Command

More information

CS1 Lecture 3 Jan. 18, 2019

CS1 Lecture 3 Jan. 18, 2019 CS1 Lecture 3 Jan. 18, 2019 Office hours for Prof. Cremer and for TAs have been posted. Locations will change check class website regularly First homework assignment will be available Monday evening, due

More information

Chapter 2, Part I Introduction to C Programming

Chapter 2, Part I Introduction to C Programming Chapter 2, Part I Introduction to C Programming C How to Program, 8/e, GE 2016 Pearson Education, Ltd. All rights reserved. 1 2016 Pearson Education, Ltd. All rights reserved. 2 2016 Pearson Education,

More information

CpSc 1011 Lab 5 Conditional Statements, Loops, ASCII code, and Redirecting Input Characters and Hurricanes

CpSc 1011 Lab 5 Conditional Statements, Loops, ASCII code, and Redirecting Input Characters and Hurricanes CpSc 1011 Lab 5 Conditional Statements, Loops, ASCII code, and Redirecting Input Characters and Hurricanes Overview For this lab, you will use: one or more of the conditional statements explained below

More information

C: How to Program. Week /Mar/05

C: How to Program. Week /Mar/05 1 C: How to Program Week 2 2007/Mar/05 Chapter 2 - Introduction to C Programming 2 Outline 2.1 Introduction 2.2 A Simple C Program: Printing a Line of Text 2.3 Another Simple C Program: Adding Two Integers

More information

BASIC ELEMENTS OF A COMPUTER PROGRAM

BASIC ELEMENTS OF A COMPUTER PROGRAM BASIC ELEMENTS OF A COMPUTER PROGRAM CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING LOGO Contents 1 Identifier 2 3 Rules for naming and declaring data variables Basic data types 4 Arithmetic operators

More information

S206E Lecture 19, 5/24/2016, Python an overview

S206E Lecture 19, 5/24/2016, Python an overview S206E057 Spring 2016 Copyright 2016, Chiu-Shui Chan. All Rights Reserved. Global and local variables: differences between the two Global variable is usually declared at the start of the program, their

More information

CS1 Lecture 3 Jan. 22, 2018

CS1 Lecture 3 Jan. 22, 2018 CS1 Lecture 3 Jan. 22, 2018 Office hours for me and for TAs have been posted, locations will change check class website regularly First homework available, due Mon., 9:00am. Discussion sections tomorrow

More information

Week 1: Introduction to R, part 1

Week 1: Introduction to R, part 1 Week 1: Introduction to R, part 1 Goals Learning how to start with R and RStudio Use the command line Use functions in R Learning the Tools What is R? What is RStudio? Getting started R is a computer program

More information

Variables are used to store data (numbers, letters, etc) in MATLAB. There are a few rules that must be followed when creating variables in MATLAB:

Variables are used to store data (numbers, letters, etc) in MATLAB. There are a few rules that must be followed when creating variables in MATLAB: Contents VARIABLES... 1 Storing Numerical Data... 2 Limits on Numerical Data... 6 Storing Character Strings... 8 Logical Variables... 9 MATLAB S BUILT-IN VARIABLES AND FUNCTIONS... 9 GETTING HELP IN MATLAB...

More information

CSI33 Data Structures

CSI33 Data Structures Outline Department of Mathematics and Computer Science Bronx Community College October 24, 2018 Outline Outline 1 Chapter 8: A C++ Introduction For Python Programmers Expressions and Operator Precedence

More information

12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments.

12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments. Java How to Program, 9/e Education, Inc. All Rights Reserved. } Java application programming } Use tools from the JDK to compile and run programs. } Videos at www.deitel.com/books/jhtp9/ Help you get started

More information

MATLAB TUTORIAL WORKSHEET

MATLAB TUTORIAL WORKSHEET MATLAB TUTORIAL WORKSHEET What is MATLAB? Software package used for computation High-level programming language with easy to use interactive environment Access MATLAB at Tufts here: https://it.tufts.edu/sw-matlabstudent

More information

Loop structures and booleans

Loop structures and booleans Loop structures and booleans Michael Mandel Lecture 7 Methods in Computational Linguistics I The City University of New York, Graduate Center https://github.com/ling78100/lectureexamples/blob/master/lecture07final.ipynb

More information

CS/ECE 374 Fall Homework 1. Due Tuesday, September 6, 2016 at 8pm

CS/ECE 374 Fall Homework 1. Due Tuesday, September 6, 2016 at 8pm CSECE 374 Fall 2016 Homework 1 Due Tuesday, September 6, 2016 at 8pm Starting with this homework, groups of up to three people can submit joint solutions. Each problem should be submitted by exactly one

More information

CpSc 111 Lab 5 Conditional Statements, Loops, the Math Library, and Redirecting Input

CpSc 111 Lab 5 Conditional Statements, Loops, the Math Library, and Redirecting Input CpSc Lab 5 Conditional Statements, Loops, the Math Library, and Redirecting Input Overview For this lab, you will use: one or more of the conditional statements explained below scanf() or fscanf() to read

More information

lab MS Excel 2010 active cell

lab MS Excel 2010 active cell MS Excel is an example of a spreadsheet, a branch of software meant for performing different kinds of calculations, numeric data analysis and presentation, statistical operations and forecasts. The main

More information

Pathologically Eclectic Rubbish Lister

Pathologically Eclectic Rubbish Lister Pathologically Eclectic Rubbish Lister 1 Perl Design Philosophy Author: Reuben Francis Cornel perl is an acronym for Practical Extraction and Report Language. But I guess the title is a rough translation

More information

Praat scripting manual (workshop) for beginners

Praat scripting manual (workshop) for beginners Praat scripting manual (workshop) for beginners v. 1.8 January, 2015 mauricio figueroa www.mauriciofigueroa.cl This work is licensed under the Creative Commons Attribution- NonCommercial-ShareAlike 4.0

More information

EGR 111 Functions and Relational Operators

EGR 111 Functions and Relational Operators EGR 111 Functions and Relational Operators This lab is an introduction to writing your own MATLAB functions. The lab also introduces relational operators and logical operators which allows MATLAB to compare

More information

Full file at C How to Program, 6/e Multiple Choice Test Bank

Full file at   C How to Program, 6/e Multiple Choice Test Bank 2.1 Introduction 2.2 A Simple Program: Printing a Line of Text 2.1 Lines beginning with let the computer know that the rest of the line is a comment. (a) /* (b) ** (c) REM (d)

More information

Chapter 3: Programming with MATLAB

Chapter 3: Programming with MATLAB Chapter 3: Programming with MATLAB Choi Hae Jin Chapter Objectives q Learning how to create well-documented M-files in the edit window and invoke them from the command window. q Understanding how script

More information

Text Input and Conditionals

Text Input and Conditionals Text Input and Conditionals Text Input Many programs allow the user to enter information, like a username and password. Python makes taking input from the user seamless with a single line of code: input()

More information

SMURF Language Reference Manual Serial MUsic Represented as Functions

SMURF Language Reference Manual Serial MUsic Represented as Functions SMURF Language Reference Manual Serial MUsic Represented as Functions Richard Townsend, Lianne Lairmore, Lindsay Neubauer, Van Bui, Kuangya Zhai {rt2515, lel2143, lan2135, vb2363, kz2219}@columbia.edu

More information

CMSC 201 Fall 2016 Lab 09 Advanced Debugging

CMSC 201 Fall 2016 Lab 09 Advanced Debugging CMSC 201 Fall 2016 Lab 09 Advanced Debugging Assignment: Lab 09 Advanced Debugging Due Date: During discussion Value: 10 points Part 1: Introduction to Errors Throughout this semester, we have been working

More information

Quiz 1: Functions and Procedures

Quiz 1: Functions and Procedures Quiz 1: Functions and Procedures Outline Basics Control Flow While Loops Expressions and Statements Functions Primitive Data Types 3 simple data types: number, string, boolean Numbers store numerical data

More information

DEBUGGING TIPS. 1 Introduction COMPUTER SCIENCE 61A

DEBUGGING TIPS. 1 Introduction COMPUTER SCIENCE 61A DEBUGGING TIPS COMPUTER SCIENCE 61A 1 Introduction Every time a function is called, Python creates what is called a stack frame for that specific function to hold local variables and other information.

More information

Introduction to: Computers & Programming Defining Identifiers: Objects with Names

Introduction to: Computers & Programming Defining Identifiers: Objects with Names Introduction to: Computers & Programming Defining Identifiers: Objects with Names Adam Meyers New York University Outline The types of objects with names Functions, Variables, Programs, Modules, etc. Defining

More information

HW3: CS 110X C Domain Information. Final Version: 1/29/2014

HW3: CS 110X C Domain Information. Final Version: 1/29/2014 HW3: CS 110X C 2014 Note: This homework (and all remaining homework assignments) is a partner homework and must be completed by each partner pair. When you complete this assignment, you must not share

More information

2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program

2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program Chapter 2: Introduction to C++ 2.1 Parts of a C++ Program Copyright 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Parts of a C++ Program Parts of a C++ Program // sample C++ program

More information

Programming for Engineers Introduction to C

Programming for Engineers Introduction to C Programming for Engineers Introduction to C ICEN 200 Spring 2018 Prof. Dola Saha 1 Simple Program 2 Comments // Fig. 2.1: fig02_01.c // A first program in C begin with //, indicating that these two lines

More information

CMSC 201 Spring 2016 Homework 7 Strings and File I/O

CMSC 201 Spring 2016 Homework 7 Strings and File I/O CMSC 201 Spring 2016 Homework 7 Strings and File I/O Assignment: Homework 7 Strings and File I/O Due Date: Monday, April 4th, 2016 by 8:59:59 PM Value: 40 points Homework 7 is designed to help you practice

More information

APPM 2460: Week Three For, While and If s

APPM 2460: Week Three For, While and If s APPM 2460: Week Three For, While and If s 1 Introduction Today we will learn a little more about programming. This time we will learn how to use for loops, while loops and if statements. 2 The For Loop

More information

The PCAT Programming Language Reference Manual

The PCAT Programming Language Reference Manual The PCAT Programming Language Reference Manual Andrew Tolmach and Jingke Li Dept. of Computer Science Portland State University September 27, 1995 (revised October 15, 2002) 1 Introduction The PCAT language

More information

fpp: Fortran preprocessor March 9, 2009

fpp: Fortran preprocessor March 9, 2009 fpp: Fortran preprocessor March 9, 2009 1 Name fpp the Fortran language preprocessor for the NAG Fortran compiler. 2 Usage fpp [option]... [input-file [output-file]] 3 Description fpp is the preprocessor

More information

MATVEC: MATRIX-VECTOR COMPUTATION LANGUAGE REFERENCE MANUAL. John C. Murphy jcm2105 Programming Languages and Translators Professor Stephen Edwards

MATVEC: MATRIX-VECTOR COMPUTATION LANGUAGE REFERENCE MANUAL. John C. Murphy jcm2105 Programming Languages and Translators Professor Stephen Edwards MATVEC: MATRIX-VECTOR COMPUTATION LANGUAGE REFERENCE MANUAL John C. Murphy jcm2105 Programming Languages and Translators Professor Stephen Edwards Language Reference Manual Introduction The purpose of

More information

Mobile Computing Professor Pushpendra Singh Indraprastha Institute of Information Technology Delhi Java Basics Lecture 02

Mobile Computing Professor Pushpendra Singh Indraprastha Institute of Information Technology Delhi Java Basics Lecture 02 Mobile Computing Professor Pushpendra Singh Indraprastha Institute of Information Technology Delhi Java Basics Lecture 02 Hello, in this lecture we will learn about some fundamentals concepts of java.

More information

CS2900 Introductory Programming with Python and C++ Kevin Squire LtCol Joel Young Fall 2007

CS2900 Introductory Programming with Python and C++ Kevin Squire LtCol Joel Young Fall 2007 CS2900 Introductory Programming with Python and C++ Kevin Squire LtCol Joel Young Fall 2007 Course Web Site http://www.nps.navy.mil/cs/facultypages/squire/cs2900 All course related materials will be posted

More information

There are two ways to use the python interpreter: interactive mode and script mode. (a) open a terminal shell (terminal emulator in Applications Menu)

There are two ways to use the python interpreter: interactive mode and script mode. (a) open a terminal shell (terminal emulator in Applications Menu) I. INTERACTIVE MODE VERSUS SCRIPT MODE There are two ways to use the python interpreter: interactive mode and script mode. 1. Interactive Mode (a) open a terminal shell (terminal emulator in Applications

More information

Java Programming Fundamentals - Day Instructor: Jason Yoon Website:

Java Programming Fundamentals - Day Instructor: Jason Yoon Website: Java Programming Fundamentals - Day 1 07.09.2016 Instructor: Jason Yoon Website: http://mryoon.weebly.com Quick Advice Before We Get Started Java is not the same as javascript! Don t get them confused

More information

Exercise 6 - Addressing a Message

Exercise 6 - Addressing a Message Exercise 6 - Addressing a Message All e-mail messages have to include an address for an e-mail to be delivered, just as a normal letter has to have a house address. An e-mail address is made up of: a user

More information

Introduction to: Computers & Programming Defining Identifiers: Objects with Names

Introduction to: Computers & Programming Defining Identifiers: Objects with Names Introduction to: Computers & Programming Defining Identifiers: Objects with Names Adam Meyers New York University Outline The types of objects with names Functions, Variables, Programs, Modules, etc. Defining

More information

Control Structures. CIS 118 Intro to LINUX

Control Structures. CIS 118 Intro to LINUX Control Structures CIS 118 Intro to LINUX Basic Control Structures TEST The test utility, has many formats for evaluating expressions. For example, when given three arguments, will return the value true

More information

Sprite an animation manipulation language Language Reference Manual

Sprite an animation manipulation language Language Reference Manual Sprite an animation manipulation language Language Reference Manual Team Leader Dave Smith Team Members Dan Benamy John Morales Monica Ranadive Table of Contents A. Introduction...3 B. Lexical Conventions...3

More information

Introduction to C Programming

Introduction to C Programming 1 2 Introduction to C Programming 2.6 Decision Making: Equality and Relational Operators 2 Executable statements Perform actions (calculations, input/output of data) Perform decisions - May want to print

More information

Fundamental of Programming (C)

Fundamental of Programming (C) Borrowed from lecturer notes by Omid Jafarinezhad Fundamental of Programming (C) Lecturer: Vahid Khodabakhshi Lecture 3 Constants, Variables, Data Types, And Operations Department of Computer Engineering

More information

Lab 4 CSE 7, Spring 2018 This lab is an introduction to using logical and comparison operators in Matlab.

Lab 4 CSE 7, Spring 2018 This lab is an introduction to using logical and comparison operators in Matlab. LEARNING OBJECTIVES: Lab 4 CSE 7, Spring 2018 This lab is an introduction to using logical and comparison operators in Matlab 1 Use comparison operators (< > = == ~=) between two scalar values to create

More information

Have examined process Creating program Have developed program Written in C Source code

Have examined process Creating program Have developed program Written in C Source code Preprocessing, Compiling, Assembling, and Linking Introduction In this lesson will examine Architecture of C program Introduce C preprocessor and preprocessor directives How to use preprocessor s directives

More information

Chapter 2 - Introduction to C Programming

Chapter 2 - Introduction to C Programming Chapter 2 - Introduction to C Programming 2 Outline 2.1 Introduction 2.2 A Simple C Program: Printing a Line of Text 2.3 Another Simple C Program: Adding Two Integers 2.4 Memory Concepts 2.5 Arithmetic

More information

MATLAB Project: Getting Started with MATLAB

MATLAB Project: Getting Started with MATLAB Name Purpose: To learn to create matrices and use various MATLAB commands for reference later MATLAB built-in functions used: [ ] : ; + - * ^, size, help, format, eye, zeros, ones, diag, rand, round, cos,

More information

Selection statements. CSE 1310 Introduction to Computers and Programming Alexandra Stefan University of Texas at Arlington

Selection statements. CSE 1310 Introduction to Computers and Programming Alexandra Stefan University of Texas at Arlington Selection s CSE 1310 Introduction to Computers and Programming Alexandra Stefan University of Texas at Arlington 1 Book reference Book: The practice of Computing Using Python 2-nd edition Second hand book

More information

Label_1_6.praat 1 13 Nov 2009

Label_1_6.praat 1 13 Nov 2009 Label_1_6.praat 1 13 Nov 2009 User manual for the PRAAT script Label_1_6.praat 0. Quick start a) Make a raw test file (.txt) with the sequence of labels that you want to set, one item per line. b) Put

More information

EGR 111 Functions and Relational Operators

EGR 111 Functions and Relational Operators EGR 111 Functions and Relational Operators This lab is an introduction to writing your own MATLAB functions. The lab also introduces relational operators and logical operators which allows MATLAB to compare

More information

IT 374 C# and Applications/ IT695 C# Data Structures

IT 374 C# and Applications/ IT695 C# Data Structures IT 374 C# and Applications/ IT695 C# Data Structures Module 2.1: Introduction to C# App Programming Xianrong (Shawn) Zheng Spring 2017 1 Outline Introduction Creating a Simple App String Interpolation

More information

6.001 Notes: Section 8.1

6.001 Notes: Section 8.1 6.001 Notes: Section 8.1 Slide 8.1.1 In this lecture we are going to introduce a new data type, specifically to deal with symbols. This may sound a bit odd, but if you step back, you may realize that everything

More information

Overview: Programming Concepts. Programming Concepts. Names, Values, And Variables

Overview: Programming Concepts. Programming Concepts. Names, Values, And Variables Chapter 18: Get With the Program: Fundamental Concepts Expressed in JavaScript Fluency with Information Technology Third Edition by Lawrence Snyder Overview: Programming Concepts Programming: Act of formulating

More information

Overview: Programming Concepts. Programming Concepts. Chapter 18: Get With the Program: Fundamental Concepts Expressed in JavaScript

Overview: Programming Concepts. Programming Concepts. Chapter 18: Get With the Program: Fundamental Concepts Expressed in JavaScript Chapter 18: Get With the Program: Fundamental Concepts Expressed in JavaScript Fluency with Information Technology Third Edition by Lawrence Snyder Overview: Programming Concepts Programming: Act of formulating

More information

OBJECT ORIENTED PROGRAMMING USING C++

OBJECT ORIENTED PROGRAMMING USING C++ OBJECT ORIENTED PROGRAMMING USING C++ Chapter 17 - The Preprocessor Outline 17.1 Introduction 17.2 The #include Preprocessor Directive 17.3 The #define Preprocessor Directive: Symbolic Constants 17.4 The

More information