Python: Array Slicing Damian Gordon.

Slides:



Advertisements
Similar presentations
Luminosity measurements at Hadron Colliders
Advertisements

From Word Embeddings To Document Distances
NHỮNG VẤN ĐỀ NỔI BẬT CỦA NỀN KINH TẾ VIỆT NAM GIAI ĐOẠN
Evolving Architecture for Beyond the Standard Model
CMSC423: Bioinformatic Algorithms, Databases and Tools
Some aspect concerning the LMDZ dynamical core and its use
实习总结 (Internship Summary)
Fuel cell development program for electric vehicle
داده کاوی سئوالات نمونه
ლექცია 4 - ფული და ინფლაცია
Wissenschaftliche Aussprache zur Dissertation
On Robust Neighbor Discovery in Mobile Wireless Networks
Online Learning: An Introduction
The Toroidal Sporadic Source: Understanding Temporal Variations
Howard Wiseman1 and Geoff Pryde1
פרויקט מסכם לתואר בוגר במדעים (B.Sc.) במתמטיקה שימושית
Solar Astronomy with LOFAR - First Steps
Virtual Memory II CSE 351 Spring 2017
Introduction to Scientific Computing
Measuring Wealth and Wealth Inequality
Technologies Needed for Fusion DEMO and the Role of International Collaboration Mohamed Abdou Distinguished Professor of Engineering and Applied Science.
Tradeoffs in contextual bandit learning
Chapter11 Authentication
Year 12 physics summary Use this as a reminder of content and a way of identifying weakness, NOT as a replacement for revision.
Status of the Crystal Zero Degree Detector (cZDD)
QPCR for quantification of synthetic ecosystems: hurdles and solutions
Examining the Feasibility of Long Term Care Insurance

Which of these arrows is closest to your original guess?
Knowledge Sharing: GSP Pump Energy Assessment
The Auxiliary Electric Team:
LDO Architecture Review
Introduction to Deep Learning
Chemistry 200 Focus 1 Atoms.
Chemistry 130 Dr. John F. C. Turner 409 Buehler Hall
Monday April 10, 2017 Welcome back! Last week of content!
Geotechnical Engineering II CE 481
Modelling of Realistic Intermediate band solar cells : Materials Focus
Jobs and Unemployment Goals for this chapter
Chapter 10. Cluster Analysis: Basic Concepts and Methods
Performance – meaning and metrics
Ch16: Hooke’s Law and Simple Harmonic Motion
Physics 7E Prof. D. Casper.
Physics Montwood High School R. Casao
Sealed-Glass Proofs: What can we do with SGX without confidentiality?
NA61/SHINE search for the critical point
Availability Operating systems I800
Department of Petroleum Engineering
Business of Platforms, Networks, and Two-sided Markets
Section 8-1 Review and Preview.
Chapter 2 Atoms. Molecules, and ions
1. Introduction The relationship between democracy and economic growth has received considerable attention in recent years But the debate on whether democracy.
Navigating Your Casio Calculator
Essentials of Modern Business Statistics (7e)
The Economic Value of Green Buildings
Grade 9 – Module 3 Module Focus Session
Important Terms computers interconnected by communication network
Chapter 1 Managers, Profits, and Markets
GCSE: Constructions & Loci
Systematic Managed Floating Jeffrey Frankel Harpel Professor of Capital Formation and Growth Harvard Kennedy School, Harvard University 4th Asian Monetary.
The PV Cell History, Basics & Technologies
Open Economy Macroeconomics for Dummies
19. Inference about a population proportion
Objectives (PSLS Chapter 19)
Secret from Muscle: Enabling Secure Paring with Electromyography
Feng Duan, Yu Lei, Linbin Yu, Raghu N. Kacker, D. Richard Kuhn
in response to VB-111 Virotherapy
ENZYMES- action and inhibition
History and Philosophy of the Black Hole Information Paradox
Python: Sorting – Selection Sort
Presentation transcript:

Python: Array Slicing Damian Gordon

Array Slicing Array Slicing is a way of quickly printing out sections of an array. It is not unique to Python, and is available in other languages such as Fortran, Algol, Ada, and MATLAB.

Array Slicing Array[start:end] # items start through end-1 Array[start:] # items start through the rest of the array Array[:end] # items from the beginning through end-1 Array[:] # a copy of the whole array Array[start:end:step] # start through not past end, by step

Array Slicing Let’s consider an array:

Array Slicing Let’s consider an array: If we print Array[3], we get: 3

Array Slicing Let’s consider an array: If we print Array[:3], we get: [0, 1, 2]

Array Slicing Let’s consider an array: If we print Array[3:], we get: [3, 4, 5, 6, 7]

Array Slicing Let’s consider an array: If we print Array[-3:], we get: [5, 6, 7]

Array Slicing Let’s consider an array: If we print Array[:-3], we get: [0, 1, 2, 3, 4]

Array Slicing Let’s consider an array: If we print Array[1:5], we get: [1, 2, 3, 4]

Array Slicing Let’s consider an array: If we print Array[1:5:2], we get: [1, 3]

Array Slicing Let’s try a 2D Array: MArray = [[0, 1, 2], [3, 4, 5], [6, 7, 8]]

Array Slicing Let’s try a 2D Array: MArray = [[0, 1, 2], [3, 4, 5], [6, 7, 8]] Let’s print MArray[1:] [[3, 4, 5], [6, 7, 8]]

Array Slicing Let’s try a 2D Array: MArray = [[0, 1, 2], [3, 4, 5], [6, 7, 8]] Let’s print MArray[:1] [[0, 1, 2]]

Array Slicing Let’s try a 2D Array: MArray = [[0, 1, 2], [3, 4, 5], [6, 7, 8]] Let’s print MArray[1:2] [[3, 4, 5]]

Array Slicing Let’s try a 2D Array: MArray = [[0, 1, 2], [3, 4, 5], [6, 7, 8]] Let’s print MArray[2:3] [[6, 7, 8]]

etc.