Compsci 6/101: PFTW What is Python? What is a programming language?

Slides:



Advertisements
Similar presentations
In Review JAVA C++ GUIs - Windows Webopedia.com.
Advertisements

Dr. Ken Hoganson, © August 2014 Programming in R COURSE NOTES 2 Hoganson Language Translation.
Introduction to JavaScript
CSCE 145: Algorithmic Design I Chapter 1 Intro to Computers and Java Muhammad Nazmus Sakib.
POSH Python Object Sharing Steffen Viken Valvåg In collaboration with Kjetil Jacobsen & Åge Kvalnes University of Tromsø, Norway Sponsored by Fast Search.
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.
1 Programming Languages b Each type of CPU has its own specific machine language b But, writing programs in machine languages is cumbersome (too detailed)
HTML Recall that HTML is static in that it describes how a page is to be displayed, but it doesn’t provide for interaction or animation. A page created.
+ Java vs. Javascript Jessi Style. + Java Compiled Can stand on its own Written once, run anywhere Two-stage debugging Java is an Object Oriented Programming.
High-level Languages.
Algorithms and Programming
1 3. Computing System Fundamentals 3.1 Language Translators.
Compsci 101.2, Fall PFThursday l Review Organization and Problem-Solving  Defining functions, calling functions  Return types, print, None l.
Compsci 06/101, Fall How to build a program l Create a module  Can be used by other modules via import  Collection of functions, later collection.
Compsci 6/101, Spring More on Python, Tools, Compsci 101 l APTs, Assignments, Tools  APT: Algorithmic Problem-solving and Testing  How to get.
What am I?. Translators Translators – Module Knowledge Areas Types of translators and their use Lexical analysis Syntax analysis Code generation and.
Compsci 6/101, Spring PFTW: Sequences aka Strings&Lists l From Return values to Random-ness [aka two R's]  What power does random provide? 
CS 346 – Chapter 2 OS services –OS user interface –System calls –System programs How to make an OS –Implementation –Structure –Virtual machines Commitment.
Compsci 06/101, Spring Compsci 6/101: PFTW, Feb 28-March 4 l Algorithms and Data Structures  Sets and how they are used in Python (data structure)
Component 4: Introduction to Information and Computer Science Unit 5: Overview of Programming Languages, Including Basic Programming Concepts Lecture 2.
Compsci 101.2, Fall PFTWeek l Introduce new Python concepts  Control: if, elif, else, for  Data: Strings, Lists Operators on data: slicing,
A compiler is a computer program that translate written code (source code) into another computer language Associated with high level languages A well.
 Programming - the process of creating computer programs.
Georgia Institute of Technology Speed part 4 Barb Ericson Georgia Institute of Technology May 2006.
By: Cheryl Mok & Sarah Tan. Java is partially interpreted. 1. Programmer writes a program in textual form 2. Runs the compiler, which converts the textual.
Getting Started With Java September 22, Java Bytecode  Bytecode : is a highly optimized set of instructions designed to be executed by the Java.
Compsci 6/101, Spring PFTW: Functions, Control, Python/Tools l How do functions work and why do we use them?  Functions we call (APIs), Functions.
Compsci 06/101, Spring Compsci 6: PFTW l Problem solving and (Python) programming  What are the steps in solving an APT?  How do you get better.
CompSci 101 Introduction to Computer Science February 4, 2016 Prof. Rodger compsci101 spring161.
Representation of Data - Instructions Start of the lesson: Open this PowerPoint from the A451 page – Representation of Data/ Instructions How confident.
Presented By Sushil K. Chaturvedi Assistant Professor SRCEM,Banmore 1.
CPS 100, Spring Interlude for trees l Joyce Kilmer Joyce Kilmer l Balanced Trees  Splay  Red-Black  AVL  B-tree.
PHP using MySQL Database for Web Development (part II)
Computer System Structures
CSC235 Computer Organization & Assembly Language
Lecture 1b- Introduction
High or Low Level Programming Language? Justify your decision.
Topic: Programming Languages and their Evolution + Intro to Scratch
COSC 1306 COMPUTER SCIENCE AND PROGRAMMING
CompSci 101 Introduction to Computer Science
Computational Thinking, Problem-solving and Programming: General Principals IB Computer Science.
Learning to Program D is for Digital.
Introduction to Computer Science
CSCI-235 Micro-Computer Applications
Key Ideas from day 1 slides
Lecture 1: Introduction to JAVA
CompSci 101 Introduction to Computer Science
CompSci 101 Introduction to Computer Science
Programming Concepts and Languages
2.1. Compilers and Interpreters
Compsci 101, APTs and Sequences and Selection
Chapter 2: Operating-System Structures
CompSci 101 Introduction to Computer Science
High Level Programming Languages
CS-0401 INTERMEDIATE PROGRAMMING USING JAVA
Lesson Objectives Aims Key Words Compiler, interpreter, assembler
Introduction CSC 111.
CS105 Introduction to Computer Concepts Intro to programming
ICT Programming Lesson 1:
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
What is Programming Language
Review of Previous Lesson
1.3.7 High- and low-level languages and their translators
Programming language translators
Web Application Development Using PHP
CompSci 101 Introduction to Computer Science
Running & Testing Programs :: Translators
Hypervisor A hypervisor or virtual machine monitor (VMM) is computer software, firmware or hardware that creates and runs virtual machines. A computer.
Presentation transcript:

Compsci 6/101: PFTW What is Python? What is a programming language? How are programs executed? What does that mean? Why do you need to have an understanding of this? What are functions, modules, return values, function calls What’s an APT and how do you solve them? Why are you writing a function? Who calls the function you write? What is a list and what is a list comprehension? How to create, modify, and use lists Why lists will change your life … for the better!

Python (C, Javascript, Java, PHP, …) High level programming languages Translate to lower-level languages: assembly, bytecode Executed by a virtual machine or by a chip/real machine Compile the high level language into lower level Python compiler/interpreter written in C or Java (or …) Compilers for platforms: Mac, Windows, Linux, … Abstractions: foundation of languages Make it easier to think about problems and avoid details Hide details, which can sometimes have issues What is a loop, a list, an int, a String a function …

From high- to low-level Python def reverse(s): r = "" for ch in s: r = ch + r return r Create version on the right using dissassembler dis.dis(code.py) 7 0 LOAD_CONST 1 ('') 3 STORE_FAST 1 (r) 8 6 SETUP_LOOP 24 (to 33) 9 LOAD_FAST 0 (s) 12 GET_ITER >> 13 FOR_ITER 16 (to 32) 16 STORE_FAST 2 (ch) 9 19 LOAD_FAST 2 (ch) 22 LOAD_FAST 1 (r) 25 BINARY_ADD 26 STORE_FAST 1 (r) 29 JUMP_ABSOLUTE 13 >> 32 POP_BLOCK 10 >> 33 LOAD_FAST 1 (r) 36 RETURN_VALUE

High level, low level, abstractions Python byte-code is executed by… Platform specific virtual machine/environment Similar to Java Javascript code is executed by … Platform specific browser (Firefox, IE, Chrome, Opera, …) Is HTML executed? C++ code is executed by … The CPU and the operating system, from compiled code Compiler is platform specific Microsoft word is executed by … Platform specific OS, CPU, from compiled executable

Reading and understanding Python When a program executes where does it start? When you click the ‘run’ button, what happens? What does it mean to ‘execute sequentially’? What happens when one function calls another (e.g., FileFilter.py or OldWoman.py) Simple illustration: http://www.kongregate.com/games/Coolio_Niato/light-bot

Lynn Conway Joined U. Michigan 1985 NAE '89, IEEE Pioneer '09 See Wikipedia and lynnconway.com Joined Xerox Parc in 1973 Revolutionized VLSI design with Carver Mead Joined U. Michigan 1985 Professor and Dean, retired '98 NAE '89, IEEE Pioneer '09 Helped invent dynamic scheduling early '60s IBM Transgender, fired in '68

Debugging APTs: Going green TxMsg APT: from ideas to code to green What are the main parts of solving this problem? Transform words in original string Abstract that away at first Finding words in original string How do we do this? def getMessage(original): ret = "" for word in original.split(): ret = ret + " " + transform(word) return ret #initial space?

Debugging APTs: Going green CirclesCountry APT: from ideas to code to green How do we solve the problem? May not be apparent How do we loop over circles? What is a circle? When is a piont inside a circle? x = leastBorder([-3,2,2,0,-4,12,12,12], [-1,2,3,1,5,1,1,1],[1,3,1,7,1,1,2,3],2,3,13,2)

Set, Logic Operations from pictures http://en.wikipedia.org/wiki/File:Venn0111.svg

Revisiting cgratio APT How do you count 'c' and 'g' content of a string? Toward a transformative approach v. modification/mutate def cgcount(strand): cg = 0 for nuc in strand: if nuc == 'c' or nuc == 'g': cg += 1 return cg def cgcount2(strand): cg = [1 for ch in strand if ch == 'c' or ch == 'g'] return sum(cg)

List Comprehensions Creating a list from another list, two decisions: Is new list the same size as original, or smaller? Are elements the same or related by some correspondence? words = ["bear", "lion", "zebra", "python"] w2 = [w for w in words if some_property(w)] w3 = [f(w) for w in words] w4 = [1 for w in words if some_property(w)] Once we have list can apply list functions We have: len, sum, max, min Can "invent" others by writing functions

List Comprehensions Again Transformative approach can scale differently Functional programming: code generates and doesn't modify Basis for (ultra) large scale mapreduce/Google coding w = [expr for elt in list if bool-expr] w = [f(w) for w in list if bool_expr(w)] Why are abstractions important? Reason independently of concrete examples Generalize from concrete examples http://wapo.st/e5ZtkB