CS2900 Introductory Programming with Python and C++ Kevin Squire LtCol Joel Young Fall 2007
|
|
- Brendan Sharp
- 5 years ago
- Views:
Transcription
1 CS2900 Introductory Programming with Python and C++ Kevin Squire LtCol Joel Young Fall 2007
2 Course Web Site All course related materials will be posted there Syllabus Notes Copies of the text Examples K. Squire - LtCol J. Young - CS2900 2
3 Text How to Think like a Computer Scientist Python and C++ versions Available here: Order it if you like Download pdf or html version We will cover most of chapters 1-8 before moving on to C++ K. Squire - LtCol J. Young - CS2900 3
4 Other References The definitive source Other documentation K. Squire - LtCol J. Young - CS2900 4
5 Reading Please read the Foreword and Preface Provide interesting insight into the language selection rationale Chapters 1 and 2 K. Squire - LtCol J. Young - CS2900 5
6 Introduction Introduction to Computer Programming Introduction Introductory programming with Python Introduction to C++ Assumes no prior programming experience K. Squire - LtCol J. Young - CS2900 6
7 Programming Languages Various categories/subcategories High Level Languages Compiled C/C++, Ada, Fortran, Interpreted Perl, Ruby, Python, Basic, Hybrid Java, C#, Assembly Language Machine Language Low Level Languages K. Squire - LtCol J. Young - CS2900 7
8 Machine Language The lowest level a programmer can use Computer engineers may go even lower The ONLY language a CPU understands Unique to each class of CPU Ones and Zeros They represent the Ons and Offs or High and Low voltages used by the transistors within a computer K. Squire - LtCol J. Young - CS2900 8
9 Machine Language (cont) Different sequences of 1s and 0s have different meanings Assigned by the designers of the CPU A small program, how readable is this? Very tough to find errors K. Squire - LtCol J. Young - CS2900 9
10 Assembly Language Human readable form of machine language Each meaningful sequence of 1s and 0s is assigned a name called a mnemonic Easier for humans to remember Same program in Motorola Assembly MOVE BASEPAY, D0 ADD OVERTIME, D0 MOVE D0, GROSSPAY K. Squire - LtCol J. Young - CS
11 Assembly Language (cont) Easier to find errors Like machine language, assembly language unique to each CPU Not understood by CPU Because it is really just text A special program called an assembler translates assembly language into 1s and 0s The first assembler had to be written in machine language! K. Squire - LtCol J. Young - CS
12 High Level Languages Many different types Attempt to be native language like Closer to english than assembly Independent of CPU Some type of program must translate your program into assembly/machine language before it can run GrossPay = BasePay + Overtime; K. Squire - LtCol J. Young - CS
13 High Level Languages (cont) Three main types Compiled C++, Pascal, Ada, Fortran, Cobol, Interpreted Lisp, Basic, Perl, Python, Hybrid Java, C#, In all cases, the author enters text containing programming statements that conform to a specific language K. Squire - LtCol J. Young - CS
14 Compiled Languages A program called a compiler translates high level statements into assembly/machine language Think of a compiler as an assembler on steroids The ultimate output of the compilation process is what we often called an executable file The executable is a machine language equivalent If a programmer makes a change to a program, it must be re-compiled before the changes can take effect K. Squire - LtCol J. Young - CS
15 Compiled Languages (cont) cpu independent cpu dependent Program File (text) Compiler (machine language) Executable File (machine language) Operating System CPU K. Squire - LtCol J. Young - CS
16 Interpreted Languages A machine language version of the program is never generated A special program called an interpreter carries out a program s steps one at a time The interpreter is a machine language program It provides a layer of insulation between the programmer and the CPU Any change to a program takes affect the next time the program is interpreted K. Squire - LtCol J. Young - CS
17 Interpreted Languages (cont) cpu independent cpu dependent Program File (text) Interpreter (machine language) Operating System CPU K. Squire - LtCol J. Young - CS
18 Hybrid Languages Compiled but NOT to machine language Compiler generates an intermediate language In the case of Java, we call this Java Byte Code The intermediate language file is then interpreted In the case of Java, the interpreter is called the Java Virtual Machine The virtual machine is like a software CPU Compiled programs can run on any CPU for which a virtual machine exists K. Squire - LtCol J. Young - CS
19 Hybrid Languages (cont).java file.class file cpu independent Program File (text) Intermediate File (intermediate language) cpu dependent Compiler (machine language) Interpreter (machine language) java Operating System javac CPU K. Squire - LtCol J. Young - CS
20 Things For You To Do Windows users Download and install cygwin, making sure you install the Python package. Unix/Mac users Make sure you have a Python interpreter for your flavor of Unix/Mac Good starting point for all things Python Windows users, we recommend cygwin s Python over the standalone Python offered here K. Squire - LtCol J. Young - CS
21 Editing Programs Program text (also called source code) is just that, text As such it can be edited with ANY text editor Most python installations come with an editor named IDLE Allow you to run python programs from within the editor The combination of editing features with execution capabilities is often called an Integrated Development Environment or IDE for short K. Squire - LtCol J. Young - CS
22 Interactive vs. Batch Execution Or, as the text calls it command line vs. script mode Interactive mode Enter your program statements one at a time at a command prompt Each statement is processed after you type it Batch mode Enter your entire program into a text file Invoke the interpreter to process statements from your file rather than from the command line K. Squire - LtCol J. Young - CS
23 Getting Started A simple Python program (interactive mode) # python Shell prompt Command to invoke Python interpreter Python (#1, Oct , 13:58:00) [GCC (Red Hat )] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> print 'Welcome to Python' Welcome to Python >>> Python interpreter prompt Version info Python statement Statement output K. Squire - LtCol J. Young - CS
24 Batch Mode Example Use a text editor (notepad, vi, ) to create a file (welcome.py) containing the single line print 'Welcome to Python' Sample run # python welcome.py Welcome to Python # K. Squire - LtCol J. Young - CS
25 Additional Resources K. Squire - LtCol J. Young - CS
26 What is a Program From the text A program is a sequence of instructions that specifies how to perform a computation Generally composed of statements that Perform input or output (keyboard, disk, network, ) Perform a computation (mathematical or otherwise) Conditionally perform some actions as a result of a test (if it is raining, stand on your head) Repeat some action (As long as you are not tired run around in circles) K. Squire - LtCol J. Young - CS
27 Learning to Program Involves Learning the statements allowed by the language and correct ways to link them together The previous example shows a simple use of the print statement Learning how to manipulate data using those statements The previous example outputs the string data "Welcome to Python" K. Squire - LtCol J. Young - CS
28 Learning to Program also involves Learning how to recognize and correct mistakes Three broad categories of errors in programming Syntax errors Semantic errors Runtime errors K. Squire - LtCol J. Young - CS
29 Syntax Errors The programming equivalent of a typo The compiler/interpreter fails to recognize something as a valid statement in the language These prevent a program from running and must be corrected before moving on Compilers/interpreters often do their best to show you the problem Their best may not help you at all They can t guess your intent K. Squire - LtCol J. Young - CS
30 Semantic Errors A valid program does not always do what you want Computers only do what you tell them to do, not always what you wanted them to do If you fail to properly express yourself you will often be surprised by the results K. Squire - LtCol J. Young - CS
31 Runtime Errors Generally the result of some problem that occurs during program execution May result from something as drastic as hardware failures to something as simple as failing to check the validity of a user input How might a program behave if it asks for a number but you enter a letter? K. Squire - LtCol J. Young - CS
32 Debugging Debugging is the act of locating and correcting all semantic errors and understanding and properly reacting to the cause of any runtime errors you may encounter As such, debugging centers around observing/understanding the behavior of a running program K. Squire - LtCol J. Young - CS
33 What s Next The remainder of the course deals with how to put these pieces together Defining/describing/manipulating data Defining functions What functions do for us How to interact with functions Finding and fixing problems with our programs Software reuse Leveraging the work of others to make your life easier K. Squire - LtCol J. Young - CS
34 A Note Please don t ever judge the quality of a programming language by the simplicity of the Hello World program! K. Squire - LtCol J. Young - CS
35 Reading Please continue with Text chapter 3 Text chapter 4 K. Squire - LtCol J. Young - CS
36 Data No useful program exists without data Programmer s main challenge Identify data requirements Model appropriate data Define relationships between data Define interactions with data Obtain data Display/store data K. Squire - LtCol J. Young - CS
37 Some Common Data Values Numbers Integers: -1, 0, 1, Floating point: Strings Sequences of characters: "Hello World!" How many characters in the string above? Enclosed in single or double quotes Let's use double quotes as a convention, many other languages do K. Squire - LtCol J. Young - CS
38 Literals A literal is a specific instance of a type of data The examples on the previous slide were literal integers, floating point numbers, and strings If something is not a literal what is it? K. Squire - LtCol J. Young - CS
39 Variables Variables are symbolic names given to program items that may take on many values during program execution Similar to the variables you may be familiar with from mathematical expressions y = 10x + 15 (not a Python statement!!!) y and x are variables in the expression above 10 and 15 are literals K. Squire - LtCol J. Young - CS
40 Choosing Variable Names Programmers can choose (almost) any name they like to represent their data items Restrictions Names consist only of letters, numbers, and the underscore character Names can only begin with a letter or an underscore Python has a set of reserved words or keywords, none of which can be used as variable names (see text p. 14) K. Squire - LtCol J. Young - CS
41 Example Variable Names x name daysperyear (preferred for multi-word) months_per_year _total What values are associated with these variables? In the interpreter try: print x K. Squire - LtCol J. Young - CS
42 What Can You Store in Variables? In python, almost anything you want The interpreter keeps track of the type of data that a variable is representing at any given moment Try >>> z = 3 >>> type (z) >>> z = "hello" >>> type (z) K. Squire - LtCol J. Young - CS
43 Assignment The act of assigning a value to a variable You can t assign a value to a literal can you? One of the simplest of Python s statements Indicated using the = operator Examples x = 3 name = "John" daysperweek = 7 r = x Now what happens if you print x? How about r? K. Squire - LtCol J. Young - CS
44 Statements From the text A statement is an instruction that the Python interpreter can execute Statements typically carry out some action, and may or may not produce a visible result You have seen two statements so far print statement Assignment statement K. Squire - LtCol J. Young - CS
45 Operators Operators are one of the fundamental building blocks of expressions and statements Instruct the interpreter to perform a specific operation on one or more pieces of data (operands) K. Squire - LtCol J. Young - CS
46 Arithmetic Operators Addition/Subtraction: + - x + y 3 Multiplication/Division: * / z * 20 / g Exponentiation: ** 2 ** 8 Modulus: % 9 % 6 Parenthesis can be used to override operator precedence (see section 2.7 p 16) K. Squire - LtCol J. Young - CS
47 Important Note on Division Division of integers yields an integer Try: 16 / 5 Try: 16.0 / 5 The results of integer division are TRUNCATED NOT ROUNDED The // operator forces integer division >>> 7 // K. Squire - LtCol J. Young - CS
48 How About Strings? Consider "3" + "6" "3" + 6 "3" * "6" "3" * 6 "Addition" of two strings performs string concatenation "Multiplication" of a string by an integer performs string repetition K. Squire - LtCol J. Young - CS
49 Relational Operators Used to compare two values, result is either True or False (Section 4.2) Test for equality: == x == 3 Common mistake is to forget an = x = 3 is very different Test for inequality:!= a!= b response!= "quit" K. Squire - LtCol J. Young - CS
50 More Relational Operators Greater than: > month > 7 Greater than or equal: >= day >= "tuesday" Less than: < "Help" < "help" Less than or equal: <= percent <= 90 K. Squire - LtCol J. Young - CS
51 Expressions Expressions are programming constructs whose evaluation yields a value Simple expressions * 4 / "Just a string" color == "red" K. Squire - LtCol J. Young - CS
52 Types of Expressions Arithmetic Expressions Yield a numeric value Boolean Expressions Yield a truth value (True/False, note the capitalization here, it is important!!) K. Squire - LtCol J. Young - CS
53 Logical Operators (4.3) Applied to one or more boolean expressions and, or, not These also happen to be keywords and, or are binary operators Take two boolean operands (a!= b) or (c < d) Results according to appropriate truth table not is a unary operator Result is boolean negation not (response == "yes") K. Squire - LtCol J. Young - CS
54 Dirty Little Secret Strictly speaking, when evaluating logical expressions python treats ANY non-zero value as True and 0/False as False Try the following "hello" and "cat" 1 and 9 1 and "jump" 0 and "crazy" "don't do this" and 0 K. Squire - LtCol J. Young - CS
55 Bitwise Operators Integers only Four operations Bitwise compliment (~), Unary operator a = ~b Bitwise And (&) a = b & c Bitwise Or ( ) a = b c Bitwise Exclusive Or (^) a = b ^ c K. Squire - LtCol J. Young - CS
56 Shift Operators Used to shift the bits in an integer right or left Left shift value << count value is shifted left count bits Same effect as: value * (2 ** count) Right shift value >> count value is shifted right count bits Similar effect to: value / (2 ** count) K. Squire - LtCol J. Young - CS
57 Interactive vs. Batch Revisited When you using python interactively, the interpreter will evaluate and display the result of any expression that you enter Python (#1, May , 07:40:45) [GCC (cygwin special)] on cygwin >>> 9 * 18 / However when executed in batch mode, the same statement, while legal will produce no output K. Squire - LtCol J. Young - CS
58 Comments When developing anything more than a trivial program, it is often nice to include non-executing comments within your program files to tell others just what you were thinking when you developed a particular section of code Comments are introduces by the # character and instruct the interpreter to ignore the remainder of the line K. Squire - LtCol J. Young - CS
59 Comment Example In the interpreter try >>> print "Hello" # print a simple message Note that the only output is: Hello The interpreter has ignored the comment Comments can occupy lines by themselves # We could provide a very detailed # explanation of an algorithm that we are # implementing so that others can easily # follow along and potentially modify # our program if they find an error K. Squire - LtCol J. Young - CS
SKILL AREA 304: Review Programming Language Concept. Computer Programming (YPG)
SKILL AREA 304: Review Programming Language Concept Computer Programming (YPG) 304.1 Demonstrate an Understanding of Basic of Programming Language 304.1.1 Explain the purpose of computer program 304.1.2
More informationPython The way of a program. Srinidhi H Asst Professor Dept of CSE, MSRIT
Python The way of a program Srinidhi H Asst Professor Dept of CSE, MSRIT 1 Problem Solving Problem solving means the ability to formulate problems, think creatively about solutions, and express a solution
More informationCS112 Lecture: Primitive Types, Operators, Strings
CS112 Lecture: Primitive Types, Operators, Strings Last revised 1/24/06 Objectives: 1. To explain the fundamental distinction between primitive types and reference types, and to introduce the Java primitive
More informationAlgorithms and Programming I. Lecture#12 Spring 2015
Algorithms and Programming I Lecture#12 Spring 2015 Think Python How to Think Like a Computer Scientist By :Allen Downey Installing Python Follow the instructions on installing Python and IDLE on your
More informationlast time in cs recitations. computer commands. today s topics.
last time in cs1007... recitations. course objectives policies academic integrity resources WEB PAGE: http://www.columbia.edu/ cs1007 NOTE CHANGES IN ASSESSMENT 5 EXTRA CREDIT POINTS ADDED sign up for
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 informationINFS 214: Introduction to Computing
INFS 214: Introduction to Computing Session 11 Principles of Programming Lecturer: Dr. Ebenezer Ankrah, Dept. of Information Studies Contact Information: eankrah@ug.edu.gh College of Education School of
More informationPRG 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 informationIT 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 informationVariables, expressions and statements
Variables, expressions and statements 2.1. Values and data types A value is one of the fundamental things like a letter or a number that a program manipulates. The values we have seen so far are 2 (the
More informationCSI Lab 02. Tuesday, January 21st
CSI Lab 02 Tuesday, January 21st Objectives: Explore some basic functionality of python Introduction Last week we talked about the fact that a computer is, among other things, a tool to perform high speed
More informationComputer Components. Software{ User Programs. Operating System. Hardware
Computer Components Software{ User Programs Operating System Hardware What are Programs? Programs provide instructions for computers Similar to giving directions to a person who is trying to get from point
More informationCSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York
CSc 10200! Introduction to Computing Lecture 2-3 Edgardo Molina Fall 2013 City College of New York 1 C++ for Engineers and Scientists Third Edition Chapter 2 Problem Solving Using C++ 2 Objectives In this
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 informationPROGRAMMING FUNDAMENTALS
PROGRAMMING FUNDAMENTALS VARIABLES, EXPRESSIONS AND STATEMENTS João Correia Lopes INESC TEC, FEUP 27 September 2018 FPRO/MIEIC/2018-19 27/09/2018 1 / 21 INTRODUCTION GOALS By the end of this class, the
More informationObjectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program
Objectives Chapter 2: Basic Elements of C++ In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates
More informationChapter 2: Basic Elements of C++
Chapter 2: Basic Elements of C++ Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates
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 informationChapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction
Chapter 2: Basic Elements of C++ C++ Programming: From Problem Analysis to Program Design, Fifth Edition 1 Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers
More informationCS Prof J.P.Morrison
CS1061 2018-2019 Prof J.P.Morrison C Programming C is the most popular language worldwide. Everything from microcontrollers to operating systems is written in C flexible and versatile, allowing maximum
More information7/8/10 KEY CONCEPTS. Problem COMP 10 EXPLORING COMPUTER SCIENCE. Algorithm. Lecture 2 Variables, Types, and Programs. Program PROBLEM SOLVING
KEY CONCEPTS COMP 10 EXPLORING COMPUTER SCIENCE Lecture 2 Variables, Types, and Programs Problem Definition of task to be performed (by a computer) Algorithm A particular sequence of steps that will solve
More informationProgram Fundamentals
Program Fundamentals /* HelloWorld.java * The classic Hello, world! program */ class HelloWorld { public static void main (String[ ] args) { System.out.println( Hello, world! ); } } /* HelloWorld.java
More information5/3/2006. Today! HelloWorld in BlueJ. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont.
Today! Build HelloWorld yourself in BlueJ and Eclipse. Look at all the Java keywords. Primitive Types. HelloWorld in BlueJ 1. Find BlueJ in the start menu, but start the Select VM program instead (you
More informationGO - OPERATORS. This tutorial will explain the arithmetic, relational, logical, bitwise, assignment and other operators one by one.
http://www.tutorialspoint.com/go/go_operators.htm GO - OPERATORS Copyright tutorialspoint.com An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations.
More informationComputational Physics Operating systems
Computational Physics numerical methods with C++ (and UNIX) 2018-19 Fernando Barao Instituto Superior Tecnico, Dep. Fisica email: fernando.barao@tecnico.ulisboa.pt Computational Physics 2018-19 (Phys Dep
More informationIntroduction to Programming
Introduction to Programming Computers and Programs Python Programming, 1/e 1 The Universal Machine What is a computer program? A detailed, step-by-step set of instructions telling a computer what to do.
More information12/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 informationAnd Parallelism. Parallelism in Prolog. OR Parallelism
Parallelism in Prolog And Parallelism One reason that Prolog is of interest to computer scientists is that its search mechanism lends itself to parallel evaluation. In fact, it supports two different kinds
More informationVARIABLES. Aim Understanding how computer programs store values, and how they are accessed and used in computer programs.
Lesson 2 VARIABLES Aim Understanding how computer programs store values, and how they are accessed and used in computer programs. WHAT ARE VARIABLES? When you input data (i.e. information) into a computer
More information9/21/17. Outline. Expression Evaluation and Control Flow. Arithmetic Expressions. Operators. Operators. Notation & Placement
Outline Expression Evaluation and Control Flow In Text: Chapter 6 Notation Operator evaluation order Operand evaluation order Overloaded operators Type conversions Short-circuit evaluation of conditions
More informationCS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University
CS 112 Introduction to Computing II Wayne Snyder Department Boston University Today: Java basics: Compilation vs Interpretation Program structure Statements Values Variables Types Operators and Expressions
More informationLECTURE 17. Expressions and Assignment
LECTURE 17 Expressions and Assignment EXPRESSION SYNTAX An expression consists of An atomic object, e.g. number or variable. An operator (or function) applied to a collection of operands (or arguments)
More informationBasic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators. JAVA Standard Edition
Basic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators JAVA Standard Edition Java - Basic Operators Java provides a rich set of operators to manipulate variables.
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 informationProgramming Fundamentals (CS 302 ) Dr. Ihsan Ullah. Lecturer Department of Computer Science & IT University of Balochistan
Programming Fundamentals (CS 302 ) Dr. Ihsan Ullah Lecturer Department of Computer Science & IT University of Balochistan 1 Outline p Introduction p Program development p C language and beginning with
More informationThere 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 informationFundamental 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 informationSECTION II: LANGUAGE BASICS
Chapter 5 SECTION II: LANGUAGE BASICS Operators Chapter 04: Basic Fundamentals demonstrated declaring and initializing variables. This chapter depicts how to do something with them, using operators. Operators
More informationMEIN 50010: Python Introduction
: Python Fabian Sievers Higgins Lab, Conway Institute University College Dublin Wednesday, 2017-10-04 Outline Goals Teach basic programming concepts Apply these concepts using Python Use Python Packages
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 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 informationCGS 3066: Spring 2015 JavaScript Reference
CGS 3066: Spring 2015 JavaScript Reference Can also be used as a study guide. Only covers topics discussed in class. 1 Introduction JavaScript is a scripting language produced by Netscape for use within
More informationCS112 Lecture: Working with Numbers
CS112 Lecture: Working with Numbers Last revised January 30, 2008 Objectives: 1. To introduce arithmetic operators and expressions 2. To expand on accessor methods 3. To expand on variables, declarations
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 informationWEEK 4 OPERATORS, EXPRESSIONS AND STATEMENTS
WEEK 4 OPERATORS, EXPRESSIONS AND STATEMENTS OPERATORS Review: Data values can appear as literals or be stored in variables/constants Data values can be returned by method calls Operators: special symbols
More informationChapter 3: Operators, Expressions and Type Conversion
101 Chapter 3 Operators, Expressions and Type Conversion Chapter 3: Operators, Expressions and Type Conversion Objectives To use basic arithmetic operators. To use increment and decrement operators. To
More informationFull file at
Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class
More informationCSI32 Object-Oriented Programming
Outline Department of Mathematics and Computer Science Bronx Community College February 2, 2015 Outline Outline 1 Chapter 1 Cornerstones of Computing Textbook Object-Oriented Programming in Python Goldwasser
More informationObjectives. In this chapter, you will:
Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates arithmetic expressions Learn about
More informationBasic Programming Language Syntax
Java Created in 1990 by Sun Microsystems. Free compiler from Sun, commercial from many vendors. We use free (Sun) Java on UNIX. Compiling and Interpreting...are processes of translating a high-level programming
More informationThere 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 information9/5/2018. Overview. The C Programming Language. Transitioning to C from Python. Why C? Hello, world! Programming in C
Overview The C Programming Language (with material from Dr. Bin Ren, William & Mary Computer Science) Motivation Hello, world! Basic Data Types Variables Arithmetic Operators Relational Operators Assignments
More informationChapter 1: Why Program? Main Hardware Component Categories 8/23/2014. Main Hardware Component Categories: Why Program?
Chapter 1: Introduction to Computers and Programming 1.1 Why Program? Why Program? Computer programmable machine designed to follow instructions Program instructions in computer memory to make it do something
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 informationAssoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.
Assoc. Prof. Dr. Marenglen Biba (C) 2010 Pearson Education, Inc. All rights reserved. Java application A computer program that executes when you use the java command to launch the Java Virtual Machine
More informationWELCOME! (download slides and.py files and follow along!) LECTURE 1
WELCOME! (download slides and.py files and follow along!) 6.0001 LECTURE 1 6.0001 LECTURE 1 1 TODAY course info what is computation python basics mathematical operations python variables and types NOTE:
More informationLESSON 2 VARIABLES, OPERATORS, EXPRESSIONS, AND USER INPUT
LESSON VARIABLES, OPERATORS, EXPRESSIONS, AND USER INPUT PROF. JOHN P. BAUGH PROFJPBAUGH@GMAIL.COM PROFJPBAUGH.COM CONTENTS INTRODUCTION... Assumptions.... Variables and Data Types..... Numeric Data Types:
More informationCopyright 2005 Department of Computer & Information Science
Introducing Programming Copyright 2005 Goals By the end of this lecture, you should Understand the different types of programming languages. Understand the basic procedures in a program as input, processing
More informationThe C Programming Language. (with material from Dr. Bin Ren, William & Mary Computer Science)
The C Programming Language (with material from Dr. Bin Ren, William & Mary Computer Science) 1 Overview Motivation Hello, world! Basic Data Types Variables Arithmetic Operators Relational Operators Assignments
More informationMobile 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 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 informationLanguage Basics. /* The NUMBER GAME - User tries to guess a number between 1 and 10 */ /* Generate a random number between 1 and 10 */
Overview Language Basics This chapter describes the basic elements of Rexx. It discusses the simple components that make up the language. These include script structure, elements of the language, operators,
More informationCS102: Variables and Expressions
CS102: Variables and Expressions The topic of variables is one of the most important in C or any other high-level programming language. We will start with a simple example: int x; printf("the value of
More informationCPS122 Lecture: From Python to Java last revised January 4, Objectives:
Objectives: CPS122 Lecture: From Python to Java last revised January 4, 2017 1. To introduce the notion of a compiled language 2. To introduce the notions of data type and a statically typed language 3.
More informationChapter 1 INTRODUCTION
Chapter 1 INTRODUCTION A digital computer system consists of hardware and software: The hardware consists of the physical components of the system. The software is the collection of programs that a computer
More informationCS112 Lecture: Variables, Expressions, Computation, Constants, Numeric Input-Output
CS112 Lecture: Variables, Expressions, Computation, Constants, Numeric Input-Output Last revised January 12, 2006 Objectives: 1. To introduce arithmetic operators and expressions 2. To introduce variables
More informationReserved Words and Identifiers
1 Programming in C Reserved Words and Identifiers Reserved word Word that has a specific meaning in C Ex: int, return Identifier Word used to name and refer to a data element or object manipulated by the
More informationPython for Analytics. Python Fundamentals RSI Chapters 1 and 2
Python for Analytics Python Fundamentals RSI Chapters 1 and 2 Learning Objectives Theory: You should be able to explain... General programming terms like source code, interpreter, compiler, object code,
More informationChapter 2 Using Data. Instructor s Manual Table of Contents. At a Glance. A Guide to this Instructor s Manual:
Java Programming, Eighth Edition 2-1 Chapter 2 Using Data A Guide to this Instructor s Manual: We have designed this Instructor s Manual to supplement and enhance your teaching experience through classroom
More informationCreating a C++ Program
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer. 1 Creating a C++ Program created using an
More informationExpressions and Data Types CSC 121 Fall 2015 Howard Rosenthal
Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types and
More informationPart (04) Introduction to Programming
Part (04) Introduction to Programming Dr. Ahmed M. ElShafee 1 Dr. Ahmed ElShafee, ACU : Summer 2014, Introduction to CS 1 EVOLUTION To write a program for a computer, we must use a computer language. A
More informationChapter 2 Using Data. Instructor s Manual Table of Contents. At a Glance. Overview. Objectives. Teaching Tips. Quick Quizzes. Class Discussion Topics
Java Programming, Sixth Edition 2-1 Chapter 2 Using Data At a Glance Instructor s Manual Table of Contents Overview Objectives Teaching Tips Quick Quizzes Class Discussion Topics Additional Projects Additional
More informationChapter 1: Introduction to Computers and Programming
Chapter 1: Introduction to Computers and Programming 1.1 Why Program? Why Program? Computer programmable machine designed to follow instructions Program instructions in computer memory to make it do something
More informationWinter 2019 CISC101 1/17/2019
CISC101 Reminders Today TA emails are listed on the Labs page of the course web site. More assignments are posted. Commanding the CPU the use of a Stack. Computer Languages History of Python. Features
More informationChapter 11 Introduction to Programming in C
Chapter 11 Introduction to Programming in C C: A High-Level Language Gives symbolic names for containers of values don t need to know which register or memory location Provides abstraction of underlying
More informationQuestion No: 1 ( Marks: 1 ) - Please choose one One difference LISP and PROLOG is. AI Puzzle Game All f the given
MUHAMMAD FAISAL MIT 4 th Semester Al-Barq Campus (VGJW01) Gujranwala faisalgrw123@gmail.com MEGA File Solved MCQ s For Final TERM EXAMS CS508- Modern Programming Languages Question No: 1 ( Marks: 1 ) -
More informationPython Input, output and variables. Lecture 23 COMPSCI111/111G SS 2018
Python Input, output and variables Lecture 23 COMPSCI111/111G SS 2018 1 Today s lecture What is Python? Displaying text on screen using print() Variables Numbers and basic arithmetic Getting input from
More informationChapter 3 Syntax, Errors, and Debugging. Fundamentals of Java
Chapter 3 Syntax, Errors, and Debugging Objectives Construct and use numeric and string literals. Name and use variables and constants. Create arithmetic expressions. Understand the precedence of different
More informationCSc 10200! Introduction to Computing. Lecture 1 Edgardo Molina Fall 2013 City College of New York
CSc 10200! Introduction to Computing Lecture 1 Edgardo Molina Fall 2013 City College of New York 1 Introduction to Computing Lectures: Tuesday and Thursday s (2-2:50 pm) Location: NAC 1/202 Recitation:
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 informationInformation Science 1
Information Science 1 Simple Calcula,ons Week 09 College of Information Science and Engineering Ritsumeikan University Topics covered l Terms and concepts from Week 8 l Simple calculations Documenting
More informationChapter 2: Overview of C++
Chapter 2: Overview of C++ Problem Solving, Abstraction, and Design using C++ 6e by Frank L. Friedman and Elliot B. Koffman C++ Background Introduced by Bjarne Stroustrup of AT&T s Bell Laboratories in
More informationFull file at
Java Programming, Fifth Edition 2-1 Chapter 2 Using Data within a Program At a Glance Instructor s Manual Table of Contents Overview Objectives Teaching Tips Quick Quizzes Class Discussion Topics Additional
More informationCS 112 Introduction to Programming
CS 112 Introduction to Programming Java Primitive Data Types; Arithmetic Expressions Yang (Richard) Yang Computer Science Department Yale University 308A Watson, Phone: 432-6400 Email: yry@cs.yale.edu
More informationAdmin. CS 112 Introduction to Programming. Recap: Java Static Methods. Recap: Decomposition Example. Recap: Static Method Example
Admin CS 112 Introduction to Programming q Programming assignment 2 to be posted tonight Java Primitive Data Types; Arithmetic Expressions Yang (Richard) Yang Computer Science Department Yale University
More informationUnit. Programming Fundamentals. School of Science and Technology INTRODUCTION
INTRODUCTION Programming Fundamentals Unit 1 In order to communicate with each other, we use natural languages like Bengali, English, Hindi, Urdu, French, Gujarati etc. We have different language around
More informationLESSON 1. A C program is constructed as a sequence of characters. Among the characters that can be used in a program are:
LESSON 1 FUNDAMENTALS OF C The purpose of this lesson is to explain the fundamental elements of the C programming language. C like other languages has all alphabet and rules for putting together words
More informationThe C++ Language. Arizona State University 1
The C++ Language CSE100 Principles of Programming with C++ (based off Chapter 2 slides by Pearson) Ryan Dougherty Arizona State University http://www.public.asu.edu/~redoughe/ Arizona State University
More informationCS113: Lecture 3. Topics: Variables. Data types. Arithmetic and Bitwise Operators. Order of Evaluation
CS113: Lecture 3 Topics: Variables Data types Arithmetic and Bitwise Operators Order of Evaluation 1 Variables Names of variables: Composed of letters, digits, and the underscore ( ) character. (NO spaces;
More informationRuby: Introduction, Basics
Ruby: Introduction, Basics Computer Science and Engineering College of Engineering The Ohio State University Lecture 4 Ruby vs Java: Similarities Imperative and object-oriented Classes and instances (ie
More information9/10/10. Arithmetic Operators. Today. Assigning floats to ints. Arithmetic Operators & Expressions. What do you think is the output?
Arithmetic Operators Section 2.15 & 3.2 p 60-63, 81-89 1 Today Arithmetic Operators & Expressions o Computation o Precedence o Associativity o Algebra vs C++ o Exponents 2 Assigning floats to ints int
More informationControl Structures. Lecture 4 COP 3014 Fall September 18, 2017
Control Structures Lecture 4 COP 3014 Fall 2017 September 18, 2017 Control Flow Control flow refers to the specification of the order in which the individual statements, instructions or function calls
More informationChapter 1. Introduction to Computers and Java Objects. Background information. » important regardless of programming language. Introduction to Java
Chapter 1 Introduction to Computers and Java Objects Background information» important regardless of programming language Introduction to Java Chapter 1 Java: an Introduction to Computer Science & Programming
More informationCS 177 Recitation. Week 1 Intro to Java
CS 177 Recitation Week 1 Intro to Java Questions? Computers Computers can do really complex stuff. How? By manipulating data according to lists of instructions. Fundamentally, this is all that a computer
More informationLesson 3: Basic Programming Concepts
3 ICT Gaming Essentials Lesson 3: Basic Programming Concepts LESSON SKILLS After completing this lesson, you will be able to: Explain the types and uses of variables and operators in game programming.
More informationCourse Outline. Introduction to java
Course Outline 1. Introduction to OO programming 2. Language Basics Syntax and Semantics 3. Algorithms, stepwise refinements. 4. Quiz/Assignment ( 5. Repetitions (for loops) 6. Writing simple classes 7.
More informationCOMP Primitive and Class Types. Yi Hong May 14, 2015
COMP 110-001 Primitive and Class Types Yi Hong May 14, 2015 Review What are the two major parts of an object? What is the relationship between class and object? Design a simple class for Student How to
More informationA Set Of Machine Language Instructions For A Program Is Called Source Code >>>CLICK HERE<<<
A Set Of Machine Language Instructions For A Program Is Called Source Code In computing, an executable file or executable program, or sometimes simply an These instructions are traditionally machine code
More informationLecture Set 2: Starting Java
Lecture Set 2: Starting Java 1. Java Concepts 2. Java Programming Basics 3. User output 4. Variables and types 5. Expressions 6. User input 7. Uninitialized Variables 0 This Course: Intro to Procedural
More information