Welcome'to'BBM'101' Course'Introduc-on' Course'Staff' Course'Staff' Lecturers:# TAs#(teaching#assistants):# # # Do#not#hesitate#to#ask#TAs#for#help!
|
|
- April Lambert
- 5 years ago
- Views:
Transcription
1 Welcome'to'BBM'101' Course'Introduc-on' BBM101&Introduc/ontoProgrammingI Hace7epeUniversity Fall2015 FuatAkal,AykutErdem,ErkutErdem,VahidGarousi Thiscourseteachescoreprogrammingconceptswith anemphasisondatamanipula/ontasksfrom science,engineering,andbusiness Goalbytheendofthesemester:Givenadata sourceandaproblemdescrip/on,youcan independentlywriteacomplete,usefulprogramto solvetheproblem SlidesbasedonmaterialpreparedbyRuthAnderson,MichaelErnstandBillHoweinthecourseCSE140 UniversityofWashington 1 2 Course'Staff' Course'Staff' Lecturers: Asst.Prof.Dr.FuatAkal Asst.Prof.Dr.AykutErdem Asst.Prof.Dr.ErkutErdem Assoc.Prof.Dr.VahidGarousi 3 TAs(teachingassistants): BurçakAsal FeyzaNurÇubukçuoğlu LeventKaracan SelimYılmaz DonothesitatetoaskTAsforhelp! 4
2 Learning'Objec-ves' What'This'Course'is'not' Computa/onalproblem&solving A skillscourse inpython BasicPythonproficiency Adataanalysis/ datascience /datavisualiza/oncourse thoughyouwillbecomeproficientinthebasicsofthepython programminglanguage andyouwillgainexperiencewithsomeimportantpythonlibraries Wri/ngaprogramwillbecomeyour go&to solu/on fordataanalysistasks. Therewillbeveryli7lesta/s/csknowledgeassumedortaught Includingexperiencewithrelevantlibrariesfordata manipula/on,scien/ficcompu/ng,andvisualiza/on. A project course theassignmentsare real, butareintendedtoteachspecific programmingconcepts Experienceworkingwithrealdatasets astronomy,biology,linguis/cs,oceanography,open government,socialnetworks,andmore. Youwillseethattheseareeasytoprocesswitha program,andthatdoingsoyieldsinsight. A sohwareengineering course Programmingisthestar/ngpointofcomputerscienceandsohware engineering 5 6 All'of'Science'is'Reducing'to' Computa-onal'Data'Manipula-on'! It s!a!great!+me!to!be!a!data!geek.!!!!!old!model:! Query!the!world!!(Data!acquisi7on!coupled!to!a!specific!hypothesis)!!!!!New!model:! Download!the!world!(Data!acquisi7on!supports!many!hypotheses) Astronomy:'HighIresolu-on,'highIfrequency'sky'surveys'(SDSS,'LSST,'PanSTARRS)' Biology:'lab'automa-on,'highIthroughput'sequencing,'' Oceanography:'highIresolu-on'models,'cheap'sensors,'satellites 33!Roger!Barga,!Microso:!Research!!! The!greatest!minds!of!my!genera+on!are!trying!! to!figure!out!how!to!make!people!click!on!ads! 40TB/2nights 33!Jeff!Hammerbacher,!co3founder,!Cloudera!! ~1TB/day 100sofdevices 7 8
3 Example:'Assessing'Treatment' Efficacy' Python'Program'to'Assess'Treatment'Efficacy' numberoffollowups within16weeksaher treatmentenrollment. Zipcodeofclinic Ques+on:!Does!the!distance!between!the! pa+ent s!home!and!clinic!influence!the!number! of!follow!ups,!and!therefore!treatment!efficacy?! Zipcodeofpa/ent 9 ThisprogramreadsanExcelspreadsheetwhosepenul/mate andantepenul/matecolumnsarezipcodes. Itaddsanewlastcolumnforthedistancebetweenthosezip codes,andoutputsincsv(comma&separatedvalues)format. Calltheprogramwithtwonumericvalues:thefirstandlast rowtoinclude. Theoutputcontainsthecolumnheadersandthoserows. Librariestouse importrandom importsys importxlrdlibraryforworkingwithexcelspreadsheets import/me fromgdapiimportgoogledirec/ons Nokeyneedediffewqueries gd=googledirec/ons('dummy&google&key') wb=xlrd.open_workbook('mhip_zip_escience_121611a.xls') sheet=wb.sheet_by_index(0) Userinput:firstrowtoprocess,firstrownottoprocess first_row=max(int(sys.argv[1]),2) row_limit=min(int(sys.argv[2]+1),sheet.nrows) defcomma_separated(lst): return,.join([str(s)forsinlst]) headers=sheet.row_values(0)+[distance] printcomma_separated(headers) forrownuminrange(first_row,row_limit): row=sheet.row_values(rownum) (zip1,zip2)=row[&3:&1] ifzip1andzip2: Cleanthedata zip1=str(int(zip1)) zip2=str(int(zip2)) row[&3:&1]=[zip1,zip2] ComputethedistanceviaGoogleMaps try: distance=gd.query(zip1,zip2).distance except: print>>sys.stderr,errorcompu/ngdistance:,zip1,zip2 distance= Printtherowwiththedistance printcomma_separated(row+[distance]) AvoidtoomanyGooglequeriesinrapidsuccession /me.sleep(random.random()+0.5) 23linesofexecutablecode! 10 Course'Logis-cs' Academic'Integrity' Website: Seethewebsiteforalladministra/vedetails Readthehandoutsandrequiredtexts,beforethelecture Takenotes! FollowthecourseinPiazza fall2015/bbm101 Honestworkisrequiredofascien/storengineer. Collabora/onpolicyonthecourseweb.Read'it!' Discussionispermi7ed. Carrying'materials'from'discussion'is'not'permiTed.' Everythingyouturninmustbeyourownwork. Citeyoursources,explainanyunconven/onalac/on. You'may'not'view'others 'work.' Ifyouhaveaques/on,ask. Wetrustyoucompletely. Butwehavenosympathyfortrustviola/ons norshouldyou! 11 12
4 How'to'Succeed' Integrated'Development'Environment'(IDE)' Noprerequisites Non&predictorsforsuccess: Pastprogrammingexperience Enthusiasmforgamesorcomputers Programminganddataanalysisarechallenging Everyoneofyoucansucceed Thereisnosuchthingasa bornprogrammer Workhard Followdirec/ons Bemethodical Thinkbeforeyouact Tryonyourown,thenaskforhelp Startearly 13 Therearemany! 14 Our'Recommenda-on:'PyCharm' Python'Version' WhateverIDEyouchoosetoworkwith, alwayss/cktopython'version'2.7.10' ' Alwaysusethisversiontocodeyour assignments
5 Books' Therearemany! Our'Recommenda-on'for'Books' ThePythonTutorial,availablefromthePythonwebsite. ThisisgoodforexplainingthenutsandboltsofhowPythonworks. ThinkPython,2ndedi/on FreelyavailableonlineinHTMLandPDF. Alsoavailableforpurchaseasaprintedbook,butdon'tbuythefirst edi/on. Thisbookintroducesmoreconceptualmaterial,mo/va/ng computa/onalthinking. Thereisan interac/veversionof HowtoThinkLikeaComputerScien/st (the firstedi/onof ThinkPython ),whichletsyoutypeandrunpython codedirectlywhilereadingthebook
6 1.Pythonisacalculator 2.Avariableisacontainer Introduc)on*to*Python* and*programming* BBM101EIntroducGontoProgrammingI HaceIepeUniversity Fall2015 FuatAkal,AykutErdem,ErkutErdem,VahidGarousi 3.Differenttypescannotbecompared 4.Aprogramisarecipe SlidesbasedonmaterialpreparedbyRuthAnderson,MichaelErnstandBillHoweinthecourseCSE140 UniversityofWashington *Python*is*Like*a*Calculator* You*Type*Expressions.* Python*Computes*Their*Values.* /2 2**3 3*4+5*6 Ifprecedenceisunclear,useparentheses (72 32)/9*5 3 4
7 An*Expression*is*Evaluated* From*the*Inside*Out* HowmanyexpressionsareinthisPythoncode? anexpression (72 32)/9.0*5 values (72 32)/9.0*5* (40)/9.0*5* 40/9.0*5* 4.44*5* 22.2* Another*Evalua)on*Example* (72 32)/(9.0*5)* (40)/(9.0*5)* 40/(9.0*5)* 40/(45.0)* 40/45.0*.888* *A*Variable*is*a*Container* Variables*Hold*Values* Recallvariablesfromalgebra: Letx=2 Lety=x Toassignavariable,use varname=expression pi = 3.14 pi var = 6*10**23 22 = x Error! Nooutputfroman assignmentstatement 7 NotallvariablenamesarepermiIed 8
8 Changing*Exis)ng*Variables* ( repbinding *or* repassigning )* x = 2 x y = 2 x y x = 5 x Y = inanassignmentisnotapromiseofeternalequality ThisisdifferentthanthemathemaGcalmeaningof = EvaluaGnganexpressiongivesanew(copyofa)number, ratherthanchanginganexisgngone 9 How*an*Assignment*is*Executed* 1. EvaluatetherightEhandsidetoavalue 2. Storethatvalueinthevariable x = 2 print(x) y = x print(y) z = x + 1 print(z) x = 5 print(x) print(y) print(z) Stateofthecomputer: x:2 x:5 y:2 z:3 Printedoutput: Tovisualizeaprogram sexecugon: hip://pythontutor.com 10 More*Expressions:**Condi)onals* (value*is*true*or*false)* More*Expressions:**strings* 22 > 4 condigon,orcondigonal 22 < 4 condigon,orcondigonal 22 == 4 x == 100 Assignment,notcondiGonal! 22 = 4 Error! x >= 5 x >= 100 Numericoperators:+,*,** Booleanoperators:not,and,or Mixedoperators:<,>=,== x >= 200 not True not (x >= 200) 3<4 and 5<6 4<3 or 5<6 temp = 72 water_is_liquid = (temp > 32 and temp < 212) 11 A*string*represents*text* 'Python' mystring = BBM 101-Introduction to Programming Empty*string*is*not*the*same*as*an*unbound*variable* *and* *are*the*same* Opera)ons:* Length:* len(mystring) Concatena)on:* Hacettepe + + ' University' Containment/searching:* a' in mystring a in mystring 12
9 3.*Different*Types*cannot*be*Compared* Types*of*Values* anint = 2 astring = Hacettepe anint == astring Error Integers(int):-22,0,44 ArithmeGcisexact SomefunnyrepresentaGons: L * Realnumbers(float,for floagngpoint ):2.718, ArithmeGcisapproximate,e.g.,6.022*10**23 SomefunnyrepresentaGons:6.022e+23 Strings(str):I love Python, Truthvalues(bool,for Boolean ): True,False 13 GeorgeBoole 14 Opera)ons*Behave*differently* on*different*types* ConcatenaGon Error 3 + True Error Moral:Pythononlysome-mestellsyouwhenyou dosomethingthatdoesnotmakesense. Opera)ons*on*Different*Types* 15.0 / / / 4 15 / 4.0 Typeconversion: float(15) int(15.0) int(15.5) int(15) str(15.5) float(15) /
10 A*Program*is*a*Recipe* Design*the*Algorithm*Before*Coding* Weshouldthink(designthealgorithm)beforecoding Algorithmicthinkingisthelogic.Also,calledproblem solving Codingisthesyntax Makethisahabit SomestudentsdonotfollowthispracGceandtheyget challengedinalltheircoursesandcareers! What*is*a*Program?* The**print()*Statement* AprogramisasequenceofinstrucGons Thecomputerexecutesoneanertheother,asiftheyhadbeen typedtotheinterpreter SavingyourworkasaprogramisbeIerthanreEtypingfrom scratch x = 1 y = 2 x + y print(x + y) print(the sum of, x, and, y, is, x+y) 19 Theprintstatementalwaysprintsoneline Thenextprintstatementprintsbelowthatone Write0ormoreexpressionsanerprint,separatedby commas Intheoutput,thevaluesareseparatedbyspaces Examples: x=1 y=2 print(3.1415) print(2.718, 1.618) Print() print(20 + 2, 7 * 3, 4 * 5) print(the sum of, x, and, y, is, x+y) 20
11 Exercise:**Convert*Temperatures* Expressions,*Statements,*and*Programs* Makeatemperatureconversionchartasthefollowing FahrenheittoCenGgrade,forFahrenheitvaluesof:E40,0,32,68,98.6, 212 C=(FE32) 5/9 Output: Fahrenheit Centigrade YouhavecreatedaPythonprogram! (Itdoesn thavetobethistedious,anditwon tbe.) 21 Anexpressionevaluatestoavalue pi * r**2 Astatementcausesaneffect pi = print(pi) Expressionsappearwithinotherexpressionsandwithinstatements (fahr 32) * (5.0 / 9) print(pi * r**2) Astatementmaynotappearwithinanexpression 3 + print(pi) *Error!* * Aprogramismadeupofstatements AprogramshoulddosomethingorcommunicateinformaGon 22 print()*func)on* 1.Pythonisacalculator 2.Avariableisacontainer 3.Differenttypescannotbecompared 4.Aprogramisarecipe 23 24
12 Programming*Languages* Evolu)on*of*Programming*Languages* Aprogramminglanguageisa language towriteprograms in,suchaspython,c,c++,java Theconceptofprogramminglanguagesarequitesimilar Python: Java: Pythonissimpler!That swhywearelearningitfirst! hip://blog.codeeval.com/codeevalblog/
Introduction to Python and Programming. 1. Python is Like a Calculator. You Type Expressions. Python Computes Their Values /2 2**3 3*4+5*6
1. Python is a calculator. A variable is a container Introduction to Python and Programming BBM 101 - Introduction to Programming I Hacettepe University Fall 016 Fuat Akal, Aykut Erdem, Erkut Erdem 3.
More informationMonty Python and the Holy Grail (1975) BBM 101. Introduction to Programming I. Lecture #03 Introduction to Python and Programming, Control Flow
BBM 101 Monty Python and the Holy Grail (1975) Introduction to Programming I Lecture #03 Introduction to Python and Programming, Control Flow Aykut Erdem, Fuat Akal & Aydın Kaya // Fall 2018 Last time
More informationIntroduction to Python and programming. Ruth Anderson UW CSE 160 Winter 2017
Introduction to Python and programming Ruth Anderson UW CSE 160 Winter 2017 1 1. Python is a calculator 2. A variable is a container 3. Different types cannot be compared 4. A program is a recipe 2 0.
More informationMonty Python and the Holy Grail (1975) BBM 101. Introduction to Programming I. Lecture #03 Introduction to Python and Programming, Control Flow
BBM 101 Monty Python and the Holy Grail (1975) Introduction to Programming I Lecture #03 Introduction to Python and Programming, Control Flow Erkut Erdem, Aykut Erdem & Aydın Kaya // Fall 2017 Last time
More informationLecture Writing Programs. Richard E Sarkis CSC 161: The Art of Programming
Lecture Writing Programs Richard E Sarkis CSC 161: The Art of Programming Class Administrivia Agenda To be able to understand and write Python statements to output information to the screen To assign values
More informationLecture 3. Input, Output and Data Types
Lecture 3 Input, Output and Data Types Goals for today Variable Types Integers, Floating-Point, Strings, Booleans Conversion between types Operations on types Input/Output Some ways of getting input, and
More informationCSEN 102 Introduction to Computer Science
CSEN 102 Introduction to Computer Science Lecture 2: Python and Sequential Algorithms Prof. Dr. Slim Abdennadher Dr. Aysha Alsafty, slim.abdennadher@guc.edu.eg, aysha.alsafty@guc.edu.eg German University
More informationCS 303E Fall 2011 Exam 2 Solutions and Criteria November 2, Good Luck!
CS 303E Fall 2011 Exam 2 Solutions and Criteria November 2, 2011 Name: EID: Section Number: Friday discussion time (circle one): 9-10 10-11 11-12 12-1 2-3 Friday discussion TA(circle one): Wei Ashley Answer
More informationCh.2: Loops and lists
Ch.2: Loops and lists Joakim Sundnes 1,2 Hans Petter Langtangen 1,2 Simula Research Laboratory 1 University of Oslo, Dept. of Informatics 2 Aug 29, 2018 Plan for 28 August Short quiz on topics from last
More informationCSSE 120 Introduction to Software Development Practice for Test 1 paper-and-pencil part Page 1 of 6
CSSE 120 Introduction to Software Development Practice for Test 1 paper-and-pencil part Page 1 of 6 Name: Use this quiz to help you prepare for the Paper-and-Pencil portion of Test 1. Complete it electronically
More informationSpring 2017 CS 1110/1111 Exam 1
CS 1110/1111 Spring 2017 Exam 1 page 1 of 6 Spring 2017 CS 1110/1111 Exam 1 Bubble in your computing ID in the footer of this page. We use an optical scanner to read it, so fill in the bubbles darkly.
More informationCITS 4406 Problem Solving & Programming
CITS 4406 Problem Solving & Programming Tim French Lecture 02 The Software Development Process (These slides are based on John Zelle s powerpoint slides for lectures accompanied with the text book) Objectives
More informationComputer Science 217
Computer Science 17 Midterm Exam March 5, 014 Exam Number 1 First Name: Last Name: ID: Class Time (Circle One): 1:00pm :00pm Instructions: Neatly print your names and ID number in the spaces provided above.
More informationLecture 4: Basic I/O
Lecture 4: Basic I/O CS1068+ Introductory Programming in Python Dr Kieran T. Herley Department of Computer Science University College Cork 2017-2018 KH (21/09/17) Lecture 4: Basic I/O 2017-2018 1 / 20
More informationCPSC 217 Midterm (Python 3 version)
CPSC 217 Midterm (Python 3 version) Duration: 50 minutes 6 March 2009 This exam has 61 questions and 11 pages. This exam is closed book. No notes, books, calculators or electronic devices, or other assistance
More informationLecture 4: Simple Input-Calculate-Output Programs
Lecture 4: Simple Input-Calculate-Output Programs CS1068+ Introductory Programming in Python Dr Kieran T. Herley 2017/18 Department of Computer Science University College Cork input Statement Python s
More informationNotes on Chapter 1 Variables and String
Notes on Chapter 1 Variables and String Note 0: There are two things in Python; variables which can hold data and the data itself. The data itself consists of different kinds of data. These include numbers,
More informationCS 115 Lecture 4. More Python; testing software. Neil Moore
CS 115 Lecture 4 More Python; testing software Neil Moore Department of Computer Science University of Kentucky Lexington, Kentucky 40506 neil@cs.uky.edu 8 September 2015 Syntax: Statements A statement
More informationCS2304: Python for Java Programmers. CS2304: Sequences and Collections
CS2304: Sequences and Collections Sequences In Python A sequence type in python supports: The in membership operator. The len() function. Slicing like we saw with strings, s[1:3]. And is iterable (for
More informationIntroduction to Computer Programming for Non-Majors
Introduction to Computer Programming for Non-Majors CSC 2301, Fall 2014 Chapter 2 The Department of Computer Science Chapter 2 Elements of Programs-Objectives To be able to understand and write Python
More informationENGR 102 Engineering Lab I - Computation
ENGR 102 Engineering Lab I - Computation Week 03: Data Types and Console Input / Output Introduction to Types As we have already seen, 1 computers store numbers in a binary sequence of bits. The organization
More informationPython 2 Conditionals and loops
Today s lecture Python 2 Conditionals and loops Lecture 23 COMPSCI111/111G SS 2016! Recap of yesterday s lecture! if statements! while loops Recap! Introduced the IDLE IDE, variables! Basic arithmetic
More informationCS177 Python Programming. Recita4on 2 - Compu4ng with Numbers
CS177 Python Programming Recita4on 2 - Compu4ng with Numbers Outline Data types. Variables Math library. Range Func4on What is data (in the context of programming)? Values that are stored and manipulated
More informationCS177 Python Programming. Recitation 2 - Computing with Numbers
CS177 Python Programming Recitation 2 - Computing with Numbers Outline Data types. Variables Math library. Range Function What is data (in the context of programming)? Values that are stored and manipulated
More informationLecture 3: Functions & Modules (Sections ) CS 1110 Introduction to Computing Using Python
http://www.cs.cornell.edu/courses/cs1110/2019sp Lecture 3: Functions & Modules (Sections 3.1-3.3) CS 1110 Introduction to Computing Using Python [E. Andersen, A. Bracy, D. Gries, L. Lee, S. Marschner,
More informationPython 2 Conditionals and loops Matthew Egbert CS111
Python 2 Conditionals and loops Matthew Egbert CS111 Yesterday's Lecture Input and Output user_input_as_str = input('prompt: ') print('hello. You entered: '+ user_input_as_str) Comments # everything to
More informationIntroduction to Mathematical and Scientific Programming TUTORIAL WEEK 1 (MATH 1MP3) Winter 2019
TUTORIAL WEEK 1 Introduction to Mathematical and Scientific Programming (MATH 1MP3) Winter 2019 Important Links 1- The Course Website https://ms.mcmaster.ca/~matt/1mp3.html 2- Python https://www.python.org/downloads/
More informationPython Programming: An Introduction to Computer Science
Python Programming: An Introduction to Computer Science Chapter 2 Python Programming, 2/e 1 Objectives n To be able to understand and write Python statements to output information to the screen, assign
More informationLecture 9. Assignment. Logical Operations. Logical Operations - Motivation 2/8/18
Assignment Lecture 9 Logical Operations Formatted Print Printf Increment and decrement Read through 3.9, 3.10 Read 4.1. 4.2, 4.3 Go through checkpoint exercise 4.1 Logical Operations - Motivation Logical
More informationCS111: PROGRAMMING LANGUAGE II
CS111: PROGRAMMING LANGUAGE II Computer Science Department Lecture 1(c): Java Basics (II) Lecture Contents Java basics (part II) Conditions Loops Methods Conditions & Branching Conditional Statements A
More informationCS 111X - Fall Test 1 - KEY KEY KEY KEY KEY KEY KEY
CS 111X - Fall 2016 - Test 1 1/9 Computing ID: CS 111X - Fall 2016 - Test 1 - KEY KEY KEY KEY KEY KEY KEY Name: Computing ID: On my honor as a student, I have neither given nor received unauthorized assistance
More informationFinal Exam COMP Fall 2004 Dec 16, 2004
1. Closed book and closed notes. Final Exam COMP 14-062 Fall 2004 Dec 16, 2004 2. Write all scratch work and answers on the exam itself. If you need extra space, let me know. Indicate your final answer
More informationFlow Control. CSC215 Lecture
Flow Control CSC215 Lecture Outline Blocks and compound statements Conditional statements if - statement if-else - statement switch - statement? : opertator Nested conditional statements Repetitive statements
More informationIntroduction to Python (All the Basic Stuff)
Introduction to Python (All the Basic Stuff) 1 Learning Objectives Python program development Command line, IDEs, file editing Language fundamentals Types & variables Expressions I/O Control flow Functions
More informationFundamentals: Expressions and Assignment
Fundamentals: Expressions and Assignment A typical Python program is made up of one or more statements, which are executed, or run, by a Python console (also known as a shell) for their side effects e.g,
More informationNot-So-Mini-Lecture 6. Modules & Scripts
Not-So-Mini-Lecture 6 Modules & Scripts Interactive Shell vs. Modules Launch in command line Type each line separately Python executes as you type Write in a code editor We use Atom Editor But anything
More information1 Truth. 2 Conditional Statements. Expressions That Can Evaluate to Boolean Values. Williams College Lecture 4 Brent Heeringa, Bill Jannen
1 Truth Last lecture we learned about the int, float, and string types. Another very important object type in Python is the boolean type. The two reserved keywords True and False are values with type boolean.
More informationCS 111X - Fall Test 1
CS 111X - Fall 2016 - Test 1 1/9 Computing ID: CS 111X - Fall 2016 - Test 1 Name: Computing ID: On my honor as a student, I have neither given nor received unauthorized assistance on this exam. Signature:
More informationENGR 101 Engineering Design Workshop
ENGR 101 Engineering Design Workshop Lecture 2: Variables, Statements/Expressions, if-else Edgardo Molina City College of New York Literals, Variables, Data Types, Statements and Expressions Python as
More informationCSCI 121: Anatomy of a Python Script
CSCI 121: Anatomy of a Python Script Python Scripts We start by a Python script: A text file containing lines of Python code. Each line is a Python statement. The Python interpreter (the python3 command)
More informationLecture 3: Functions & Modules
http://www.cs.cornell.edu/courses/cs1110/2018sp Lecture 3: Functions & Modules (Sections 3.1-3.3) CS 1110 Introduction to Computing Using Python [E. Andersen, A. Bracy, D. Gries, L. Lee, S. Marschner,
More informationArrays: Higher Dimensional Arrays. CS0007: Introduction to Computer Programming
Arrays: Higher Dimensional Arrays CS0007: Introduction to Computer Programming Review If the == operator has two array variable operands, what is being compared? The reference variables held in the variables.
More informationCS 455 Midterm Exam 1 Fall 2016 [Bono] Thursday, Sept. 29, 2016
Name: USC NetID (e.g., ttrojan): CS 455 Midterm Exam 1 Fall 2016 [Bono] Thursday, Sept. 29, 2016 There are 5 problems on the exam, with 56 points total available. There are 10 pages to the exam (5 pages
More informationModule 3: Strings and Input/Output
Module 3: Strings and Input/Output Topics: Strings and their methods Printing to standard output Reading from standard input Readings: ThinkP 8, 10 1 Strings in Python: combining strings in interesting
More informationWorksheet 6: Basic Methods Methods The Format Method Formatting Floats Formatting Different Types Formatting Keywords
Worksheet 1: Introductory Exercises Turtle Programming Calculations The Print Function Comments Syntax Semantics Strings Concatenation Quotation Marks Types Variables Restrictions on Variable Names Long
More informationLecture 4. Defining Functions
Lecture 4 Defining Functions Academic Integrity Quiz Reading quiz about the course AI policy Go to http://www.cs.cornell.edu/courses/cs11110/ Click Academic Integrity in side bar Read and take quiz in
More informationObject Oriented Programming in Python 3
Object Oriented Programming in Python 3 Objects Python 3 Objects play a central role in the Python data model All the types we ve seen until now are in-fact objects Numeric types, strings, lists, tuples,
More informationIntroduction to Computers. Laboratory Manual. Experiment #3. Elementary Programming, II
Think Twice Code Once The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 LNGG 1003 Khaleel I. Shaheen Introduction to Computers Laboratory Manual Experiment
More informationVariables. Store information needed by the program
Variables Store information needed by the program Must have a TYPE int - can only store a number without a fractional part float, double - can store any number, with or without a fractional part (double
More informationMidterm #1a Fall minutes
15-110 Midterm #1a Fall 2018 50 minutes Name: Andrew ID: @andrew.cmu.edu Section: You may not use any books, notes, or electronic devices during this exam. You may not ask questions about the exam except
More informationExpressions and Variables
Expressions and Variables Expressions print(expression) An expression is evaluated to give a value. For example: 2 + 9-6 Evaluates to: 5 Data Types Integers 1, 2, 3, 42, 100, -5 Floating points 2.5, 7.0,
More informationCS1500 Algorithms and Data Structures for Engineering, FALL Virgil Pavlu, Jose Annunziato,
CS1500 Algorithms and Data Structures for Engineering, FALL 2012 Virgil Pavlu, vip@ccs.neu.edu Jose Annunziato, jannunzi@gmail.com Rohan Garg Morteza Dilgir Huadong Li cs1500hw@gmail.com http://www.ccs.neu.edu/home/vip/teach/cpp_eng/
More informationPython Day 3 11/28/16
Python Day 3 11/28/16 Objectives Review Concepts Types of Errors Escape sequences String functions Find the Errors bookcost = int(input("how much is the book: ")) discount = float(input("what is the discount:
More informationRelational operators (1)
Review-2 Control of flow: ifs & loops How to set them up Where to break to When to use which kind 85-132 Introduction to C-Programming 10-1 Relational operators (1) Relational Operators
More information3. Java - Language Constructs I
Educational Objectives 3. Java - Language Constructs I Names and Identifiers, Variables, Assignments, Constants, Datatypes, Operations, Evaluation of Expressions, Type Conversions You know the basic blocks
More informationStatic Semantics. Lecture 15. (Notes by P. N. Hilfinger and R. Bodik) 2/29/08 Prof. Hilfinger, CS164 Lecture 15 1
Static Semantics Lecture 15 (Notes by P. N. Hilfinger and R. Bodik) 2/29/08 Prof. Hilfinger, CS164 Lecture 15 1 Current Status Lexical analysis Produces tokens Detects & eliminates illegal tokens Parsing
More informationPython Programming: An Introduction to Computer Science
Python Programming: An Introduction to Computer Science Chapter 2 Writing Simple Programs Python Programming, 3/e 1 Objectives n To know the steps in an orderly software development process. n To understand
More informationCSC 120 Computer Science for the Sciences. Week 1 Lecture 2. UofT St. George January 11, 2016
CSC 120 Computer Science for the Sciences Week 1 Lecture 2 UofT St. George January 11, 2016 Introduction to Python & Foundations of computer Programming Variables, DataTypes, Arithmetic Expressions Functions
More informationReal Python: Python 3 Cheat Sheet
Real Python: Python 3 Cheat Sheet Numbers....................................... 3 Strings........................................ 5 Booleans....................................... 7 Lists.........................................
More informationCS240: Programming in C
CS240: Programming in C Lecture 5: Functions. Scope of variables. Program structure. Cristina Nita-Rotaru Lecture 5/ Fall 2013 1 Functions: Explicit declaration Declaration, definition, use, order matters.
More informationCS 312 Exam 2 Fall KG Kris Megan Roman Sonika
CS 312 Exam 2 Fall 2015 Your Name Your UTEID Circle your TA's Name: Aila CK Jialin Katherine B KG Kris Megan Roman Sonika Problem Number Topic Points Possible 1 code trace 32 2 scanners 15 3 program logic
More informationCS Name : Grading TA:
CS 1301 Exam 1 Name : Grading TA: Integrity: By taking this exam, you pledge that this is your work and you have neither given nor received inappropriate help during the taking of this exam in compliance
More informationProgramming. We will be introducing various new elements of Python and using them to solve increasingly interesting and complex problems.
Plan for the rest of the semester: Programming We will be introducing various new elements of Python and using them to solve increasingly interesting and complex problems. We saw earlier that computers
More informationIntroduction to Computer Programming for Non-Majors
Introduction to Computer Programming for Non-Majors CSC 2301, Fall 2014 Chapter 7 Part 2 The Department of Computer Science Quick review one-way or simple decision if : two-way decision
More informationProgramming Languages and Techniques (CIS120e)
Programming Languages and Techniques (CIS120e) Lecture 21 Oct 29, 2010 Transi?on to Java III More on Sta?c vs. Dynamic Types CIS120e / Fall 2010 2 Review: Sta?c vs. Dynamic Types The dynamic type of an
More informationENGR (Socolofsky) Week 02 Python scripts
ENGR 102-213 (Socolofsky) Week 02 Python scripts Listing for script.py 1 # data_types.py 2 # 3 # Lecture examples of using various Python data types and string formatting 4 # 5 # ENGR 102-213 6 # Scott
More informationBinary Search. Not your parents binary search. Ethan Arnold, Arnav Sastry. Spring 2017 CS 104C
Binary Search Not your parents binary search Ethan Arnold, Arnav Sastry CS 104C Spring 2017 1 / 10 How to write binary search Java: 2 / 10 How to write binary search Java: Collections.binarySearch(list,
More informationHacettepe University Computer Engineering Department. Programming in. BBM103 Introduction to Programming Lab 1 Week 4. Fall 2018
Hacettepe University Computer Engineering Department Programming in BBM103 Introduction to Programming Lab 1 Week 4 Fall 2018 Install PyCharm Download Link : https://www.jetbrains.com/pycharm-edu/download/#section=windows
More informationPython workshop. Week 2: Make choices and reuse code.
Python workshop Week 2: Make choices and reuse code barbera@van-schaik.org Overview of this workshop series Week 1: Writing your first program Week 2: Make choices and reuse code Week 3: Loops and strings
More informationITEC1620 Object-Based Programming. Lecture 13
ITEC1620 Object-Based Programming Lecture 13 References A Simple Class AnInt objecta = new AnInt(); AnInt objectb = new AnInt(); objecta objectb AnInt AnInt value value Value Assignments objecta.value
More informationLecture 9. Memory and Call Stacks
Lecture 9 Memory and Call Stacks Announcements for Today Assignment 1 Reading We have started grading! Should have your grade tomorrow morning Resubmit until correct If you were close Will get feedback
More informationPLT Fall Shoo. Language Reference Manual
PLT Fall 2018 Shoo Language Reference Manual Claire Adams (cba2126) Samurdha Jayasinghe (sj2564) Rebekah Kim (rmk2160) Cindy Le (xl2738) Crystal Ren (cr2833) October 14, 2018 Contents 1 Comments 2 1.1
More informationLoop 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 informationPython BASICS. Introduction to Python programming, basic concepts: formatting, naming conventions, variables, etc.
Python BASICS Introduction to Python programming, basic concepts: formatting, naming conventions, variables, etc. Identikit First appeared in 1991 Designed by Guido van Rossum General purpose High level
More informationGenome 373: Intro to Python I. Doug Fowler
Genome 373: Intro to Python I Doug Fowler Outline Intro to Python I What is a program? Dealing with data Strings in Python Numbers in Python What is a program? What is a program? A series of instruc2ons,
More informationCS101 PLEDGED SPRING 2001
The following exam is pledged. All answers are to be given on the provided answer sheet. The test is closed book, closed note, and closed calculator. If you believe more than one answer is acceptable,
More informationCS 141, Lecture 3. Please login to the Math/Programming profile, and look for IDLE (3.4 or the unnumbered. <-- fine <-- fine <-- broken
CS 141, Lecture 3 Please login to the Math/Programming profile, and look for IDLE (3.4 or the unnumbered one are fine)
More informationC Programming Language (Chapter 2 of K&R) Variables and Constants
C Programming Language (Chapter 2 of K&R) Types, Operators and Expressions Variables and Constants Basic objects manipulated by programs Declare before use: type var1, var2, int x, y, _X, x11, buffer;
More informationProgramming to Python
Programming to Python Sept., 5 th Slides by M. Stepp, M. Goldstein, M. DiRamio, and S. Shah Compiling and interpreting Many languages require you to compile (translate) your program into a form that the
More informationCMPT 120 Basics of Python. Summer 2012 Instructor: Hassan Khosravi
CMPT 120 Basics of Python Summer 2012 Instructor: Hassan Khosravi Python A simple programming language to implement your ideas Design philosophy emphasizes code readability Implementation of Python was
More informationName: Partner: Python Activity 9: Looping Structures: FOR Loops
Name: Partner: Python Activity 9: Looping Structures: FOR Loops Learning Objectives Students will be able to: Content: Explain the difference between while loop and a FOR loop Explain the syntax of a FOR
More informationStrings. CSE 1310 Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington
Strings CSE 1310 Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1 Strings Store Text In the same way that int and float are designed to store numerical values,
More informationExtended Introduction to Computer Science CS1001.py Lecture 10, part A: Interim Summary; Testing; Coding Style
Extended Introduction to Computer Science CS1001.py Lecture 10, part A: Interim Summary; Testing; Coding Style Instructors: Benny Chor, Amir Rubinstein Teaching Assistants: Michal Kleinbort, Amir Gilad
More informationScope and Parameter Passing 1 / 19
Scope and Parameter Passing 1 / 19 Outline Overview Naming and scope Function/procedure calls Static vs. dynamic scope Parameter passing schemes 2 / 19 Review of naming Most languages provide a way to
More informationExam 1. CSC 121 Spring Lecturer: Howard Rosenthal. March 1, 2017
Exam 1. CSC 121 Spring 2017 Lecturer: Howard Rosenthal March 1, 2017 Your Name: Key 1. Fill in the following table for the 8 primitive data types. Spell the types exactly correctly. (16 points total) Data
More informationFundamentals of Programming. Lecture 1: Introduction + Basic Building Blocks of Programming
15-112 Fundamentals of Programming Lecture 1: Introduction + Basic Building Blocks of Programming Anil Ada aada@cs.cmu.edu May 16, 2016 What is programming (coding)? What is computer programming? What
More informationIntroduction to Computer Programming CSCI-UA 2. Review Midterm Exam 1
Review Midterm Exam 1 Review Midterm Exam 1 Exam on Monday, October 7 Data Types and Variables = Data Types and Variables Basic Data Types Integers Floating Point Numbers Strings Data Types and Variables
More informationFunctions with Parameters and Return Values
CS101, Spring 2015 Functions with Parameters and Return Values Lecture #4 Last week we covered Objects and Types Variables Methods Tuples Roadmap Last week we covered Objects and Types Variables Methods
More informationLoops! Loops! Loops! Lecture 5 COP 3014 Fall September 25, 2017
Loops! Loops! Loops! Lecture 5 COP 3014 Fall 2017 September 25, 2017 Repetition Statements Repetition statements are called loops, and are used to repeat the same code mulitple times in succession. The
More informationPython Programming: An Introduction to Computer Science
Python Programming: An Introduction to Computer Science Chapter 7 Decision Structures Python Programming, 2/e 1 Objectives æ To understand the programming pattern simple decision and its implementation
More informationCS313D: ADVANCED PROGRAMMING LANGUAGE
CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science department Lecture 2 : C# Language Basics Lecture Contents 2 The C# language First program Variables and constants Input/output Expressions and casting
More informationModule 04: Lists. Topics: Lists and their methods Mutating lists Abstract list functions Readings: ThinkP 8, 10. CS116 Fall : Lists
Module 04: Lists Topics: Lists and their methods Mutating lists Abstract list functions Readings: ThinkP 8, 10 1 Consider the string method split >>> name = "Harry James Potter" >>> name.split() ['Harry',
More informationLists, loops and decisions
Caltech/LEAD Summer 2012 Computer Science Lecture 4: July 11, 2012 Lists, loops and decisions Lists Today Looping with the for statement Making decisions with the if statement Lists A list is a sequence
More informationIntroduction to Computer Programming for Non-Majors
Introduction to Computer Programming for Non-Majors CSC 2301, Fall 2016 Chapter 2 Instructor: Long Ma The Department of Computer Science Review Install and test python Basic concept of computers Test simple
More informationWednesday, October 15, 14. Functions
Functions Terms void foo() { int a, b;... bar(a, b); void bar(int x, int y) {... foo is the caller bar is the callee a, b are the actual parameters to bar x, y are the formal parameters of bar Shorthand:
More informationMaterials covered in this lecture are: A. Completing Ch. 2 Objectives: Example of 6 steps (RCMACT) for solving a problem.
60-140-1 Lecture for Thursday, Sept. 18, 2014. *** Dear 60-140-1 class, I am posting this lecture I would have given tomorrow, Thursday, Sept. 18, 2014 so you can read and continue with learning the course
More informationlearning objectives learn about variables, their types and their values learn about different number representations
programming basics learning objectives algorithms your software system software hardware learn about variables, their types and their values learn about different number representations learn boolean algebra
More informationStructure and Interpretation of Computer Programs Spring 2017 Mock Midterm 1
CS 61A Structure and Interpretation of Computer Programs Spring 2017 Mock Midterm 1 INSTRUCTIONS You have 1 hour to complete the exam. The exam is closed book, closed notes, closed computer, closed calculator,
More informationLecture 7. Memory in Python
Lecture 7 Memory in Python Announcements For This Lecture Readings Reread Chapter 3 No reading for Thursday Lab Work on Assignment Credit when submit A Nothing else to do Assignment Moved to Fri, Sep.
More informationGetting Started Values, Expressions, and Statements CS GMU
Getting Started Values, Expressions, and Statements CS 112 @ GMU Topics where does code go? values and expressions variables and assignment 2 where does code go? we can use the interactive Python interpreter
More information