Programming: Part I. In this section of notes you will learn about how to write simple programs using JES. Translators
|
|
- Allison Hensley
- 6 years ago
- Views:
Transcription
1 Programming: Part I In this section of notes you will learn about how to write simple programs using JES. Translators The (greatly simplified) process of writing a computer program. Step 3: The (binary) program can directly be executed/run. # The Simpsons Game while (gamestatus == PLAYING): display (amaze, artictime, currentrow, gamestatus) processmovement (amaze) currentrow, currentcolumn) Executable program Step 1: A programmer writes a program in a human understandable form. Step 2: A translator converts the program into a computer understandable form
2 What Your Will Be Writing/Translating Your Programs With In This Class Writing programs this semester: Programming language: Python (actually it s a modified version of Python called JPython or the JES version of the Python programming language ) - Starting tutorial: - Online documentation: - My old CPSC 217 notes: Software to write/translate your Python programs: JES - Quick introduction: Where You Can Run JES Lab computers: JES is installed and running on all the computers in both 203 labs Installing on your own computer (Windows, Mac, Linux) 1 : OR 1 Java is needed run JES so if you don t have it installed then you should download it as well
3 Resources My completed example programs can be found on the course web page under the following link: Getting Started At Home 1 Step 1: Download the version appropriate to your computer (Windows, Mac, Linux). Uncompress the compressed (zip format) file using the appropriate program (in Windows it s built into the operating system). Right click on the downloaded file: 1 Note: It is NOT required for this course that you install JES at home. No warranties or guarantees of service are provided for this program (i.e., we aren t responsible if you inadvertently damage your computer during the installation process).
4 Getting Started At Home (2) Pick a location to extract the files to that you will remember: Note: to keep it simple any data files (e.g., images) that you need for your programs should be stored in this folder/directory. Getting Started At Home (3) To start the program click on the JES icon:
5 Once JES Has Been Started (Home Or In The Lab) The splash screen will first load (it may stay on a few seconds even with a fast computer) JES Built in help for using JES and for some programming concepts in JPython Type in your programs here Type in your commands (e.g., run the program that you just entered) here
6 File Operations Similar to a text editor (e.g., notepad) and are used in conjunction with the creation of your programs (load, save, print etc.) The Basic Structure Of A Program In JES Format: def program name (): Body of the program 1 Indent the body using three spaces (or at least make it consistent throughout). Example: def start (): print Starting my first program! 1 This is the part that actually completes actions such as: displaying messages onscreen, loading a picture from file, performing a calculation etc.
7 Creating And Running Your First Program Step 1: Type in your program in the editing area: Creating And Running Your First Program (2) Step 2: Load your program so it can be translated into binary. (Currently your program has been loaded into the editor but not loaded into the JES translator). The file menu affects the editor and not the translator (e.g., open doesn t load the program) Load your program here Program hasn t been loaded yet
8 Creating And Running Your First Program (2) Step 3: When you run your program JES will ask if you want to save it. Save it with a file name that ends in dot-py (e.g., start.py) Creating And Running Your First Program Step 4: Run your program in the command area IMPORTANT: the name that you type in to run the program must match the program name specified here Running program called start The effect of running your program is displayed immediately after you run it.
9 Storing Information When writing a program there will sometimes be a need to store information e.g., to perform a calculation. Information is stored in a computer program by using a variable. Variables Set aside a location in memory Used to store information (temporary) This location can store one piece of information At most the information will be accessible as long as the program runs Some of the types of information which can be stored in variables: Integer (num = 10) Real numbers (num = 10.5) Strings (message = Not happy! >-< ) Picture from Computers in your future by Pfaffenberger B
10 Arithmetic Operators Operator = + - * / % ** Description Assignment Addition Subtraction Multiplication Division Modulo Exponent Example num = 7 num = num = 6-4 num = 5 * 4 num = 25 / 5 num = 8 % 3 num = 9 ** 2 Displaying Output When there s a need to display information onscreen: Status messages or instructions Contents of variables
11 Displaying String Output Displays information or messages in the command area of JES. Example: Print: A command to display information In this case, everything between the quotes will appear in the command area (string = series of characters). Displaying String Output Format: print <string of characters> Example: def outputexample (): print Please don t display this message!
12 Format: Displaying The Contents Of Variables print <name of variable> Example: def example1 (): num = 10 print num Displaying Mixed Output Strings and the contents of variables can be intermixed with a single print statement. Format: print <string>, <variable name>... Example: Available online and is called profit.py : def profit (): income = 2000 expenses = 1500 profit = income - expenses print "Income: ", income, " Expenses: ", expenses, " Profit: ", profit
13 Working With Picture Variables One of the strengths of JES is the ease at which multimedia files can be incorporated in a computer program. Example: Available online and is called picture1.py, requires that you also download and save the image called lion.jpg to the folder where you are running JES from). def picture1(): picture = makepicture ("lion.jpg") show (picture) Getting Input In JES it can be done as the program runs. Example: How to specify the name of the images as the program runs. (Available online and is called picture2.py ): def picture2 (file1,file2): picture1 = makepicture(file1) show(picture1) picture2 = makepicture(file2) show(picture2) To run this program you must enter the name of two images as you run the program in the command area E.g., picture2("angel.jpg","valerie.jpg")
14 Getting A File Dialog Box Example: Available online and is called picture3.py def picture3(): filename = pickafile() mypicture = makepicture (filename) show (mypicture) What To Do If A Program Needs To Choose Among Alternatives? Employ branching/decision-making Each alternative involves asking a true/false (Boolean) question The answer to the question determines how the program reacts
15 Example Of The Need For Branching Is income below $10,000? Nominal income deduction Eligible for social assistance True False True Income tax = 20% False etc. Is income between $10K - $20K? Some Types Of Branching Mechanisms In JES If If-else Compound decision making Nested decision making
16 To be used when a true/false question (Boolean expression) is asked and: The program reacts one way if the question evaluates to true Example: If person is a senior citizen then give a 25% discount. If Decision Making With An If Question? True Execute a statement or statements False Remainder of the program
17 The If Decision making: checking if a condition is true (in which case something should be done). Format: if (Boolean expression): body Note: Indenting the body is mandatory! The If (2) Example: Available online and is called ifexample1.py def ifexample1 (age): if (age >= 18): print "Adult" print "Tell me more"
18 Types Of Comparisons Python Mathematical operator equivalent Meaning Example < < Less than 5 < 3 > > Greater than 5 > 3 == = Equal to 5 == 3 <= Less than or equal to 5 <= 5 >= Greater than or equal to 5 >= 4 <> Not equal to 5 <> 5 OR!= 5!= 5 If (Simple Body) Body of the if consists of a single statement Format: Indenting used to indicate what statement is the body if (Boolean expression): s1 s2 Example: if (num == 1): print Body of the if print After body Body
19 Body of the if consists of multiple statements Format: if (Boolean expression): s n+1 s 1 s 2 : s n If (Compound Body) Body End of the indenting denotes the end of decision-making If (Compound Body(2)) Example: Available online and is called ifexample2.py def ifexample2 (income): taxcredit = 0 taxrate = 0.2; if (income < 10000): print Eligible for social assistance taxcredit = 100 tax = (income * taxrate) taxcredit print tax
20 Decision Making With An If : Summary Used when a question (Boolean expression) evaluates only to a true or false value (Boolean): If the question evaluates to true then the program reacts differently. It will execute a body after which it proceeds to execute the remainder of the program (which follows the if construct). If the question evaluates to false then the program doesn t react different. It just executes the remainder of the program (which follows the if construct). If-Else To be used when a true/false question (Boolean expression) is asked and: The program reacts one way if the question evaluates to true The program reacts another way if the question evaluates to false Example: If income is greater than $10,000 then calculate taxes owed, otherwise calculate subsidy to be given back to the person.
21 Decision Making With An If-Else Question? True Execute a statement or statements False Execute a statement or statements Remainder of the program The If-Else Decision making: checking if a condition is true (in which case something should be done) but also reacting if the condition is not true (false). Format: if (Boolean expression): body of 'if' else: body of 'else' additional statements
22 If-Else Construct (2) Example: Available online and is called ifexample3.py def ifexample3 (age): if (age >= 18): print Adult else: print Not an adult print Tell me more about yourself If-Else (Compound Body(2)) Example: Available online and is called ifexample4.py def ifexample4 (income): taxcredit = 0 if (income < 10000): print Eligible for social assistance taxcredit = 100 taxrate = 0.1 else: print Not eligible for social assistance taxrate = 0.2 tax := (income * taxrate) taxcredit print tax
23 Quick Summary: If Vs. If-Else If: Evaluate a Boolean expression (ask a question) If the expression evaluates to true then execute the body of the if. No additional action is taken when the expression evaluates to false. Use when your program evaluates a Boolean expression and code will be executed only when the expression evaluates to true. If-Else: Evaluate a Boolean expression (ask a question) If the expression evaluates to true then execute the body of the if. If the expression evaluates to false then execute the body of the else. Use when your program evaluates a Boolean expression and different code will execute if the expression evaluates to true than if the expression evaluates to false. Decision-Making With Multiple Expressions Format: if (Boolean expression) logical operator (Boolean expression): body Example: if (x > 0) and (y > 0): print X is positive, Y is positive
24 Decision-Making With Multiple Expressions (2) Commonly used logical operators in Python or and not Forming Compound Boolean Expressions With The OR Operator Format: if (Boolean expression) or (Boolean expression): body Example: if (gpa > 3.7) or (yearsjobexperience > 5): print You are hired
25 Format: Forming Compound Boolean Expressions With The AND Operator if (Boolean expression) and (Boolean expression): body Example: if (yearsonjob <= 2) and (salary > 50000): print You are fired Forming Compound Boolean Expressions With The NOT Operator Format: if not (Boolean expression): body Example: if not (x == 0): print X is anything but zero
26 Nested Decision Making Used when there s a need to qualify questions. One or more questions are asked only if another question evaluates to true. Example: Looking for people to hire Question 1: Did the candidate complete an advanced graduate degree (masters or doctoral degree) - (The following questions are asked only if the person does have a graduate degree) - Question 1A: Is the grade point 3.7 or above. - Question 1B: Does the person have 5 or more years of work experience. This is referred to as nested decision making because some questions are dependent on the answer to other questions (dependent questions are nested inside another question). Nested Decision Making Decision making is dependent. The first decision must evaluate to true before successive decisions are even considered for evaluation. Question 1? True Question 2? True Statement or statements False False Remainder of the program
27 Nested Decision Making One decision is made inside another. Outer decisions must evaluate to true before inner decisions are even considered for evaluation. Format: if (Boolean expression): if (Boolean expression): inner body Outer body Inner body Nested Decision Making (2) Example: Available online and is called ifexample5.py def ifexample5 (graddegree, gpa, experience): status = "Not hired" if (graddegree == 'y'): if (gpa >= 3.7): status = "Hired" if (experience >= 5): status = "Hired" print "Employment status: ", status
28 Review: What Decision Making Mechanisms Are Available/When To Use Them Construct If If-else Compound decision making Nested decision making When To Use Evaluate a Boolean expression and execute some code (body) if it s true Evaluate a Boolean expression and execute some code (first body) if it s true, execute alternate code (second body) if it s false More than one Boolean expression must be evaluated. The outer Boolean expression must be true before the inner expression will even be evaluated. Common Errors 1. Inconsistent indenting (remember that you should only indent the body of something).
29 Common Errors (2) 2. Forgetting to load your program before trying to run it. Common Errors (3) 3. Your program cannot find a file that it needs. It can t find the file angel.jpg to make the picture
30 Common Errors (3) 3. Problem: Your program cannot find a file that it needs. Solution: Put all the files (pictures, sounds, videos) in the same folder where you put JES. Example Common Errors (4) 4. Forgetting required parts of the program Forgetting the word def and/or the name of the program (Erroneous version) print hello (Fixed version) def programname (): print hello Forgetting the brackets and/or the colon: def programname print jello
31 Common Errors (5) 4. Forgetting required parts of the program Forgetting the quotes when displaying a string of characters: def programname (): print hello Mismatching quotes: def programname print jello Common Errors (6) 5. Typing in your JES program using a word processor or other program that allows for powerful text formatting. These errors can be very tough to find and fix because there is no visible error in your program ( computers suck! )
32 You Should Now Know How to create and run a program using JES How the print statement displays information What are variables and how to use them in a program How to load and display images in a program How to get input as a program runs The way in which decision making works with computer programs How to write and trace (determine the execution and output of) programs that employ: if, else-if, compound decision making and nested decision making mechanisms
Making Decisions In Python
Making Decisions In Python In this section of notes you will learn how to have your programs choose between alternative courses of action. Decision Making Is All About Choices My next vacation? Images:
More informationMaking Decisions In Pascal
Making Decisions In Pascal In this section of notes you will learn how to have your Pascal programs choose between alternative courses of action High Level View Of Decision Making For The Computer Is income
More informationMaking Decisions In Python
Branching and making decisions 1 Making Decisions In Python In this section of notes you will learn how to have your programs choose between alternative courses of action. Recap: Programs You ve Seen So
More informationDecisions, Decisions. Testing, testing C H A P T E R 7
C H A P T E R 7 In the first few chapters, we saw some of the basic building blocks of a program. We can now make a program with input, processing, and output. We can even make our input and output a little
More informationIntro 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 informationMaking Decisions In Pascal
Making Decisions In Pascal In this section of notes you will learn how to have your Pascal programs choose between alternative courses of action High Level View Of Decision Making For The Computer??? True
More informationIntroduction to JES and Programming. Installation
Introduction to JES and Programming Installation Installing JES and starting it up Windows users: Just copy the folder Double-click JES application Mac users: Just copy the folder Double-click the JES
More informationCMSC 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 informationIntroduction To C Programming
Introduction To C Programming You will learn basic programming concepts in a low level procedural language. Programming Languages There are many different languages - (Just a small sample): C, C++, C#,
More informationLanguages. Solve problems using a computer, give the computer instructions. Remember our diaper-changing exercise?
Languages Solve problems using a computer, give the computer instructions. Remember our diaper-changing exercise? Talk the talk Speak its language High-level: Python, C++, Java Low-level: machine language,
More informationMaking Decisions In Pascal In this section of notes you will learn how to have your Pascal programs to execute alternatives
Making Decisions In Pascal In this section of notes you will learn how to have your Pascal programs to execute alternatives Decision-Making In Pascal Decisions are questions that are either true or false
More informationGetting Started With Python Programming
Getting Started With Python Programming How are computer programs created Variables and constants Input and output Operators Common programming errors Advanced techniques for formatting text output Reminder:
More informationJavaScript. Backup Your Work Frequently!
JavaScript You will learn advanced programming tools in JavaScript that allow your programs to automatically repeat and to run alternate courses of execution. Pictures courtesy of Backup Your Work Frequently!
More informationChapter 2: Introduction to Programming
Chapter 2: Introduction to Programming 1 Chapter Learning Objectives 2 Installation Installing JES and starting it up Go to http://www.mediacomputation.org and get the version of JES for your computer.
More informationChapter 2: Introduction to Programming
Chapter 2: Introduction to Programming Chapter Learning Objectives Installation Installing JES and starting it up Go to http://www.mediacomputation.org and get the version of JES for your computer. If
More informationage = 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 informationFlow Control: Branches and loops
Flow Control: Branches and loops In this context flow control refers to controlling the flow of the execution of your program that is, which instructions will get carried out and in what order. In the
More informationIntroduction to Computation for the Humanities and Social Sciences. CS 3 Chris Tanner
Introduction to Computation for the Humanities and Social Sciences CS 3 Chris Tanner Lecture 4 Python: Variables, Operators, and Casting Lecture 4 [People] need to learn code, man I m sick with the Python.
More informationText 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 informationHello, World! An Easy Intro to Python & Programming. Jack Rosenthal
An Easy Intro to Python & Programming Don t just buy a new video game, make one. Don t just download the latest app, help design it. Don t just play on your phone, program it. No one is born a computer
More informationIntroduction to Computer Science. Course Goals. Python. Slides02 - Intro to Python.key - September 15, 2015
Introduction to Computer Science Barbara Lerner (blerner@mtholyoke.edu) https://www.mtholyoke.edu/~blerner/cs100/ 1 Office Clapp 227, x3250 Mon 1-2 Tues 4-5 Wed. 11-12 Thurs 3:30-4:30 or by appointment
More informationChapter 2. Designing a Program. Input, Processing, and Output Fall 2016, CSUS. Chapter 2.1
Chapter 2 Input, Processing, and Output Fall 2016, CSUS Designing a Program Chapter 2.1 1 Algorithms They are the logic on how to do something how to compute the value of Pi how to delete a file how to
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 informationExercise 1 Using Boolean variables, incorporating JavaScript code into your HTML webpage and using the document object
CS1046 Lab 5 Timing: This lab should take you approximately 2 hours. Objectives: By the end of this lab you should be able to: Recognize a Boolean variable and identify the two values it can take Calculate
More informationBuilding Java Programs. Chapter 2: Primitive Data and Definite Loops
Building Java Programs Chapter 2: Primitive Data and Definite Loops Copyright 2008 2006 by Pearson Education 1 Lecture outline data concepts Primitive types: int, double, char (for now) Expressions: operators,
More informationDEBUGGING 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 informationCS101 Lecture 24: Thinking in Python: Input and Output Variables and Arithmetic. Aaron Stevens 28 March Overview/Questions
CS101 Lecture 24: Thinking in Python: Input and Output Variables and Arithmetic Aaron Stevens 28 March 2011 1 Overview/Questions Review: Programmability Why learn programming? What is a programming language?
More informationChapter 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 informationObjectives. Chapter 4: Control Structures I (Selection) Objectives (cont d.) Control Structures. Control Structures (cont d.) Relational Operators
Objectives Chapter 4: Control Structures I (Selection) In this chapter, you will: Learn about control structures Examine relational and logical operators Explore how to form and evaluate logical (Boolean)
More informationPython for Non-programmers
Python for Non-programmers A Gentle Introduction 1 Yann Tambouret Scientific Computing and Visualization Information Services & Technology Boston University 111 Cummington St. yannpaul@bu.edu Winter 2013
More informationIntroduction to Programming with JES
Introduction to Programming with JES Titus Winters & Josef Spjut October 6, 2005 1 Introduction First off, welcome to UCR, and congratulations on becoming a Computer Engineering major. Excellent choice.
More informationChapter 4: Control Structures I (Selection) Objectives. Objectives (cont d.) Control Structures. Control Structures (cont d.
Chapter 4: Control Structures I (Selection) In this chapter, you will: Objectives Learn about control structures Examine relational and logical operators Explore how to form and evaluate logical (Boolean)
More informationJython. secondary. memory
2 Jython secondary memory Jython processor Jython (main) memory 3 Jython secondary memory Jython processor foo: if Jython a
More informationTOPIC 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 informationGetting Started With Pascal Programming
Getting Started With Pascal Programming How are computer programs created What is the basic structure of a Pascal Program Variables and constants Input and output Pascal operators Common programming errors
More informationComputer Programming. Basic Control Flow - Loops. Adapted from C++ for Everyone and Big C++ by Cay Horstmann, John Wiley & Sons
Computer Programming Basic Control Flow - Loops Adapted from C++ for Everyone and Big C++ by Cay Horstmann, John Wiley & Sons Objectives To learn about the three types of loops: while for do To avoid infinite
More informationChapter 3. More Flow of Control. Copyright 2008 Pearson Addison-Wesley. All rights reserved.
Chapter 3 More Flow of Control Overview 3.1 Using Boolean Expressions 3.2 Multiway Branches 3.3 More about C++ Loop Statements 3.4 Designing Loops Slide 3-3 Flow Of Control Flow of control refers to the
More informationSPARK-PL: Introduction
Alexey Solovyev Abstract All basic elements of SPARK-PL are introduced. Table of Contents 1. Introduction to SPARK-PL... 1 2. Alphabet of SPARK-PL... 3 3. Types and variables... 3 4. SPARK-PL basic commands...
More informationOur 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 informationProgramming for Engineers in Python. Autumn
Programming for Engineers in Python Autumn 2011-12 Plan Administration: Course site Homework submission guidelines Working environment Python: Variables Editor vs. shell Homework 0 Python Cont. Conditional
More informationWeek - 01 Lecture - 04 Downloading and installing Python
Programming, Data Structures and Algorithms in Python Prof. Madhavan Mukund Department of Computer Science and Engineering Indian Institute of Technology, Madras Week - 01 Lecture - 04 Downloading and
More informationOperators. Java operators are classified into three categories:
Operators Operators are symbols that perform arithmetic and logical operations on operands and provide a meaningful result. Operands are data values (variables or constants) which are involved in operations.
More informationLesson 6A Loops. By John B. Owen All rights reserved 2011, revised 2014
Lesson 6A Loops By John B. Owen All rights reserved 2011, revised 2014 Topic List Objectives Loop structure 4 parts Three loop styles Example of a while loop Example of a do while loop Comparison while
More informationCMSC 201 Computer Science I for Majors
CMSC 201 Computer Science I for Majors Lecture 02 Intro to Python Syllabus Last Class We Covered Grading scheme Academic Integrity Policy (Collaboration Policy) Getting Help Office hours Programming Mindset
More informationCS 31: Intro to Systems C Programming. Kevin Webb Swarthmore College September 13, 2018
CS 31: Intro to Systems C Programming Kevin Webb Swarthmore College September 13, 2018 Reading Quiz Agenda Basics of C programming Comments, variables, print statements, loops, conditionals, etc. NOT the
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 informationChapter Goals. Contents LOOPS
CHAPTER 4 LOOPS Slides by Donald W. Smith TechNeTrain.com Final Draft Oct 30, 2011 Chapter Goals To implement while, for, and do loops To hand-trace the execution of a program To become familiar with common
More informationAccelerating Information Technology Innovation
Accelerating Information Technology Innovation http://aiti.mit.edu/program/philippines-summer-2012/ Philippines Summer 2012 Lecture 1 Introduction to Python June 19, 2012 Agenda About the Course What is
More informationCSE 115. Introduction to Computer Science I
CSE 115 Introduction to Computer Science I Note about posted slides The slides we post will sometimes contain additional slides/content, beyond what was presented in any one lecture. We do this so the
More informationEclipse Environment Setup
Eclipse Environment Setup Adapted from a document from Jeffrey Miller and the CS201 team by Shiyuan Sheng. Introduction This lab document will go over the steps to install and set up Eclipse, which is
More informationCS2900 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\n is used in a string to indicate the newline character. An expression produces data. The simplest expression
Chapter 1 Summary Comments are indicated by a hash sign # (also known as the pound or number sign). Text to the right of the hash sign is ignored. (But, hash loses its special meaning if it is part of
More informationProgramming for Engineers in Python. Recitation 1
Programming for Engineers in Python Recitation 1 Plan Administration: Course site Homework submission guidelines Working environment Python: Variables Editor vs. shell Homework 0 Python Cont. Conditional
More information4.1. Chapter 4: Simple Program Scheme. Simple Program Scheme. Relational Operators. So far our programs follow a simple scheme
Chapter 4: 4.1 Making Decisions Relational Operators Simple Program Scheme Simple Program Scheme So far our programs follow a simple scheme Gather input from the user Perform one or more calculations Display
More informationCPSC 231: Loops In Python
Repetition using loops 1 CPSC 231: Loops In Python In this section of notes you will learn how to rerun parts of your program without duplicating instructions. Repetition: Computer View Continuing a process
More informationCSCE 110: Programming I
CSCE 110: Programming I Sample Questions for Exam #1 February 17, 2013 Below are sample questions to help you prepare for Exam #1. Make sure you can solve all of these problems by hand. For most of the
More informationCPSC 231: Loops In Python
Repetition using loops 1 CPSC 231: Loops In Python In this section of notes you will learn how to rerun parts of your program without duplicating instructions. Repetition: Computer View Continuing a process
More informationCP215 Application Design
CP215 Application Design Alphabet's Project Loon to deliver Internet this year in Indonesia Tech News! Tech News! Alphabet's Project Loon to deliver Internet this year in Indonesia Casey Reas computational
More information3 Programming. Jalal Kawash Mandatory: Chapter 5 Section 5.5 Jalal s resources: How to movies and example programs available at:
3 Programming 1 Mandatory: Chapter 5 Section 5.5 Jalal s resources: How to movies and example programs available at: http://pages.cpsc.ucalgary.ca/~kawash/peeking/alice-how-to.html JT s resources: www.cpsc.ucalgary.ca/~tamj/203/extras/alice
More informationLoops In Python. In this section of notes you will learn how to rerun parts of your program without having to duplicate the code.
Loops In Python In this section of notes you will learn how to rerun parts of your program without having to duplicate the code. Application Of Loops In Actual Software Play again? Re-running specific
More informationConditional Expressions and Decision Statements
Conditional Expressions and Decision Statements June 1, 2015 Brian A. Malloy Slide 1 of 23 1. We have introduced 5 operators for addition, subtraction, multiplication, division, and exponentiation: +,
More informationC++ Data Types. 1 Simple C++ Data Types 2. 3 Numeric Types Integers (whole numbers) Decimal Numbers... 5
C++ Data Types Contents 1 Simple C++ Data Types 2 2 Quick Note About Representations 3 3 Numeric Types 4 3.1 Integers (whole numbers)............................................ 4 3.2 Decimal Numbers.................................................
More informationCS1114: Matlab Introduction
CS1114: Matlab Introduction 1 Introduction The purpose of this introduction is to provide you a brief introduction to the features of Matlab that will be most relevant to your work in this course. Even
More informationBASIC 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 informationUsing IDLE for
Using IDLE for 15-110 Step 1: Installing Python Download and install Python using the Resources page of the 15-110 website. Be sure to install version 3.3.2 and the correct version depending on whether
More informationCMSC201 Computer Science I for Majors
CMSC201 Computer Science I for Majors Lecture 03 Operators All materials copyright UMBC and Dr. Katherine Gibson unless otherwise noted Variables Last Class We Covered Rules for naming Different types
More informationEx: If you use a program to record sales, you will want to remember data:
Data Variables Programs need to remember values. Ex: If you use a program to record sales, you will want to remember data: A loaf of bread was sold to Sione Latu on 14/02/19 for T$1.00. Customer Name:
More informationHello World! Computer Programming for Kids and Other Beginners. Chapter 1. by Warren Sande and Carter Sande. Copyright 2009 Manning Publications
Hello World! Computer Programming for Kids and Other Beginners by Warren Sande and Carter Sande Chapter 1 Copyright 2009 Manning Publications brief contents Preface xiii Acknowledgments xix About this
More informationIntro. 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 informationMidterms Save the Dates!
University of British Columbia CPSC 111, Intro to Computation Alan J. Hu Primitive Data Types Arithmetic Operators Readings Your textbook is Big Java (3rd Ed). This Week s Reading: Ch 2.1-2.5, Ch 4.1-4.2.
More informationCOSC 122 Computer Fluency. Programming Basics. Dr. Ramon Lawrence University of British Columbia Okanagan
COSC 122 Computer Fluency Programming Basics Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca Key Points 1) We will learn JavaScript to write instructions for the computer.
More informationCS Summer 2013
CS 1110 - Summer 2013 intro to programming -- how to think like a robot :) we use the Python* language (www.python.org) programming environments (many choices): Eclipse (free from www.eclipse.org), or
More informationBuilding Java Programs
Building Java Programs Chapter 2 Lecture 2-1: Expressions and Variables reading: 2.1-2.2 1 2 Data and expressions reading: 2.1 3 The computer s view Internally, computers store everything as 1 s and 0
More informationCS1 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 informationExpressions and Data Types CSC 121 Spring 2015 Howard Rosenthal
Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types
More informationGetting Started. Excerpted from Hello World! Computer Programming for Kids and Other Beginners
Getting Started Excerpted from Hello World! Computer Programming for Kids and Other Beginners EARLY ACCESS EDITION Warren D. Sande and Carter Sande MEAP Release: May 2008 Softbound print: November 2008
More informationObject-Oriented Programming
Object-Oriented Programming Java Syntax Program Structure Variables and basic data types. Industry standard naming conventions. Java syntax and coding conventions If Then Else Case statements Looping (for,
More informationCSCE 110 Programming I
CSCE 110 Programming I Basics of Python (Part 1): Variables, Expressions, and Input/Output Dr. Tiffani L. Williams Department of Computer Science and Engineering Texas A&M University Spring 2013 Tiffani
More information1. BASICS OF PYTHON. JHU Physics & Astronomy Python Workshop Lecturer: Mubdi Rahman
1. BASICS OF PYTHON JHU Physics & Astronomy Python Workshop 2017 Lecturer: Mubdi Rahman HOW IS THIS WORKSHOP GOING TO WORK? We will be going over all the basics you need to get started and get productive
More informationLoops In Python. In this section of notes you will learn how to rerun parts of your program without having to duplicate the code.
Loops In Python In this section of notes you will learn how to rerun parts of your program without having to duplicate the code. The Need For Repetition (Loops) Writing out a simple counting program (1
More informationControl Structures. A program can proceed: Sequentially Selectively (branch) - making a choice Repetitively (iteratively) - looping
Control Structures A program can proceed: Sequentially Selectively (branch) - making a choice Repetitively (iteratively) - looping Conditional Execution if is a reserved word The most basic syntax for
More informationCMSC 201 Fall 2016 Lab 13 More Recursion
CMSC 201 Fall 2016 Lab 13 More Recursion Assignment: Lab 13 More Recursion Due Date: During discussion, December 5th through 8th Value: 10 points Part 1A: What is Recursion? So far this semester, we ve
More informationWeb Application Development (WAD) V th Sem BBAITM(Unit-1) By: Binit Patel
Web Application Development (WAD) V th Sem BBAITM(Unit-1) By: Binit Patel Introduction: PHP (Hypertext Preprocessor) was invented by Rasmus Lerdorf in 1994. First it was known as Personal Home Page. Later
More informationCSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch
CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch Purpose: We will take a look at programming this week using a language called Scratch. Scratch is a programming language that was developed
More informationUNIT- 3 Introduction to C++
UNIT- 3 Introduction to C++ C++ Character Sets: Letters A-Z, a-z Digits 0-9 Special Symbols Space + - * / ^ \ ( ) [ ] =!= . $, ; : %! &? _ # = @ White Spaces Blank spaces, horizontal tab, carriage
More informationThis tutorial will teach you about operators. Operators are symbols that are used to represent an actions used in programming.
OPERATORS This tutorial will teach you about operators. s are symbols that are used to represent an actions used in programming. Here is the link to the tutorial on TouchDevelop: http://tdev.ly/qwausldq
More informationHelp File on C++ and Programming at CSUSM by Rika Yoshii
Help File on C++ and Programming at CSUSM by Rika Yoshii Compiler versus Editor empress.csusm.edu is a machine that you remotely log into from anywhere using putty, empress.csusm.edu uses the operating
More informationCMSC 201 Spring 2017 Lab 12 Recursion
CMSC 201 Spring 2017 Lab 12 Recursion Assignment: Lab 12 Recursion Due Date: During discussion, May 1st through May 4th Value: 10 points (8 points during lab, 2 points for Pre Lab quiz) This week s lab
More informationThe first program: Little Crab
Chapter 2 The first program: Little Crab topics: concepts: writing code: movement, turning, reacting to the screen edges source code, method call, parameter, sequence, if-statement In the previous chapter,
More informationReview: Exam 1. Your First C++ Program. Declaration Statements. Tells the compiler. Examples of declaration statements
Review: Exam 1 9/20/06 CS150 Introduction to Computer Science 1 1 Your First C++ Program 1 //*********************************************************** 2 // File name: hello.cpp 3 // Author: Shereen Khoja
More informationCS177 Recitation. Functions, Booleans, Decision Structures, and Loop Structures
CS177 Recitation Functions, Booleans, Decision Structures, and Loop Structures Functions Collection of instructions that perform a task as: o Printing your name and course. o Calculating the average of
More informationMagic Set Editor 2 Template Creation Tutorial
Magic Set Editor 2 Template Creation Tutorial Basics Several types of folders, called packages, must be set up correctly to create any template for MSE. (All files related to MSE template creation are
More informationBasic Uses of JavaScript: Modifying Existing Scripts
Overview: Basic Uses of JavaScript: Modifying Existing Scripts A popular high-level programming languages used for making Web pages interactive is JavaScript. Before we learn to program with JavaScript
More informationInitial Coding Guidelines
Initial Coding Guidelines ITK 168 (Lim) This handout specifies coding guidelines for programs in ITK 168. You are expected to follow these guidelines precisely for all lecture programs, and for lab programs.
More informationChapter 4: Control Structures I (Selection)
Chapter 4: Control Structures I (Selection) 1 Objectives Learn about control structures Examine relational and logical operators Explore how to form and evaluate logical (Boolean) expressions Discover
More informationControl Structure: Selection
Control Structure: Selection Knowledge: Understand various concepts of selection control structure Skill: Be able to develop a program containing selection control structure Selection Structure Single
More informationPython Unit
Python Unit 1 1.1 1.3 1.1: OPERATORS, EXPRESSIONS, AND VARIABLES 1.2: STRINGS, FUNCTIONS, CASE SENSITIVITY, ETC. 1.3: OUR FIRST TEXT- BASED GAME Python Section 1 Text Book for Python Module Invent Your
More informationBASIC 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 informationIntroduction to Bioinformatics
Introduction to Bioinformatics Variables, Data Types, Data Structures, Control Structures Janyl Jumadinova February 3, 2016 Data Type Data types are the basic unit of information storage. Instances of
More informationMore Scripting Techniques Scripting Process Example Script
More Scripting Techniques Scripting Process Example Script 1 arguments to scripts positional parameters input using read exit status test program, also known as [ if statements error messages 2 case statement
More information