ENGR (Socolofsky) Week 02 Python scripts
|
|
- Judith Meagan Wells
- 5 years ago
- Views:
Transcription
1 ENGR (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 # Scott Socolofsky 7 # August import math # In this first block, we will perform various mathematical operations on 12 # different data types and let the print () function print the raw, 13 # unformatted output so that we can see what data types result # Addition 16 i = 1 17 i = i print (' Addition of two integers :') 19 print (i) i += 1 22 print (' Addition of two integers using +=: ') 23 print (i) x = x = x print (' Addition of two floats :') 28 print (x) print (' Addition of a float and integer :') 31 x = x + i 32 print (x) x += 1 35 print (' Addition of a float and integer using +=: ') 36 print (x) 37 print (' ') # Subtraction 40 i = i = i - 1
2 42 print (' Subtraction of two integers :') 43 print (i) i -= 1 46 print (' Subtraction of two integers using -=: ') 47 print (i) x = x = x print (' Subtraction of two floats :') 52 print (x) print (' Subtraction of a float and integer :') 55 x = i = 3 57 x = x - i 58 print (x) print (' Subtraction of a float and integer using -=: ') 61 x = x -= 1 63 print (x) 64 print (' ') # Multiplication x = y = z = x * y 71 print (' Multiplication of two floats :') 72 print (z) n = w = z * n 76 print (' Multiplication of a float and integer :') 77 print (w) s = 'ENGR ' 80 heading = 5 * s 81 print (' Multiplication of an integer and string :') 82 print ( heading ) 83 print (' ') # Division 86 i = 5 87 j = k = 7 89 n1 = j / i 90 n2 = k / i 91 print ('Division of two integers (10 / 5): ') 92 print ( n1) 93 print (' Division of two integers ( 7 / 5)') 94 print ( n2) 2
3 95 96 x = y = z = x / y 99 print (' Division of two floats :') 100 print ( z) w = z / n 103 print (' Division of float by integer :') 104 print ( w) w = n / z 107 print (' Division of an integer by a float :') 108 print ( w) 109 print (' ') # Powers 112 u = i ** j 113 print (' Integer to an integer power :') 114 print ( u) v = x ** j 117 print (' Float to an integer power :') 118 print ( v) w = x ** y 121 print (' Float to a float power :') 122 print ( w) print (' NOTE : When possible, use integers in powers since ') 125 print (' integer powers execute faster on a computer.') 126 print (' ') # Integer division 129 x = y = z1 = x // y 132 print (' Division of two floats ( // 2. 54): ') 133 print ( z1) # Modulus operator 136 z2 = x % y 137 print (' Division of two floats ( % 2. 54): ') 138 print ( z2) 139 print (' ') # In this section, we format many of the variables computed above within 142 # various print statements. 143 print (' Format an integer as an integer, part 1: % d' % i) 144 print (' Format an integer as an integer, part 2: % 5. 5d' % i) 145 print (' Format an integer as a float : % 5. 5g' % i) 146 print (' Format a float as a float ( default ): % g' % w) 147 print (' Format a float as a float ( formatted ): % 7. 7g' % w) 3
4 148 print (' ') 149 print (' Include an apostrophe to symbolize feet in a string :') 150 print (" The wall is %4.4g' long " % w) # We can also include multiple strings in a print statement. 153 x = y = z = x // y 156 print (' Printing a result using multiple strings separated by comma ') 157 print ('The division of ', x, '// ', y, '=', z) 158 print (' Printing a result using string concatenation ') 159 print ('The division of ' + str (x) + '// ' + str (y) + ' = ' + str (z)) 160 print (' ') # Finally, we demonstrate the input function 163 print (' Enter the diameter of a sphere :') 164 d = float ( input ()) 165 vol = math.pi / 6. * d**3 166 print (' The volume of your sphere is % 8. 8g units ' % vol ) 167 print (' ') d = float ( input (' Enter the diameter of a sphere : ')) 170 vol = math.pi / 6. * d**3 171 print (' The volume of your sphere is % 8. 8g units ' % vol ) 172 print (' ') 4
5 Code execution for script.py yields Addition of two integers: 2 Addition of two integers using +=: 3 Addition of two floats: Addition of a float and integer: Addition of a float and integer using +=: Subtraction of two integers: 9 Subtraction of two integers using -=: 8 Subtraction of two floats: Subtraction of a float and integer: 4.15 Subtraction of a float and integer using -=: 6.15 Multiplication of two floats: Multiplication of a float and integer: Multiplication of an integer and string: ENGR ENGR ENGR ENGR ENGR Division of two integers (10 / 5): 2.0 Division of two integers (7 / 5) 1.4 Division of two floats: Division of float by integer: Division of an integer by a float:
6 Integer to an integer power: Float to an integer power: Float to a float power: NOTE: When possible, use integers in powers since integer powers execute faster on a computer. Division of two floats (7.15 // 2.54): 2.0 Division of two floats (7.15 % 2.54): Format an integer as an integer, part 1: 5 Format an integer as an integer, part 2: Format an integer as a float: 5 Format a float as a float (default): Format a float as a float (formatted): Include an apostrophe to symbolize feet in a string: The wall is long Printing a result using multiple strings separated by comma The division of 7.15 // 3.45 = 2.0 Printing a result using string concatenation The division of 7.15//3.45 = 2.0 Enter the diameter of a sphere: 3.5 The volume of your sphere is units Enter the diameter of a sphere: 4.5 The volume of your sphere is units Process finished with exit code 0 6
Python Programming Exercises 1
Python Programming Exercises 1 Notes: throughout these exercises >>> preceeds code that should be typed directly into the Python interpreter. To get the most out of these exercises, don t just follow them
More informationENGR (Socolofsky) Week 07 Python scripts
ENGR 102-213 (Socolofsky) Week 07 Python scripts A couple programming examples for this week are embedded in the lecture notes for Week 7. We repeat these here as brief examples of typical array-like operations
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 information1. What type of error produces incorrect results but does not prevent the program from running? a. syntax b. logic c. grammatical d.
Gaddis: Starting Out with Python, 2e - Test Bank Chapter Two MULTIPLE CHOICE 1. What type of error produces incorrect results but does not prevent the program from running? a. syntax b. logic c. grammatical
More informationLecture 2: Python Arithmetic
Lecture 2: Python Arithmetic CS1068+ Introductory Programming in Python Dr Kieran T. Herley 2018/19 Department of Computer Science University College Cork Basic data types in Python Python data types Programs
More informationUser-Defined Function
ENGR 102-213 (Socolofsky) Week 11 Python scripts In the lecture this week, we are continuing to learn powerful things that can be done with userdefined functions. In several of the examples, we consider
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 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 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 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 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 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 informationLessons on Python Numbers
Lessons on Python Numbers Walter Didimo [ 30 minutes ] Types of numbers There are only three kinds of number in Python: integer any integer number floating-point any real number complex any number having
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 informationProfessor: Sana Odeh Lecture 3 Python 3.1 Variables, Primitive Data Types & arithmetic operators
1 Professor: Sana Odeh odeh@courant.nyu.edu Lecture 3 Python 3.1 Variables, Primitive Data Types & arithmetic operators Review What s wrong with this line of code? print( He said Hello ) What s wrong with
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 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 informationENGR 102 Engineering Lab I - Computation
ENGR 102 Engineering Lab I - Computation Week 07: Arrays and Lists of Data Introduction to Arrays In last week s lecture, 1 we were introduced to the mathematical concept of an array through the equation
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 informationVariable and Data Type I
Islamic University Of Gaza Faculty of Engineering Computer Engineering Department Lab 2 Variable and Data Type I Eng. Ibraheem Lubbad September 24, 2016 Variable is reserved a location in memory to store
More informationIntroduction to Scientific Python, CME 193 Jan. 9, web.stanford.edu/~ermartin/teaching/cme193-winter15
1 LECTURE 1: INTRO Introduction to Scientific Python, CME 193 Jan. 9, 2014 web.stanford.edu/~ermartin/teaching/cme193-winter15 Eileen Martin Some slides are from Sven Schmit s Fall 14 slides 2 Course Details
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 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 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 informationIntroduction to: Computers & Programming: Review prior to 1 st Midterm
Introduction to: Computers & Programming: Review prior to 1 st Midterm Adam Meyers New York University Summary Some Procedural Matters Summary of what you need to Know For the Test and To Go Further in
More informationLecture 3. Functions & Modules
Lecture 3 Functions & Modules Labs this Week Lab 1 is due at the beginning of your lab If it is not yet by then, you cannot get credit Only exception is for students who added late (Those students should
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 informationPython Numbers. Learning Outcomes 9/19/2012. CMSC 201 Fall 2012 Instructor: John Park Lecture Section 01 Discussion Sections 02-08, 16, 17
Python Numbers CMSC 201 Fall 2012 Instructor: John Park Lecture Section 01 Discussion Sections 02-08, 16, 17 1 (adapted from Meeden, Evans & Mayberry) 2 Learning Outcomes To become familiar with the basic
More informationCS 112: Intro to Comp Prog
CS 112: Intro to Comp Prog Lecture Review Data Types String Operations Arithmetic Operators Variables In-Class Exercises Lab Assignment #2 Upcoming Lecture Topics Variables * Types Functions Purpose Parameters
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 informationCME 193: Introduction to Scientific Python Lecture 1: Introduction
CME 193: Introduction to Scientific Python Lecture 1: Introduction Nolan Skochdopole stanford.edu/class/cme193 1: Introduction 1-1 Contents Administration Introduction Basics Variables Control statements
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 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 informationCOMP519 Web Programming Lecture 11: JavaScript (Part 2) Handouts
COMP519 Web Programming Lecture 11: JavaScript (Part 2) Handouts Ullrich Hustadt Department of Computer Science School of Electrical Engineering, Electronics, and Computer Science University of Liverpool
More informationVariable and Data Type I
The Islamic University of Gaza Faculty of Engineering Dept. of Computer Engineering Intro. To Computers (LNGG 1003) Lab 2 Variable and Data Type I Eng. Ibraheem Lubbad February 18, 2017 Variable is reserved
More informationLecture 3. Functions & Modules
Lecture 3 Functions & Modules Labs this Week Lab 1 is due at the beginning of your lab If it is not yet by then, you cannot get credit Only exception is for students who added late (Those students should
More informationCSCE 110 Programming I Basics of Python: Variables, Expressions, Input/Output
CSCE 110 Programming I Basics of Python: Variables, Expressions, Input/Output Dr. Tiffani L. Williams Department of Computer Science and Engineering Texas A&M University Spring 2011 Python Python was developed
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 informationOUTLINE. Number system. Creating MATLAB variables Overwriting variable Error messages Making corrections Entering multiple statements per line
1 LECTURE 2 OUTLINE Number system Integer number Decimal number Binary number Hexadecimal number Creating MATLAB variables Overwriting variable Error messages Making corrections Entering multiple statements
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 informationCS 1803 Individual Homework 1 Python Practice Due: Wednesday, January 26th, before 6 PM Out of 100 points
CS 1803 Individual Homework 1 Python Practice Due: Wednesday, January 26th, before 6 PM Out of 100 points Files to submit: 1. HW1.py This is an INDIVIDUAL assignment! Collaboration at a reasonable level
More informationPython lab session 1
Python lab session 1 Dr Ben Dudson, Department of Physics, University of York 28th January 2011 Python labs Before we can start using Python, first make sure: ˆ You can log into a computer using your username
More informationMIT AITI Python Software Development
MIT AITI Python Software Development PYTHON L02: In this lab we practice all that we have learned on variables (lack of types), naming conventions, numeric types and coercion, strings, booleans, operator
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 informationIntroduction to Python
Introduction to Python CB2-101 Introduction to Scientific Computing November 11 th, 2014 Emidio Capriotti http://biofold.org/emidio Division of Informatics Department of Pathology Python Python high-level
More informationThe Three Rules. Program. What is a Computer Program? 5/30/2018. Interpreted. Your First Program QuickStart 1. Chapter 1
The Three Rules Chapter 1 Beginnings Rule 1: Think before you program Rule 2: A program is a human-readable essay on problem solving that also executes on a computer Rule 3: The best way to improve your
More information>>> * *(25**0.16) *10*(25**0.16)
#An Interactive Session in the Python Shell. #When you type a statement in the Python Shell, #the statement is executed immediately. If the #the statement is an expression, its value is #displayed. #Lines
More informationLesson 5: Introduction to the Java Basics: Java Arithmetic THEORY. Arithmetic Operators
Lesson 5: Introduction to the Java Basics: Java Arithmetic THEORY Arithmetic Operators There are four basic arithmetic operations: OPERATOR USE DESCRIPTION + op1 + op2 Adds op1 and op2 - op1 + op2 Subtracts
More informationLecture 3 Tao Wang 1
Lecture 3 Tao Wang 1 Objectives In this chapter, you will learn about: Arithmetic operations Variables and declaration statements Program input using the cin object Common programming errors C++ for Engineers
More informationSAMS Programming A/B. Lecture #1 Introductions July 3, Mark Stehlik
SAMS Programming A/B Lecture #1 Introductions July 3, 2017 Mark Stehlik Outline for Today Overview of Course A Python intro to be continued in lab on Wednesday (group A) and Thursday (group B) 7/3/2017
More information1/11/2010 Topic 2: Introduction to Programming 1 1
Topic 2: Introduction to Programming g 1 1 Recommended Readings Chapter 2 2 2 Computer Programming Gain necessary knowledge of the problem domain Analyze the problem, breaking it into pieces Repeat as
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 informationENGG1811 Computing for Engineers Week 1 Introduction to Programming and Python
ENGG1811 Computing for Engineers Week 1 Introduction to Programming and Python ENGG1811 UNSW, CRICOS Provider No: 00098G W4 Computers have changed engineering http://www.noendexport.com/en/contents/48/410.html
More informationCSc 110, Spring 2017 Lecture 3: Expressions, Variables and Loops. Adapted from slides by Marty Stepp and Stuart Reges
CSc 110, Spring 2017 Lecture 3: Expressions, Variables and Loops Adapted from slides by Marty Stepp and Stuart Reges 1 Data and expressions 2 Data types Internally, computers store everything as 1s and
More informationGetting Started. Office Hours. CSE 231, Rich Enbody. After class By appointment send an . Michigan State University CSE 231, Fall 2013
CSE 231, Rich Enbody Office Hours After class By appointment send an email 2 1 Project 1 Python arithmetic Do with pencil, paper and calculator first Idle Handin Help room 3 What is a Computer Program?
More informationCS 102 Lab 3 Fall 2012
Name: The symbol marks programming exercises. Upon completion, always capture a screenshot and include it in your lab report. Email lab report to instructor at the end of the lab. Review of built-in functions
More informationModular Arithmetic. Marizza Bailey. December 14, 2015
Modular Arithmetic Marizza Bailey December 14, 2015 Introduction to Modular Arithmetic If someone asks you what day it is 145 days from now, what would you answer? Would you count 145 days, or find a quicker
More informationIntroduction to Python: Data types. HORT Lecture 8 Instructor: Kranthi Varala
Introduction to Python: Data types HORT 59000 Lecture 8 Instructor: Kranthi Varala Why Python? Readability and ease-of-maintenance Python focuses on well-structured easy to read code Easier to understand
More informationCIS192 Python Programming. Robert Rand. August 27, 2015
CIS192 Python Programming Introduction Robert Rand University of Pennsylvania August 27, 2015 Robert Rand (University of Pennsylvania) CIS 192 August 27, 2015 1 / 30 Outline 1 Logistics Grading Office
More informationLecture 1. Introduction to course, Welcome to Engineering, What is Programming and Why is this the first thing being covered in Engineering?
Lecture 1 Introduction to course, Welcome to Engineering, What is Programming and Why is this the first thing being covered in Engineering? Welcome to ENGR 102 Syllabus review Your Time Expectations (in
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 informationTopic 2: Introduction to Programming
Topic 2: Introduction to Programming 1 Textbook Strongly Recommended Exercises The Python Workbook: 12, 13, 23, and 28 Recommended Exercises The Python Workbook: 5, 7, 15, 21, 22 and 31 Recommended Reading
More informationData Handing in Python
Data Handing in Python As per CBSE curriculum Class 11 Chapter- 3 By- Neha Tyagi PGT (CS) KV 5 Jaipur(II Shift) Jaipur Region Introduction In this chapter we will learn data types, variables, operators
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 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 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 informationComputing with Numbers Zelle - Chapter 3
Computing with Numbers Zelle - Chapter 3 Charles Severance - www.dr-chuck.com Textbook: Python Programming: An Introduction to Computer Science, John Zelle (www.si182.com) Numbers Numeric Data Types and
More informationDatatypes, Variables, and Operations
Datatypes, Variables, and Operations 1 Primitive Type Classification 2 Numerical Data Types Name Range Storage Size byte 2 7 to 2 7 1 (-128 to 127) 8-bit signed short 2 15 to 2 15 1 (-32768 to 32767) 16-bit
More informationENGINEERING 1020 Introduction to Computer Programming M A Y 2 6, R E Z A S H A H I D I
ENGINEERING 1020 Introduction to Computer Programming M A Y 2 6, 2 0 1 0 R E Z A S H A H I D I Today s class Constants Assignment statement Parameters and calling functions Expressions Mixed precision
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 informationCOMP1730/COMP6730 Programming for Scientists. Sequence types, part 2
COMP1730/COMP6730 Programming for Scientists Sequence types, part 2 Lecture outline * Lists * Mutable objects & references Sequence data types (recap) * A sequence contains n 0 values (its length), each
More informationCSI33 Data Structures
Outline Department of Mathematics and Computer Science Bronx Community College August 29, 2018 Outline Outline 1 Chapter 2: Data Abstraction Outline Chapter 2: Data Abstraction 1 Chapter 2: Data Abstraction
More informationA simple interpreted language
Copyright Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See http://software-carpentry.org/license.html for more information. A simple interpreted language
More informationMathematical Data Operators
Mathematical Data Operators Programming often requires numbers to be manipulated. This usually involves standard mathematical operators: addition, subtraction, multiplication and division. It can also
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 informationAt full speed with Python
At full speed with Python João Ventura v0.1 Contents 1 Introduction 2 2 Installation 3 2.1 Installing on Windows............................ 3 2.2 Installing on macos............................. 5 2.3
More informationBuilt-in Types of Data
Built-in Types of Data Types A data type is set of values and a set of operations defined on those values Python supports several built-in data types: int (for integers), float (for floating-point numbers),
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 informationChapter Two PROGRAMMING WITH NUMBERS AND STRINGS
Chapter Two PROGRAMMING WITH NUMBERS AND STRINGS Introduction Numbers and character strings are important data types in any Python program These are the fundamental building blocks we use to build more
More informationIntro to Python & Programming. C-START Python PD Workshop
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 scientist, but with a little hard work
More informationModule 2 - Part 2 DATA TYPES AND EXPRESSIONS 1/15/19 CSE 1321 MODULE 2 1
Module 2 - Part 2 DATA TYPES AND EXPRESSIONS 1/15/19 CSE 1321 MODULE 2 1 Topics 1. Expressions 2. Operator precedence 3. Shorthand operators 4. Data/Type Conversion 1/15/19 CSE 1321 MODULE 2 2 Expressions
More informationCSC Web Programming. Introduction to JavaScript
CSC 242 - Web Programming Introduction to JavaScript JavaScript JavaScript is a client-side scripting language the code is executed by the web browser JavaScript is an embedded language it relies on its
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 informationIntroduction. Following are the types of operators: Unary requires a single operand Binary requires two operands Ternary requires three operands
Introduction Operators are the symbols which operates on value or a variable. It tells the compiler to perform certain mathematical or logical manipulations. Can be of following categories: Unary requires
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 informationLab of COMP 406. MATLAB: Quick Start. Lab tutor : Gene Yu Zhao Mailbox: or Lab 1: 11th Sep, 2013
Lab of COMP 406 MATLAB: Quick Start Lab tutor : Gene Yu Zhao Mailbox: csyuzhao@comp.polyu.edu.hk or genexinvivian@gmail.com Lab 1: 11th Sep, 2013 1 Where is Matlab? Find the Matlab under the folder 1.
More informationC++ Programming Applied to Robotics, Mark Aull Lesson 2: Intro to Visual Studio, debugger Intro to C++, variables, conditionals, loops, strings
C++ Programming Applied to Robotics, Mark Aull Lesson 2: Intro to Visual Studio, debugger Intro to C++, variables, conditionals, loops, strings As in the first lesson, open visual studio, start a new empty
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 informationENGR 102 Engineering Lab I - Computation
ENGR 102 Engineering Lab I - Computation Learning Objectives by Week 1 ENGR 102 Engineering Lab I Computation 2 Credits 2. Introduction to the design and development of computer applications for engineers;
More informationInvent Your Own Computer Games with Python
Hello Wor ld! Invent Your Own Computer Games with Python Taesoo Kwon Heejin Park Hanyang University Introduction to Python Python Easier to learn than C. Serious programming language. Many expert programmers
More informationInformatics Ingeniería en Electrónica y Automática Industrial
Informatics Ingeniería en Electrónica y Automática Industrial Operators and expressions in C Operators and expressions in C Numerical expressions and operators Arithmetical operators Relational and logical
More informationPhysics 514 Basic Python Intro
Physics 514 Basic Python Intro Emanuel Gull September 8, 2014 1 Python Introduction Download and install python. On Linux this will be done with apt-get, evince, portage, yast, or any other package manager.
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 informationLevel 3 Computing Year 2 Lecturer: Phil Smith
Level 3 Computing Year 2 Lecturer: Phil Smith Previously We learnt what a computer program does. What a procedural program does. What a procedure is. We had a first look at IDLE. Now Learning Outcomes
More informationLecture Numbers. Richard E Sarkis CSC 161: The Art of Programming
Lecture Numbers Richard E Sarkis CSC 161: The Art of Programming Class Administrivia Agenda To understand the concept of data types To be familiar with the basic numeric data types in Python To be able
More informationCOMP 110 Introduction to Programming. What did we discuss?
COMP 110 Introduction to Programming Fall 2015 Time: TR 9:30 10:45 Room: AR 121 (Hanes Art Center) Jay Aikat FB 314, aikat@cs.unc.edu Previous Class What did we discuss? COMP 110 Fall 2015 2 1 Today Announcements
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 informationMath 1 Variable Manipulation Part 2 Exponents & Roots
Math 1 Variable Manipulation Part 2 Exponents & Roots 1 PRE-ALGEBRA REVIEW: WORKING WITH EXPONENTS Exponents are shorthand for repeated multiplication of the same thing by itself. For instance, the shorthand
More informationWeek 2. expressions, variables, for loops
Week expressions, variables, for loops Special thanks to Scott Shawcroft, Ryan Tucker, Paul Beck, Hélène Martin, Kim Todd, John Kurkowski, and Marty Stepp for their work on these slides. Except where otherwise
More informationVisual Basic for Applications
Visual Basic for Applications Programming Damiano SOMENZI School of Economics and Management Advanced Computer Skills damiano.somenzi@unibz.it Week 1 Outline 1 Visual Basic for Applications Programming
More information