Introduction to Python programming

Slides:



Advertisements
Similar presentations
Guy Griffiths. General purpose interpreted programming language Widely used by scientists and programmers of all stripes Supported by many 3 rd -party.
Advertisements

Why python? Automate processes Batch programming Faster Open source Easy recognition of errors Good for data management What is python? Scripting programming.
XP 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial 10.
Python Jordan Miller and Lauren Winkleman CS 311 Fall 2011.
Jonathan Huelman CSC 415 – Programming Languages
Python for S60 SmartPhones PostPC Workshop Fall 2006 Amnon Dekel.
Python Introduction.
CSC 110 A 1 CSC 110 Introduction to Python [Reading: chapter 1]
Programming 101 with Python: an open-source, cross-platform, and fun language By J. Burton Browning, Ed.D. Copyright © J. Burton Browning All rights reserved.
Python Mini-Course University of Oklahoma Department of Psychology Day 1 – Lesson 2 Fundamentals of Programming Languages 4/5/09 Python Mini-Course: Day.
CSCI 224 Introduction to Java Programming. Course Objectives  Learn the Java programming language: Syntax, Idioms Patterns, Styles  Become comfortable.
IT 211 Project Integration and Deployment Lab #11.
Python: An Introduction
Introduction to Programming Workshop 1 PHYS1101 Discovery Skills in Physics Dr. Nigel Dipper Room 125d
Introduction to PythonIntroduction to Python SPARCS `08 서우석 (pipoket) `09 Summer SP ARCS Seminar`09 Summer SP ARCS Seminar.
August 29, 2005ICP: Chapter 1: Introduction to Python Programming 1 Introduction to Computer Programming Chapter 1: Introduction to Python Programming.
XP Tutorial 10New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with JavaScript Creating a Programmable Web Page for North Pole.
CHAPTER TEN AUTHORING.
Python From the book “Think Python”
Guide to Programming with Python Chapter One Getting Started: The Game Over Program.
Python – May 11 Briefing Course overview Introduction to the language Lab.
OCR GCSE Computing © Hodder Education 2013 Slide 1 OCR GCSE Computing Python programming 1: Introduction.
Introduction to Python Origins Nature of Python Importance of Python Example.
CSC 1010 Programming for All Lecture 2 Introduction to Python Some material based on material from Marty Stepp, Instructor, University of Washington.
Python  Monty or Snake?. Monty?  Spam, spam, spam and eggs  Dead parrots  Eric Idle, John Cleese, Michael Palin, etc.
Exploring Spyder: An IDE for scientific computing
PYTHON FOR HIGH PERFORMANCE COMPUTING. OUTLINE  Compiling for performance  Native ways for performance  Generator  Examples.
Getting Started With Python Brendan Routledge
PROBLEM SOLVING WARM-UP Fill in the spaces using any operation to solve the following (!, (), -/+,÷,×): = 6.
PYTHON PROGRAMMING LANGUAGE.
How to Get Started With Python
Introduction to.
Python Programming Unit -1.
Programming For Big Data
Introduction to Perl: Practical extraction and report language
Development Environment
Top 8 Best Programming Languages To Learn
Programming and Debugging with the Dragon and JTAG
Introduction to GIS PythonScript CGIS-NURIntroduction to ArcGIS II.
Release Numbers MATLAB is updated regularly
CSC391/691 Intro to OpenCV Dr. Rongzhong Li Fall 2016
Key Ideas from day 1 slides
Introduction Python is an interpreted, object-oriented and high-level programming language, which is different from a compiled one like C/C++/Java. Its.
Matlab Training Session 4: Control, Flow and Functions
Intro To Pete Alonzi University of Virginia Library
PYTHON: AN INTRODUCTION
DATA MINING Python.
Guide To UNIX Using Linux Third Edition
Python in astronomy + Monte-Carlo techniques
Prepared by Kimberly Sayre and Jinbo Bi
Training on Real-time project With 100 % assistance support Training by IT professionals Trainers have 5+ years experience
Why are there so many snakes?
Unit# 8: Introduction to Computer Programming
TRANSLATORS AND IDEs Key Revision Points.
Do you know this browser?...
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
CIS16 Application Development – Programming with Visual Basic
Brief Intro to Python for Statistics
Topics Introduction Hardware and Software How Computers Store Data
Advanced Programming in Java
Python Basics Wen-Yen Hsu, Hsiao-Lung Chan Dept Electrical Engineering
Using Script Files and Managing Data
Chapter 1: Programming Basics, Python History and Program Components
Programming Arc.
Numpy, pylab, matplotlib (follow-up)
Python Debugging Session
Installations for Course
Installations for Course
Presentation transcript:

Introduction to Python programming Gal Rattner

Outlines What is python? Installation Conda Virtual environments & Interpreters Packages Syntax Functions Examples Links So why doing text prediction?

What is python? There are two main versions to python: Python is a dynamic (compiled at runtime) programming language, gaining huge popularity in the recent years Created in 1991 by Guido van Rossum It is open source – packages are developed and released by programmers frequently There are two main versions to python: Python 2.x (late is 2.7) – will be deprecated by 2020 Python 3.x (3.5/3.6/3.7) - mainly used Easy to learn – mainly used for server programming, mathematics (replacing matlab), ML etc. You should use only 3.5 and above. Except some Image processing packages – didn’t see anything that doesn’t exist in 3.5 ^

Installation Installation can be done in few ways: Python.org Anaconda3 – managing installation of packages Pycharm – JetBains Integrated Development Environment (IDE) for python We will install Conda and open Virtual environment Then we will install pycharm and define the environment as the project interpreter

Installation Installing Anaconda3 Using CMD prompt: https://conda.io/docs/user-guide/install/windows.html#install-win-silent Pay attention that you install with the proper 3.x python version Using CMD prompt: The environments can be switched using ‘activate <name>’ , ‘deactivate <name>’ The * signify which env is now active

Installation Installing Pycharm Pycharm is one of the common IDEs (like MS Visual Studio for example) It is very comfortable and adjusted for remote connection and ML development Installation link: https://www.jetbrains.com/help/pycharm/install-and-set-up-pycharm.html Make sure to install the full version and not ‘community edition ’ (CE) for remote control ability.

Installation Open a new project and select the ‘interpreter’ to be the conda virtual env you created. or in: File  settings  project interpreter

Python packages The basic Python language is very thin and shallow Extensions are added manually to each project as ‘import <package>’ command Import should be used at the top of each python script file Some of the common packages numpy – dealing with numbers and mathematics pickle – save/load files os - operations on files (move/remove/create) time - times calculation tensorflow/torch – ML packages *You can import a class/subpackage from a package, or rename an imported package

Python packages import numpy as np Use shortcut: One of the most important packages for research work is numpy numpy has many Matlab-like functions and operators np.ones(100,10) np.squeeze() np.linspace() Etc. Use shortcut: import numpy as np All mathematics and vector operations should be done ONLY using np, for efficiency and preciseness Python math operations often include substantial errors

Python syntax Python data structures Syntax list – the basic array structure in python, bound with [], can contain more than one data types [1, 2, 4, ‘stam_string’, 8, 16] np.array -- the numpy array type, used for vector/matrix math dictionary – complex data structure that stores “keys” and their ‘values’ {”name” : ‘gal’, ”age” : 29, “occupation” : ‘researcher’} Syntax Indentation !!! Data copying – make sure to use ‘copy’ package to deep copy non scalar data objects Make sure not to use saved words as variables names (in, list, len, etc.) dot dot colon ‘ : ’ Object oriented programmin

Python tips OOP – define classes and call them to create objects init() functions Properties (@propery) private functions – for effective and easy coding Use vectorization of the calculation (instead of for loops) – reduces runtime by 1-2 orders Use global variables to use common data between functions Use pycharm debug mode all the time! Object oriented programmin

Examples Object oriented programmin

Questions

Links Python tutorials: Conda: Pycharm: https://www.w3schools.com/python/python_getstarted.asp https://www.learnpython.org/ Conda: https://conda.io/docs/user-guide/getting-started.html Pycharm: https://www.jetbrains.com/pycharm/documentation/ Linux tutorial (for server work): https://www.tutorialspoint.com/unix/ Michael Nielsen ML book & examples: http://neuralnetworksanddeeplearning.com/chap1.html Object oriented programmin