High-level languages + Python

Slides:



Advertisements
Similar presentations
Programming Types of Testing.
Advertisements

Creating a Program In today’s lesson we will look at: what programming is different types of programs how we create a program installing an IDE to get.
Compilers and Interpreters. Translation to machine language Every high level language needs to be translated to machine code There are different ways.
PYTHON: LESSON 1 Catherine and Annie. WHAT IS PYTHON ANYWAY?  Python is a programming language.  But what’s a programming language?  It’s a language.
CS190/295 Programming in Python for Life Sciences: Lecture 1 Instructor: Xiaohui Xie University of California, Irvine.
Topics Introduction Hardware and Software How Computers Store Data
Introduction to Python
General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 09/03/2010.
A First Program CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington Credits: a significant part of.
PYTHON. Python is a high-level, interpreted, interactive and object- oriented scripting language. Python was designed to be highly readable which uses.
Python – Part 1 Python Programming Language 1. What is Python? High-level language Interpreted – easy to test and use interactively Object-oriented Open-source.
Python From the book “Think Python”
Guide to Programming with Python Chapter One Getting Started: The Game Over Program.
Chapter 1 Introduction Chapter 1 Introduction 1 st Semester 2015 CSC 1101 Computer Programming-1.
I Power Higher Computing Software Development Development Languages and Environments.
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
CSC 1010 Programming for All Lecture 2 Introduction to Python Some material based on material from Marty Stepp, Instructor, University of Washington.
REFERENCE: CHAPTER 1 High-level languages + Python.
The single most important skill for a computer programmer is problem solving Problem solving means the ability to formulate problems, think creatively.
Compiler Construction CPCS302 Dr. Manal Abdulaziz.
1. COMPUTERS AND PROGRAMS Rocky K. C. Chang September 6, 2015 (Adapted from John Zelle’s slides)
Python 1 SIGCS 1 Intro to Python March 7, 2012 Presented by Pamela A Moore & Zenia C Bahorski 1.
Introducing Python 3 Introduction to Python. Introduction to Python L1 Introducing Python 3 Learning Objectives Know what Python is and some of the applications.
PROBLEM SOLVING WARM-UP Fill in the spaces using any operation to solve the following (!, (), -/+,÷,×): = 6.
Chapter 1 Introduction 2nd Semester H
Topic 2: Hardware and Software
The build process + misc
Introduction to Programming
Fundamentals of Programming I Overview of Programming
Introducing Python Introduction to Python.
Why don’t programmers have to program in machine code?
Development Environment
Component 1.6.
Assembly language.
COSC 1306 COMPUTER SCIENCE AND PROGRAMMING
Learning to Program D is for Digital.
Topics Introduction Hardware and Software How Computers Store Data
Python Let’s get started!.
Introduction to Python
Compiler Construction (CS-636)
Pamela Moore & Zenia Bahorski
ICS103 Programming in C Lecture 3: Introduction to C (2)
A451 Theory – 7 Programming 7A, B - Algorithms.
Variables, Expressions, and IO
Introduction to Programming
Introduction to Programming
Teaching Computing to GCSE
TRANSLATORS AND IDEs Key Revision Points.
Teaching Computing to GCSE
CS190/295 Programming in Python for Life Sciences: Lecture 1
Language Basics.
Learning Outcomes –Lesson 4
Escape sequences: Practice using the escape sequences on the code below to see what happens. Try this next code to help you understand the last two sequences.
Topics Introduction Hardware and Software How Computers Store Data
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
CMP 131 Introduction to Computer Programming
Topics Designing a Program Input, Processing, and Output
Introduction to Programming
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
A programming language
Tonga Institute of Higher Education IT 141: Information Systems
CISC101 Reminders Labs start this week. Meet your TA! Get help with:
Tonga Institute of Higher Education IT 141: Information Systems
Chapter 1: Programming Basics, Python History and Program Components
General Computer Science for Engineers CISC 106 Lecture 03
1.3.7 High- and low-level languages and their translators
WJEC GCSE Computer Science
Introduction to Python
Running & Testing Programs :: Translators
Programming for Business Computing Introduction
Presentation transcript:

High-level languages + Python Reference: Chapter 1 (I’ll try to put these at the Beginning of most lectures – it’s from the optional textbook on the syllabus)

??? Game Programming…??? Half-life 3! mov ax, 0x5000 add ax, 0x0001 … …. …(5 billion lines later)… jmp 0x6539

In the old days…the missing piece was a person! VOUT LDA #$20 STA ScanLine ; We're assuming scanline $20. STA WSYNC STA HMOVE ; Move sprites horizontally. VOUT_VB LDA INTIM BNE VOUT_VB ; Wait for INTIM to time-out. STA CXCLR ; Clear collision latches STA VBLANK ; End vertical blank TSX STX TMPSTK ; Save stack pointer LDA #$02 STA CTRLPF ; Double, instead of reflect. LDX KLskip Vskip1 STA WSYNC ; Skip a few scanlines... DEX BNE Vskip1 LDA KLskip CMP #$0E ; "No Score" value of KLskip BEQ Vmain This is a 20-line snippet. The complete program has 1988 lines! See http://www.bjars.com/source/Combat.asm for the full source code (very well commented!) Ted Dabney (L) and Nolan Bushnell (R)

Ready to learn assembly? Why don’t (most) programmers write programs this way? What’s the alternative?

High-level Programming languages to the rescue! Half-Life 3 mov ax, 0x5000 add ax, 0x0001 … …. …(5 billion lines later)… jmp 0x6539 3 Halo Image from: http://ninjanerdstech.com/wiki/halo-4/

Compilers / Interpreters compiler and interpreter Specific to architecture and OS Steps: Reads source file(s). Generates machine code (CPU instructions) Compilers Stand-alone executable (.exe file) Faster to run, slow to build. Cryptic run-time errors Interpreters re-generate machine code every run Instantaneous “build”, slower execution Very informative run-time errors

High Level Languages Name Some! Why are there so many? Interpreted: Compiled: Why are there so many?

Python! +: Easy to read/write (more English-like than many) +: A ton of libraries e.g. pygame (www.pygame.org) +: Good balance between ease-of-use and power. -: Interpreted (so a little slower) -: A little harder to distribute Note: Already installed on the lab computers See the pdf on ssugames for instructions on installing it at home / on laptop

Script vs. Interactive mode Interpreters usually have "interactive" mode [Script mode differences] [Demonstrate in IDLE] A word about IDE’s (e.g. PyCharm)

Errors Jason’s rule-of-thumb (how much time you’ll spend) ~20% planning your approach ~10% writing code ~70% debugging / re-factoring code. Syntax Errors Exceptions Try these (in interactive mode): print(Hello, World”) print(Hello, World) Print(“Hello, World”)

Errors, cont. Call Stack: This is the line number of the error: We got there from here: We got to the error from here: The bottom section is the actual error: This is the type of Error:

Print Function print(expression) expression can be: A string A number A mathematical expression: 4 + 5 4 - 5 4 * 5 4 / 5 2 ** 3 A comma-separated sequence of expressions [sep and end]

Comments [Syntax and evaluation] [Why are they useful?]

Quick taste of variables Basically, a place to store a value. Use them just as you would a hard-coded (constant) value. >>> x = 15 >>> print(“x is”, x) x is 15 Warning: NOT a rule (as in math) Just holds the last value assigned to it. >>> width = 10 >>> height = 4 >>> area = width * height >>> print(area) 40 >>> width = 20 40 (did you think it was 80? Why not?)

Input function [As a means to pause] We'll see the real use next time…