CSCI 121: Anatomy of a Python Script
|
|
- Christal Lamb
- 5 years ago
- Views:
Transcription
1 CSCI 121: Anatomy of a Python Script
2 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) executes each statement, line by line, from top to bottom. A statement directs that an action be made by the interpreter, which has a (state-changing) effect. (Think of the first lecture s demo.)
3 Python Statement Effects Each Python statement directs that an action be taken, which has an effect on the runtime system. Some examples of effects: some text gets output (printed) to the console some typed console input is read some named variable gets assigned a newly computed value window is displayed, file is read, URL is fetched, the program connects to a database or a network service, a sound is made, etc., etc.
4 Running the Script print("hello there, everyone!") print("this is our second Python program.") print("did you know that times is this?") print(78687 * 89798) The above was saved as hello_calc.py into a folder. On my Mac, within Terminal, I enter the command: C02MX1KLFH04:examples jimfix$ python3 hello_calc.py Hello there, everyone! This is our second Python program. Did you know that times is this? C02MX1KLFH04:examples jimfix$ The interpreter outputs those four lines.
5 Another example: variables print("hello there, everyone!") print("this is our third Python program. ) result = * print("did you know that times is this?") print(result) The third line is an assignment statement It introduces a variable named result and associates it with a value. That computed value is saved in Python s memory and can then be used later in the script. In line 5, we tell Python to print that value.
6 Another example: variables print("hello there, everyone!") print("this is our third Python program. ) result = * print("did you know that times is this?") print(result) Syntax of an assignment statement: <variable name> = <expression of value to calculate> The left hand side gives the name of the variable. The right hand side expresses a value to calculate. There are a variety of expressions, often a bunch of data operations, e.g. numeric and string arithmetic.
7 Reassigning variables print("hello there, everyone!") print("this is our fourth Python program. ) result = * print("did you know that times is this?") print(result) result = (86 * 786) / ( ) print(result) result = (result ** 2) / (result - 1) print(result) A variable can be reassigned in a subsequent statement (can even be computed from its prior value). Don t reverse the order! Don t write: result = * Assignments are not logical/mathematical assertions!
8 Formatting output print("hello there, everyone!") print("this is our fifth Python program. ) result = * print("78687 times equals + str(result) +. ) In line 4, we use a function named str to convert a numeric value into a string of characters. We then use the string concatenation operation + to stick three strings together into a single string. The plus means different things for different data values.
9 Formatting output print("hello there, everyone!") print("this is our sixth Python program. ) result = * print("78687 times equals + str(result) +. ) print(result + result) print(str(result)+str(result)) C02MX1KLFH04:examples jimfix$ python3 hello6.py Hello there, everyone! This is our sixth Python program times equals C02MX1KLFH04:examples jimfix$
10 An interactive script name = input("could someone volunteer their name? ") print("hello there, + name + "!") print("thanks for volunteering like that.") print("this is our seventh Python program.") C02MX1KLFH04:examples jimfix$ python3 shoutout.py Could someone volunteer their name? John Kroger Hello there, John Kroger! Thanks for volunteering like that. This is our seventh Python program. C02MX1KLFH04:examples jimfix$ There are 3 print statements and an assignment statement. The right hand side uses a function named input That function outputs a prompt string to the console, then reads a string of input typed into the console.
11 String arithmetic name = input("could someone volunteer their name? ") print("hello there, "+name+"!") print("thanks for volunteering like that.") print("this is our eighth Python program. ) repeated = (name +, ) * 3 + name print( Below is your name repeated four times: ) print(repeated) C02MX1KLFH04:examples jimfix$ python3 shoutout4x.py Could someone volunteer their name? John Kroger Hello there, John Kroger! Thanks for volunteering like that. This is our eighth Python program. Below is your name repeated four times: John Kroger, John Kroger, John Kroger, John Kroger C02MX1KLFH04:examples jimfix$
12 Another example pi = area = float(input("circle area? ")) radius = (area / pi) ** 0.5 print("the radius of that circle is about "+str(radius)+" units.") Program is 3 assignment statements and a print statement. The first defines/assigns the variable named pi. The second gets a floating point value (a calculator number ) as input, assigned to area. We compute that with an arithmetic formula. The functions float and str convert (or cast ) values of one type to values of another type.
13 Same, but different from math import pi, sqrt area = float(input("circle area? ")) radius = sqrt(area / pi) print("the radius of that circle is about "+str(radius)+" units.") Here we import some definitions from a Python package named math. pi is the name of a floating point constant. sqrt is the name of a floating point function. There are packages for all sorts of useful Python libraries.
14 Some issues I d like to address values versus variables versus expressions functions, calling functions, defining functions (Friday) different types: int versus float versus str operations on each ( overloaded meaning for +,*) built-in functions for each managing print output carefully special characters (tab, end of line, quote, ) Let s switch modes in using the Python interpreter
15 CSCI 121: Python as calculator
16 Python3 can be run as a calculator We can also write a Python script live by interacting directly with the interpreter. We type in Python statements one at a time. They get executed immediately: C02MX1KLFH04:examples jimfix$ python3 >>> print( hello ) hello >>> print(6 * 7) 42 >>> result = 6 * 7 >>> print(result) 42 >>>
17 Python3 can be run as a calculator We can also enter Python expressions instead. A statement describes an action to be performed. An expression describes a value to be calculated. C02MX1KLFH04:examples jimfix$ python3 >>> hello hello >>> 6 * 7 42 >>> result = 6 * 7 >>> result 42 >>>
18 Python3 can be run as a calculator We can also enter Python expressions instead. A statement describes an action to be performed. An expression describes a value to be calculated. C02MX1KLFH04:examples jimfix$ python3 >>> hello hello >>> 6 * 7 42 >>> result = 6 * 7 >>> result 42 >>> Here, Python is acting differently. It calculates the value of the expression, then (quietly) converts that to a string of text, then reports that text representing the value.
19 Python as (programmable) calculator C02MX1KLFH04:examples jimfix$ python3 >>> hello hello >>> 6 * 7 42 >>> 67 / >>> This is the READ - EVALUATE - PRINT LOOP (or REPL ). Having a REPL for learning a language is wonderful! It s a HUGE reason we teach programming in Python.
20 Python can calculate live >>> >>> * 3 10 >>> (4 + 2) * 3 18 >>> 4 / >>> 2 ** 4 16 >>>
21 int vs. float Python has two types of number values: int and float With integers, computation is exact. With floating point numbers ( floats ), computation is approximate. With the division operation, you get a float. >>> 10 / >>> >>> int(8.7) 8
22 Python provides useful functions >>> pow(2,3) 8 >>> abs(-3) 3 >>> abs(4 + 2) 6 >>> min(3,7) 3 >>> max(4, 8.3, 6) 8.3 >>> len( hello ) 5 >>> len( ) 0
23 You can save results in variables >>> x = 7 >>> x 7 >>> x = 8+5 >>> x 13 >>> new = x >>> new 13 >>> x = y >>> y Error!
24 You can reassign variables >>> x = 3 >>> x 3 >>> x = x + 1 >>> x 4 >>> y = 10 >>> x = y >>> y = x >>> x 10 >>> y 10 Error!
25 Strings have arithmetic >>> x = Hello >>> x Hello >>> y = world >>> y world >>> x+y Helloworld >>> x + 8 Error!!!! >>> x * 3 HelloHelloHello Error!
26 Strings have arithmetic >>> x = Hello >>> x Hello >>> x + world Helloworld >>> x + 8 Error!!!! >>> x * 3 HelloHelloHello >>> str(8) 8 >>> int( 8 ) 8 >>> x + str(8) Hello8 >>>len(x) 5 Error!
27 Strings have arithmetic >>> z = input('what\'s your name?') What's your name?john >>> x + + z Hello John >>> print( I\ ve +str(19)+ characters.\nsee? ) I ve 19 characters. See? >>> len( I\ ve +str(21)+ characters. ) 19 >>> print( \thello\nthere ) hello there >>>
28 Tomorrow and Friday Things to remember to use in lab: convert input using float or int, depending. string concat (+) and repeat (*) and length (len) new line character ( \n ) and tab character ( \t ) plus (+) minus (-) times (*) divide (/) power (**) convert numbers using str to concatenate with strings Friday s lecture: What does Python do under its hood to execute code? We ll start writing our own functions.
Lecture 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 informationIntroduction to computers and Python. Matthieu Choplin
Introduction to computers and Python Matthieu Choplin matthieu.choplin@city.ac.uk http://moodle.city.ac.uk/ 1 Objectives To get a brief overview of what Python is To understand computer basics and programs
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 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 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 informationBasic Concepts. Computer Science. Programming history Algorithms Pseudo code. Computer - Science Andrew Case 2
Basic Concepts Computer Science Computer - Science - Programming history Algorithms Pseudo code 2013 Andrew Case 2 Basic Concepts Computer Science Computer a machine for performing calculations Science
More informationJython. secondary. memory
2 Jython secondary memory Jython processor Jython (main) memory 3 Jython secondary memory Jython processor foo: if Jython a
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 informationEntry Point of Execution: the main Method. Elementary Programming. Learning Outcomes. Development Process
Entry Point of Execution: the main Method Elementary Programming EECS1021: Object Oriented Programming: from Sensors to Actuators Winter 2019 CHEN-WEI WANG For now, all your programming exercises will
More informationCS 115 Lecture 4. More Python; testing software. Neil Moore
CS 115 Lecture 4 More Python; testing software Neil Moore Department of Computer Science University of Kentucky Lexington, Kentucky 40506 neil@cs.uky.edu 8 September 2015 Syntax: Statements A statement
More informationPython 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 informationGetting Started Values, Expressions, and Statements CS GMU
Getting Started Values, Expressions, and Statements CS 112 @ GMU Topics where does code go? values and expressions variables and assignment 2 where does code go? we can use the interactive Python interpreter
More 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 informationAP Computer Science Unit 1. Writing Programs Using BlueJ
AP Computer Science Unit 1. Writing Programs Using BlueJ 1. Open up BlueJ. Click on the Project menu and select New Project. You should see the window on the right. Navigate to wherever you plan to save
More informationTester vs. Controller. Elementary Programming. Learning Outcomes. Compile Time vs. Run Time
Tester vs. Controller Elementary Programming EECS1022: Programming for Mobile Computing Winter 2018 CHEN-WEI WANG For effective illustrations, code examples will mostly be written in the form of a tester
More informationElementary Programming
Elementary Programming EECS1022: Programming for Mobile Computing Winter 2018 CHEN-WEI WANG Learning Outcomes Learn ingredients of elementary programming: data types [numbers, characters, strings] literal
More informationCS Introduction to Computational and Data Science. Instructor: Renzhi Cao Computer Science Department Pacific Lutheran University Spring 2017
CS 133 - Introduction to Computational and Data Science Instructor: Renzhi Cao Computer Science Department Pacific Lutheran University Spring 2017 Previous class We have learned the path and file system.
More informationLab 1: Course Intro, Getting Started with Python IDLE. Ling 1330/2330 Computational Linguistics Na-Rae Han
Lab 1: Course Intro, Getting Started with Python IDLE Ling 1330/2330 Computational Linguistics Na-Rae Han Objectives Course Introduction http://www.pitt.edu/~naraehan/ling1330/index.html Student survey
More informationCOMP1730/COMP6730 Programming for Scientists. Data: Values, types and expressions.
COMP1730/COMP6730 Programming for Scientists Data: Values, types and expressions. Lecture outline * Data and data types. * Expressions: computing values. * Variables: remembering values. What is data?
More informationExploring Python Basics
CptS 111 Lab #1 Fall 2017 Exploring Python Basics Learning Objectives: - Use the IDLE Shell window to run Python interactively - Use the IDLE Editor window to write a Python program (script) - Run Python
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 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 informationIntroduction to Java Unit 1. Using BlueJ to Write Programs
Introduction to Java Unit 1. Using BlueJ to Write Programs 1. Open up BlueJ. Click on the Project menu and select New Project. You should see the window on the right. Navigate to wherever you plan to save
More informationCS1110 Lab 1 (Jan 27-28, 2015)
CS1110 Lab 1 (Jan 27-28, 2015) First Name: Last Name: NetID: Completing this lab assignment is very important and you must have a CS 1110 course consultant tell CMS that you did the work. (Correctness
More informationAP Computer Science Unit 1. Writing Programs Using BlueJ
AP Computer Science Unit 1. Writing Programs Using BlueJ 1. Open up BlueJ. Click on the Project menu and select New Project. You should see the window on the right. Navigate to wherever you plan to save
More informationPython Intro GIS Week 1. Jake K. Carr
GIS 5222 Week 1 Why Python It s simple and easy to learn It s free - open source! It s cross platform IT S expandable!! Why Python: Example Consider having to convert 1,000 shapefiles into feature classes
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 informationCSEN 102 Introduction to Computer Science
CSEN 102 Introduction to Computer Science Lecture 2: Python and Sequential Algorithms Prof. Dr. Slim Abdennadher Dr. Aysha Alsafty, slim.abdennadher@guc.edu.eg, aysha.alsafty@guc.edu.eg German University
More 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 informationExploring Python Basics
CptS 111 Lab #1 Exploring Python Basics Learning Objectives: - Use the IDLE Shell window to run Python interactively - Use the IDLE Editor window to write a Python program (script) - Run Python programs
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 informationIntroduction to Python. Genome 559: Introduction to Statistical and Computational Genomics Prof. James H. Thomas
Introduction to Python Genome 559: Introduction to Statistical and Computational Genomics Prof. James H. Thomas If you have your own PC, download and install a syntax-highlighting text editor and Python
More informationCS1 Lecture 3 Jan. 18, 2019
CS1 Lecture 3 Jan. 18, 2019 Office hours for Prof. Cremer and for TAs have been posted. Locations will change check class website regularly First homework assignment will be available Monday evening, due
More informationPython language: Basics
Python language: Basics The FOSSEE Group Department of Aerospace Engineering IIT Bombay Mumbai, India FOSSEE Team (FOSSEE IITB) Basic Python 1 / 45 Outline 1 Data types Numbers Booleans Strings 2 Operators
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 informationCom S 127 Lab 2. For the first two parts of the lab, start up Wing 101 and use the Python shell window to try everything out.
Com S 127 Lab 2 Checkpoint 0 Please open the CS 127 Blackboard page and click on Groups in the menu at left. Sign up for the group corresponding to the lab section you are attending. Also, if you haven't
More informationBeyond Blocks: Python Session #1
Beyond Blocks: Session #1 CS10 Spring 2013 Thursday, April 30, 2013 Michael Ball Beyond Blocks : : Session #1 by Michael Ball adapted from Glenn Sugden is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike
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 informationfrom scratch A primer for scientists working with Next-Generation- Sequencing data Chapter 1 Text output and manipulation
from scratch A primer for scientists working with Next-Generation- Sequencing data Chapter 1 Text output and manipulation Chapter 1: text output and manipulation In this unit you will learn how to write
More informationReview. Input, Processing and Output. Review. Review. Designing a Program. Typical Software Development cycle. Bonita Sharif
Input, Processing and Output Bonita Sharif 1 Review A program is a set of instructions a computer follows to perform a task The CPU is responsible for running and executing programs A set of instructions
More informationIntroduction to Python. Genome 559: Introduction to Statistical and Computational Genomics Prof. James H. Thomas
Introduction to Python Genome 559: Introduction to Statistical and Computational Genomics Prof. James H. Thomas If you have your own PC, download and install a syntax-highlighting text editor and Python
More informationCS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 10: OCT. 6TH INSTRUCTOR: JIAYIN WANG
CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 10: OCT. 6TH INSTRUCTOR: JIAYIN WANG 1 Notice Assignments Reading Assignment: Chapter 3: Introduction to Parameters and Objects The Class 10 Exercise
More informationBasic Data Types and Operators CS 8: Introduction to Computer Science, Winter 2019 Lecture #2
Basic Data Types and Operators CS 8: Introduction to Computer Science, Winter 2019 Lecture #2 Ziad Matni, Ph.D. Dept. of Computer Science, UCSB Your Instructor Your instructor: Ziad Matni, Ph.D(zee-ahd
More informationData Types and the main Function
COMP101 - UNC Data Types and the main Function Lecture 03 Announcements PS0 Card for Someone Special Released TODAY, due next Wednesday 9/5 Office Hours If your software has issues today, come to office
More informationStrings. CSE 1310 Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington
Strings CSE 1310 Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1 Strings Store Text In the same way that int and float are designed to store numerical values,
More 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 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 informationCS 1110 SPRING 2016: GETTING STARTED (Jan 27-28) First Name: Last Name: NetID:
CS 1110 SPRING 2016: GETTING STARTED (Jan 27-28) http://www.cs.cornell.edu/courses/cs1110/2016sp/labs/lab01/lab01.pdf First Name: Last Name: NetID: Goals. Learning a computer language is a lot like learning
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 informationIntroduction to Computer Programming in Python Dr. William C. Bulko. Data Types
Introduction to Computer Programming in Python Dr William C Bulko Data Types 2017 What is a data type? A data type is the kind of value represented by a constant or stored by a variable So far, you have
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 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 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 informationLecture 12. Lists (& Sequences)
Lecture Lists (& Sequences) Announcements for Today Reading Read 0.0-0., 0.4-0.6 Read all of Chapter 8 for Tue Prelim, Oct th 7:30-9:30 Material up to October 3rd Study guide net week Conflict with Prelim
More informationDownloaded from Chapter 2. Functions
Chapter 2 Functions After studying this lesson, students will be able to: Understand and apply the concept of module programming Write functions Identify and invoke appropriate predefined functions Create
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 informationChris Simpkins (Georgia Tech) CS 2316 Data Manipulation for Engineers Python Overview 1 / 9
http://xkcd.com/353/ Chris Simpkins (Georgia Tech) CS 2316 Data Manipulation for Engineers Python Overview 1 / 9 Python Python is a general-purpose programming language, meaning you can write any kind
More informationClass 2: Variables and Memory. Laura Marik Spring 2012 C++ Course Notes (Provided by Jason Minski)
Class 2: Variables and Memory Variables A variable is a value that is stored in memory It can be numeric or a character C++ needs to be told what type it is before it can store it in memory It also needs
More informationTeaching London Computing
Teaching London Computing A Level Computer Science Topic 1: GCSE Python Recap William Marsh School of Electronic Engineering and Computer Science Queen Mary University of London Aims What is programming?
More informationOverview (4) CPE 101 mod/reusing slides from a UW course. Assignment Statement: Review. Why Study Expressions? D-1
CPE 101 mod/reusing slides from a UW course Overview (4) Lecture 4: Arithmetic Expressions Arithmetic expressions Integer and floating-point (double) types Unary and binary operators Precedence Associativity
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 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 informationIntroduction to programming with Python
Introduction to programming with Python Ing. Lelio Campanile 1/61 Main Goal - Introduce you to programming - introduce you to the most essential feature of python programming 2/61 Before to start The name
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 informationPython Class-Lesson1 Instructor: Yao
Python Class-Lesson1 Instructor: Yao What is Python? Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Its high-level built in data structures, combined
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 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 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 informationCSCA20 Worksheet Strings
1 Introduction to strings CSCA20 Worksheet Strings A string is just a sequence of characters. Why do you think it is called string? List some real life applications that use strings: 2 Basics We define
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 informationExpressions, Statements, Variables, Assignments, Types
Expressions, Statements, Variables, Assignments, Types CSE 1310 Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington Credits: a significant part of this material
More informationEntry Point of Execution: the main Method. Elementary Programming. Compile Time vs. Run Time. Learning Outcomes
Entry Point of Execution: the main Method Elementary Programming EECS2030: Advanced Object Oriented Programming Fall 2017 CHEN-WEI WANG For now, all your programming exercises will be defined within the
More informationComputer Science 1 CSCI-1100 Spring Semester 2015 Exam 1 Overview and Practice Questions
Computer Science 1 CSCI-1100 Spring Semester 2015 Exam 1 Overview and Practice Questions REMINDERS Exam 1 will be held Monday, March 2, 2015. Most of you will take the exam from 6:00-7:50PM in DCC 308.
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 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 informationCS Advanced Unix Tools & Scripting
& Scripting Spring 2011 Hussam Abu-Libdeh slides by David Slater March 4, 2011 Hussam Abu-Libdeh slides by David Slater & Scripting Python An open source programming language conceived in the late 1980s.
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 informationSlicing. Open pizza_slicer.py
Slicing and Tuples Slicing Open pizza_slicer.py Indexing a string is a great way of getting to a single value in a string However, what if you want to use a section of a string Like the middle name of
More informationAnnouncements for this Lecture
Lecture 6 Objects Announcements for this Lecture Last Call Quiz: About the Course Take it by tomorrow Also remember survey Assignment 1 Assignment 1 is live Posted on web page Due Thur, Sep. 18 th Due
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 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 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 informationCMSC 201 Spring 2016 Lab 04 For Loops
CMSC 201 Spring 2016 Lab 04 For Loops Assignment: Lab 04 For Loops Due Date: During discussion, February 29 th through March 3 rd Value: 10 points Part 1: Lists Lists are an easy way to hold lots of individual
More information61A Lecture 2. Friday, August 28, 2015
61A Lecture 2 Friday, August 28, 2015 Names, Assignment, and User-Defined Functions (Demo) Types of Expressions Primitive expressions: 2 add 'hello' Number or Numeral Name String Call expressions: max
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 informationComp 151. More on Arithmetic and intro to Objects
Comp 151 More on Arithmetic and intro to Objects Admin Any questions 2 The Project Lets talk about the project. What do you need A 'accumulator' variable. Start outside of the loop Lets look at your book's
More informationExpressions. Eric Roberts Handout #3 CSCI 121 January 30, 2019 Expressions. Grace Murray Hopper. Arithmetic Expressions.
Eric Roberts Handout #3 CSCI 121 January 30, 2019 Expressions Grace Murray Hopper Expressions Eric Roberts CSCI 121 January 30, 2018 Grace Hopper was one of the pioneers of modern computing, working with
More informationFundamentals of Programming (Python) Getting Started with Programming
Fundamentals of Programming (Python) Getting Started with Programming Ali Taheri Sharif University of Technology Some slides have been adapted from Python Programming: An Introduction to Computer Science
More informationIntroduction to Python
Introduction to Python Reading assignment: Perkovic text, Ch. 1 and 2.1-2.5 Python Python is an interactive language. Java or C++: compile, run Also, a main function or method Python: type expressions
More informationWelcome to Python 3. Some history
Python 3 Welcome to Python 3 Some history Python was created in the late 1980s by Guido van Rossum In December 1989 is when it was implemented Python 3 was released in December of 2008 It is not backward
More informationDefine a method vs. calling a method. Chapter Goals. Contents 1/21/13
CHAPTER 2 Define a method vs. calling a method Line 3 defines a method called main Line 5 calls a method called println, which is defined in the Java library You will learn later how to define your own
More informationIntroduction to Programming
Introduction to Programming Python Lab 3: Arithmetic PythonLab3 lecture slides.ppt 16 October 2018 Ping Brennan (p.brennan@bbk.ac.uk) 1 Getting Started Create a new folder in your disk space with the name
More informationURLs and web servers. Server side basics. URLs and web servers (cont.) URLs and web servers (cont.) Usually when you type a URL in your browser:
URLs and web servers 2 1 Server side basics http://server/path/file Usually when you type a URL in your browser: Your computer looks up the server's IP address using DNS Your browser connects to that IP
More informationIntroduction to Programming
Introduction to Programming Python Lab 3: Arithmetic PythonLab3 lecture slides.ppt 26 January 2018 Ping Brennan (p.brennan@bbk.ac.uk) 1 Getting Started Create a new folder in your disk space with the name
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 informationGetting Started with Python
Fundamentals of Programming (Python) Getting Started with Python Sina Sajadmanesh Sharif University of Technology Some slides have been adapted from Python Programming: An Introduction to Computer Science
More informationCISC-124. This week we continued to look at some aspects of Java and how they relate to building reliable software.
CISC-124 20180129 20180130 20180201 This week we continued to look at some aspects of Java and how they relate to building reliable software. Multi-Dimensional Arrays Like most languages, Java permits
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 informationPython 1: Introduction to Python 1 / 19
Python 1: Introduction to Python 1 / 19 Python Python is one of many scripting languages. Others include Perl, Ruby, and even the Bash/Shell programming we've been talking about. It is a script because
More informationPython Input, output and variables
Today s lecture Python Input, output and variables Lecture 22 COMPSCI111/111G SS 2016! What is Python?! Displaying text on screen using print()! Variables! Numbers and basic arithmetic! Getting input from
More information