Coding in Python Introduction to€¦ · Coding in Python Fermilab - TARGET 2018 Week 1. Coding is...
Transcript of Coding in Python Introduction to€¦ · Coding in Python Fermilab - TARGET 2018 Week 1. Coding is...
![Page 1: Coding in Python Introduction to€¦ · Coding in Python Fermilab - TARGET 2018 Week 1. Coding is a language First for humans, then for computer 1. Rigor and Formality 2. Abstraction](https://reader033.fdocuments.us/reader033/viewer/2022051605/600ee573054ece78bf4cdf8c/html5/thumbnails/1.jpg)
Introduction to Coding in PythonFermilab - TARGET 2018Week 1
![Page 2: Coding in Python Introduction to€¦ · Coding in Python Fermilab - TARGET 2018 Week 1. Coding is a language First for humans, then for computer 1. Rigor and Formality 2. Abstraction](https://reader033.fdocuments.us/reader033/viewer/2022051605/600ee573054ece78bf4cdf8c/html5/thumbnails/2.jpg)
![Page 3: Coding in Python Introduction to€¦ · Coding in Python Fermilab - TARGET 2018 Week 1. Coding is a language First for humans, then for computer 1. Rigor and Formality 2. Abstraction](https://reader033.fdocuments.us/reader033/viewer/2022051605/600ee573054ece78bf4cdf8c/html5/thumbnails/3.jpg)
Coding is a language
First for humans, then for computer
1. Rigor and Formality2. Abstraction3. Modules4. Divide et Impera (Divide, Conquer and Glue)5. Models6. Incremental steps
![Page 4: Coding in Python Introduction to€¦ · Coding in Python Fermilab - TARGET 2018 Week 1. Coding is a language First for humans, then for computer 1. Rigor and Formality 2. Abstraction](https://reader033.fdocuments.us/reader033/viewer/2022051605/600ee573054ece78bf4cdf8c/html5/thumbnails/4.jpg)
Rigor and Formality
Be clear and concise
Computers are really good at following precise orders
![Page 5: Coding in Python Introduction to€¦ · Coding in Python Fermilab - TARGET 2018 Week 1. Coding is a language First for humans, then for computer 1. Rigor and Formality 2. Abstraction](https://reader033.fdocuments.us/reader033/viewer/2022051605/600ee573054ece78bf4cdf8c/html5/thumbnails/5.jpg)
Abstraction
Useful representation of a real object
Isolate what is important for you
- e.g . a cat
![Page 6: Coding in Python Introduction to€¦ · Coding in Python Fermilab - TARGET 2018 Week 1. Coding is a language First for humans, then for computer 1. Rigor and Formality 2. Abstraction](https://reader033.fdocuments.us/reader033/viewer/2022051605/600ee573054ece78bf4cdf8c/html5/thumbnails/6.jpg)
Modules
Large systems are built with components called modules
Interfaces between modules allow to combine them in a mix-and-match way
![Page 7: Coding in Python Introduction to€¦ · Coding in Python Fermilab - TARGET 2018 Week 1. Coding is a language First for humans, then for computer 1. Rigor and Formality 2. Abstraction](https://reader033.fdocuments.us/reader033/viewer/2022051605/600ee573054ece78bf4cdf8c/html5/thumbnails/7.jpg)
Divide et Impera
Divide: Split in pieces
Conquer: Solve each piece
Merge the solution
![Page 8: Coding in Python Introduction to€¦ · Coding in Python Fermilab - TARGET 2018 Week 1. Coding is a language First for humans, then for computer 1. Rigor and Formality 2. Abstraction](https://reader033.fdocuments.us/reader033/viewer/2022051605/600ee573054ece78bf4cdf8c/html5/thumbnails/8.jpg)
Models
Simple models can describe complex artifacts
Use models: - to describe what you do - to create elements that behave like a real system
![Page 9: Coding in Python Introduction to€¦ · Coding in Python Fermilab - TARGET 2018 Week 1. Coding is a language First for humans, then for computer 1. Rigor and Formality 2. Abstraction](https://reader033.fdocuments.us/reader033/viewer/2022051605/600ee573054ece78bf4cdf8c/html5/thumbnails/9.jpg)
Incremental steps
One small step at the time
Plan for expansion
![Page 10: Coding in Python Introduction to€¦ · Coding in Python Fermilab - TARGET 2018 Week 1. Coding is a language First for humans, then for computer 1. Rigor and Formality 2. Abstraction](https://reader033.fdocuments.us/reader033/viewer/2022051605/600ee573054ece78bf4cdf8c/html5/thumbnails/10.jpg)
Low to High Level Programing Languages
Machine code - computers hardware understand binary numbers
Assembly - 1 to 1 mapping to computer instructions
(High level) Programming language - simpler and more understandable, need to be translated for the computer
![Page 11: Coding in Python Introduction to€¦ · Coding in Python Fermilab - TARGET 2018 Week 1. Coding is a language First for humans, then for computer 1. Rigor and Formality 2. Abstraction](https://reader033.fdocuments.us/reader033/viewer/2022051605/600ee573054ece78bf4cdf8c/html5/thumbnails/11.jpg)
Compiler or Interpreter
![Page 12: Coding in Python Introduction to€¦ · Coding in Python Fermilab - TARGET 2018 Week 1. Coding is a language First for humans, then for computer 1. Rigor and Formality 2. Abstraction](https://reader033.fdocuments.us/reader033/viewer/2022051605/600ee573054ece78bf4cdf8c/html5/thumbnails/12.jpg)
Programming language
A programming (or coding) language is a set of syntax rules that define how code should be written and formatted.
● Python● Java● Scala● JavaScript● SQL● Swift● C, C++, C#● FORTRAN
![Page 13: Coding in Python Introduction to€¦ · Coding in Python Fermilab - TARGET 2018 Week 1. Coding is a language First for humans, then for computer 1. Rigor and Formality 2. Abstraction](https://reader033.fdocuments.us/reader033/viewer/2022051605/600ee573054ece78bf4cdf8c/html5/thumbnails/13.jpg)
Algorithm
Self-contained step-by- step set of operations to be performed to solve a specific problem or a class of problems
![Page 14: Coding in Python Introduction to€¦ · Coding in Python Fermilab - TARGET 2018 Week 1. Coding is a language First for humans, then for computer 1. Rigor and Formality 2. Abstraction](https://reader033.fdocuments.us/reader033/viewer/2022051605/600ee573054ece78bf4cdf8c/html5/thumbnails/14.jpg)
Algorithm: Flowchart and Pseudocode
![Page 15: Coding in Python Introduction to€¦ · Coding in Python Fermilab - TARGET 2018 Week 1. Coding is a language First for humans, then for computer 1. Rigor and Formality 2. Abstraction](https://reader033.fdocuments.us/reader033/viewer/2022051605/600ee573054ece78bf4cdf8c/html5/thumbnails/15.jpg)
Variable
Variables are used to store information to be referenced and manipulated in a computer program
Variables have a name, value, representation, a type
![Page 16: Coding in Python Introduction to€¦ · Coding in Python Fermilab - TARGET 2018 Week 1. Coding is a language First for humans, then for computer 1. Rigor and Formality 2. Abstraction](https://reader033.fdocuments.us/reader033/viewer/2022051605/600ee573054ece78bf4cdf8c/html5/thumbnails/16.jpg)
(Complex) Data Structures
List
Array
Stack
Hash Table (Map/Dictionary)
Tree
Stack
Tree
Hash Table
![Page 17: Coding in Python Introduction to€¦ · Coding in Python Fermilab - TARGET 2018 Week 1. Coding is a language First for humans, then for computer 1. Rigor and Formality 2. Abstraction](https://reader033.fdocuments.us/reader033/viewer/2022051605/600ee573054ece78bf4cdf8c/html5/thumbnails/17.jpg)
Software - Global term for all the components (programs) distinct to hardware that tell a device what to do and how to behave
Application - A type of software that does a certain task. Intended for a particular platform or device. Often needs user interaction to function
Program - (algorithm + data structures) Sequence of instructions that comply the rules of a specific programming language, written to perform a specified task with a computer
![Page 18: Coding in Python Introduction to€¦ · Coding in Python Fermilab - TARGET 2018 Week 1. Coding is a language First for humans, then for computer 1. Rigor and Formality 2. Abstraction](https://reader033.fdocuments.us/reader033/viewer/2022051605/600ee573054ece78bf4cdf8c/html5/thumbnails/18.jpg)
If you have an idea for an Application then
● Write down the algorithm to sketch out your ideas● Use your own words● Think about data structures● Select a programming language● Only then write the code (and remember to test it, deploy it, document it
and use it!)
![Page 19: Coding in Python Introduction to€¦ · Coding in Python Fermilab - TARGET 2018 Week 1. Coding is a language First for humans, then for computer 1. Rigor and Formality 2. Abstraction](https://reader033.fdocuments.us/reader033/viewer/2022051605/600ee573054ece78bf4cdf8c/html5/thumbnails/19.jpg)
Why Python
● You Can Use Python for Pretty Much Anything● Python Is Beginner Friendly and can adapt to your style● Python Saves Time (batteries are included!)● Python is a requested skill and pays well● Is the 2nd most popular programming language in the world● Python Is Widely Used in Data Science● All the Big Names use Python (major tech companies like YouTube, IBM,
Yahoo, Dropbox, Quora, Mozilla, Instagram, and others)● We use Python a lot at Fermilab
![Page 20: Coding in Python Introduction to€¦ · Coding in Python Fermilab - TARGET 2018 Week 1. Coding is a language First for humans, then for computer 1. Rigor and Formality 2. Abstraction](https://reader033.fdocuments.us/reader033/viewer/2022051605/600ee573054ece78bf4cdf8c/html5/thumbnails/20.jpg)
Let's code!
![Page 21: Coding in Python Introduction to€¦ · Coding in Python Fermilab - TARGET 2018 Week 1. Coding is a language First for humans, then for computer 1. Rigor and Formality 2. Abstraction](https://reader033.fdocuments.us/reader033/viewer/2022051605/600ee573054ece78bf4cdf8c/html5/thumbnails/21.jpg)
Acknowledgements
Thank you to Jeny Teheran for letting me use some material from her TechSavvy presentation
Thanks to Pythonbytes, Indeeds, Dice, PYPL for news about Python popularity