Fundamentals of Coding Flashcards
(41 cards)
What is scientific computing?
Coding for the purpose of science
We want to use coding to:
- Manage large amounts of data
- Apply some math/algorithms
- Visualize our data
Computer Scientists
Solving complex problems with math and computations
Software Engineers
Design and develop user-friendly software
Why can’t we just use Excel
- Highly inefficient
- Greater chance of introducing errors
- No permanent record
- Not reproduceable
R
- Developed for statistical computing
- Many statistical libraries
- Used primarily by researchers
- Free to use
Python
- General purpose language
- Large user base
- variety of libraries for data
- free to use
- widespread use across industry
MatLab
- heavily used in engineering
- excellent for signal processing
- Standard toolboxes
- requires a license
Functions
Block of code that only runs when you call it
Modules
Grouping of functions for similar tasks
Packages/Libraries
Grouping of modules for similar projects
Anaconda
A distribution of the Python for scientific computing and data science, that aims to simplify package management and development
Google CoLab
- Cloud-based platform for writing and executing python code
- hosted by Google drive, requiring only a Google account
- Provides free access to computational resources
Strings
- Variables that contains numbers, letters, or other characters
- CANNOT be used in computations
Numbers
Only contain numbers and can be used in computations
Floats
Precision numbers that carry decimal places and as such are most commonly used for storing data
- can be converted to an integer using the int command
Booleans
Represent true or false evaluation of content
Lists
- Single variables that store multiple items
- Defined by square brackets []
- Can store strings, floats, booleans, integers
Finding items on a list through index
Add .index() after the name of the list with the item we are looking for in the round brackets
Dictionaries
Allows you to store “keys” to pair with values/variables
- defined by curly brackets{}
Rules for naming variables
- Cannot start with a number
- Cannot use a reserved word as a name
- Cannot use a special symbol
- Upper and lowercase characters are read differently
Best practices when naming variables
- Never use the letters I or 0 as a single letter names (easily mistaken for 1 or 0)
- Don’t make them too general, but also not so descriptive that they become wordy
- Keep them short, but long enough to be descriptive
- Variable names should be lowercase with underscores used as a separator
- A constant can be fully capitalized
Control structures
Blocks of code that analyze variables and decide the direction the program takes
- Precondition: state of the variables entering a control structure
- Control structure: the program or algorithm that runs based on the preconditions
- Post condition: stat of the variables after the control structure has run
What are the 3 basic types of control structures
- Sequence: Simply runs 1 line after another like a recipe
- Selection: Allows for decisions and branching to occur within the block of code
- Iteration: Used for repeating lines of code
How do you combine strings
can use +