Core libraries Scripts, by default only import sys (various system services/functions) and builtins (built-in functions, exceptions and special objects.

Slides:



Advertisements
Similar presentations
Chapter 18 Building the user interface. This chapter discusses n Javas graphical user interface. n Swing: an enhancement of a library called the Abstract.
Advertisements

Python 3000 and You Guido van Rossum EuroPython July 7, 2008.
Python 3000 and You Guido van Rossum PyCon March 14, 2008.
Python Regrets OSCON, July 25, 2002
Topics in Python Blackjack & TKinter
Noadswood Science,  To know how to use Python to produce windows and colours along with specified co-ordinates Sunday, April 12, 2015.
COMP234 Perl Printing Special Quotes File Handling.
An Introduction to Python and Its Use in Bioinformatics
Python By Steve Wright. What is Python? Simple, powerful, GP scripting language Simple, powerful, GP scripting language Object oriented Object oriented.
Introduction to Python
Introduction to Computing Using Python Chapter 6  Encoding of String Characters  Randomness and Random Sampling.
Python Programming Fundamentals
History Server & API Christopher Larrieu Jefferson Laboratory.
Introduction to Python Basics of the Language. Install Python Find the most recent distribution for your computer at:
1 CSC 221: Introduction to Programming Fall 2012 Functions & Modules  standard modules: math, random  Python documentation, help  user-defined functions,
Piotr Wolski Introduction to R. Topics What is R? Sample session How to install R? Minimum you have to know to work in R Data objects in R and how to.
Recap Script M-file Editor/Debugger Window Cell Mode Chapter 3 “Built in MATLAB Function” Using Built-in Functions Using the HELP Feature Window HELP.
Introducing Python CS 4320, SPRING Lexical Structure Two aspects of Python syntax may be challenging to Java programmers Indenting ◦Indenting is.
A Level Computing#BristolMet Session ObjectivesU2#S12 MUST describe the terms modal and pretty printing in term of input and output facilities. SHOULD.
© Copyright 2012 by Pearson Education, Inc. All Rights Reserved. 1 Chapter 3 Mathematical Functions, Strings, and Objects.
TCL TK. Tcl/Tk C functions can become Tcl commands that are invoked interactively Tk = scriptable, portable user interface –Windows, X (Unix), MacOS,
CIS 601 Fall 2003 Introduction to MATLAB Longin Jan Latecki Based on the lectures of Rolf Lakaemper and David Young.
Python Programming, 2/e1 Python Programming: An Introduction to Computer Science Chapter 4 Objects and Graphics.
Normal Distributions. Probability density function - the curved line The height of the curve --> density for a particular X Density = relative concentration.
Why Is It There? Chapter 6. Review: Dueker’s (1979) Definition “a geographic information system is a special case of information systems where the database.
Quiz 1 A sample quiz 1 is linked to the grading page on the course web site. Everything up to and including this Friday’s lecture except that conditionals.
Indentations makes the scope/block Function definition def print_message (): print “hello” Function usages print_message () hubo.move ()// hubo is a class.
An Introduction To Tcl Scripting John Ousterhout Sun Microsystems Laboratories Tcl/Tk Tutorial, Part II.
Web Database Programming Using PHP
PHP LANGUAGE MULTIPLE CHOICE QUESTION SET-5
Fundamentals of Programming I Overview of Programming
Statistical Methods Michael J. Watts
Statistical Methods Michael J. Watts
Introduction to Python
Introduction Python is an interpreted, object-oriented and high-level programming language, which is different from a compiled one like C/C++/Java. Its.
Web Database Programming Using PHP
CS 100: Roadmap to Computing
Programming for Geographical Information Analysis: Core Skills
Python Useful Functions and Methods
Lecture 10 Data Collections
CSE 3302 Programming Languages
Principles of Computing – UFCFA3-30-1
Introduction to Python
Introduction to MATLAB
Digital Image Processing using MATLAB
What Is a Program? A program is like an algorithm, but describes a process that is ready or can be made ready to run on a real computer Retrieved from:
Introduction to Python
Modules and Packages.
Chapter 2: System Structures
CISC101 Reminders Slides have changed from those posted last night…
Winter 2018 CISC101 12/1/2018 CISC101 Reminders
Python Useful Functions and Methods
PHP.
CSC1018F: Intermediate Python
Variables and Expressions
Coding Concepts (Data- Types)
Python Tutorial for C Programmer Boontee Kruatrachue Kritawan Siriboon
Rocky K. C. Chang September 18, 2018 (Based on Zelle and Dierbach)
Chapter 3 Mathematical Functions, Strings, and Objects
Topics Introduction to Value-returning Functions: Generating Random Numbers Writing Your Own Value-Returning Functions The math Module Storing Functions.
Programming for Geographical Information Analysis: Core Skills
CHAPTER 3: String And Numeric Data In Python
High-Level Programming Languages
CS2911 Week 2, Class 3 Today Return Lab 2 and Quiz 1
COMPUTER PROGRAMMING SKILLS
FEATURES OF PYTHON.
Python’s STD Library Part II.
Python Useful Functions and Methods
UNIT 8: Statistical Measures
Presentation transcript:

Core libraries Scripts, by default only import sys (various system services/functions) and builtins (built-in functions, exceptions and special objects like None and False). The Python shell doesn’t import sys, and builtins is hidden away as __builtins__.

Built in functions https://docs.python.org/3/library/functions.html abs() dict() help() min() setattr() all() dir() hex() next() slice() any() divmod() id() object() sorted() ascii() enumerate() input() oct() staticmethod() bin() eval() int() open() str() bool() exec() isinstance() ord() sum() bytearray() filter() issubclass() pow() super() bytes() float() iter() print() tuple() callable() format() len() property() type() chr() frozenset() list() range() vars() classmethod() getattr() locals() repr() zip() compile() globals() map() reversed() __import__() complex() hasattr() max() round()   delattr() hash() memoryview() set() https://docs.python.org/3/library/functions.html

Python Standard Library https://docs.python.org/3/py-modindex.html https://docs.python.org/3/library/index.html https://docs.python.org/3/tutorial/stdlib.html Most give useful recipes for how to do major jobs you're likely to want to do.

Useful libraries: text difflib – for comparing text documents; can for example generate a webpages detailing the differences. https://docs.python.org/3/library/difflib.html Unicodedata – for dealing with complex character sets. See also "Fluent Python" https://docs.python.org/3/library/unicodedata.html regex https://docs.python.org/3/library/re.html

Collections https://docs.python.org/3/library/collections.html # Tally occurrences of words in a list c = Counter() for word in ['red', 'blue', 'red', 'green', 'blue', 'blue']: c[word] += 1 print(c) <Counter({'blue': 3, 'red': 2, 'green': 1})>

Collections https://docs.python.org/3/library/collections.html # Find the ten most common words in Hamlet import re words = re.findall(r'\w+', open('hamlet.txt').read().lower()) Counter(words).most_common(5) [('the', 1143), ('and', 966), ('to', 762), ('of', 669), ('i', 631)] https://docs.python.org/3/library/collections.html#collections.Counter

Useful libraries: binary data https://docs.python.org/3/library/binary.html See especially struct: https://docs.python.org/3/library/struct.html

Useful libraries: maths https://docs.python.org/3/library/math.html decimal — Does for floating points what ints do; makes them exact https://docs.python.org/3/library/decimal.html fractions — Rational numbers (For dealing with numbers as fractions https://docs.python.org/3/library/fractions.html

Statistics https://docs.python.org/3/library/statistics.html mean() Arithmetic mean (“average”) of data. harmonic_mean() Harmonic mean of data. median() Median (middle value) of data. median_low() Low median of data. median_high() High median of data. median_grouped() Median, or 50th percentile, of grouped data. mode() Mode (most common value) of discrete data. pstdev() Population standard deviation of data. pvariance() Population variance of data. stdev() Sample standard deviation of data. variance() Sample variance of data.

Random selection Random library includes functions for: Selecting a random choice Shuffling lists Sampling a list randomly Generating different probability distributions for sampling.

Auditing random numbers Often we want to generate a repeatable sequence of random numbers so we can rerun models or analyses with random numbers, but repeatably. https://docs.python.org/3/library/random.html#bookkeeping- functions Normally uses os time, but can be forced to a seed.

Useful libraries: lists/arrays bisect — Array bisection algorithm (efficient large sorted arrays for finding stuff) https://docs.python.org/3/library/bisect.html

Useful libraries: TkInter https://docs.python.org/3/library/tk.html Used for Graphical User Interfaces (windows etc.) Wrapper for a library called Tk (GUI components) and its manipulation languages Tcl. See also: wxPython: Native looking applications: https://www.wxpython.org/ (Not in Anaconda) https://en.wikipedia.org/wiki/Tcl

Turtle https://docs.python.org/3/library/turtle.html For drawing shapes. TKInter will allow you to load and display images, but there are additional external libraries better set up for this, including Pillow: http://python-pillow.org/

Useful libraries: talking to the outside world Serial ports https://docs.python.org/3/faq/library.html#how-do-i-access-the-serial- rs232-port argparse — Parser for command-line options, arguments and sub-commands https://docs.python.org/3/library/argparse.html datetime https://docs.python.org/3/library/datetime.html

Databases DB-API https://wiki.python.org/moin/DatabaseProgramming dbm — Interfaces to Unix “databases” https://docs.python.org/3/library/dbm.html Simple database sqlite3 — DB-API 2.0 interface for SQLite databases https://docs.python.org/3/library/sqlite3.html Used as small databases inside, for example, Firefox.