Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update 01-intro-to-computing.Rmd #18

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions 01-intro-to-computing.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ Python Notebook is great for data science work, because:

- It is flexible to use other programming languages, such as R.

The version of Python used in this course and in Google Colab is Python 3, which is the version of Python that is most supported. Some Python software is written in Python 2, which is very similar but has some [notable differences](https://www.fullstackpython.com/python-2-or-3.html).

Now, we will get to the basics of programming grammar.

## Grammar Structure 1: Evaluation of Expressions
Expand Down Expand Up @@ -215,21 +217,23 @@ And there is an operational equivalent:
2 ** 3
```

We will mostly look at functions with input arguments and return types in this course, but not all functions need to have input arguments and output return. Here are some varieties of functions to stretch your horizons.
We will mostly look at functions with input arguments and return types in this course, but not all functions need to have input arguments and output return. Let's look at some examples of functions that don't always have an input or output:

| Function call | What it takes in | What it does | Returns |
| Function call | What it takes in | What it does | Returns |
|---------------|---------------|----------------------------|---------------|
| `pow(a, b)` | integer `a`, integer `b` | Raises `a` to the `b`th power. | Integer |
| `print(x)` | any data type `x` | Prints out the value of `x` to the console. | None |
| `datetime.now()` | Nothing | Gets the current time. | String |
| `pow(a, b)` | integer `a`, integer `b` | Raises `a` to the `b`th power. | Integer |
| `print(x)` | any data type `x` | Prints out the value of `x` to the console. | None |
| `dir()` | Nothing | Gives a list of all the variables defined in the environment. | List |

## Tips on writing your first code

`Computer = powerful + stupid`

Computers are excellent at doing something specific over and over again, but is extremely rigid and lack flexibility. Here are some tips that is helpful for beginners:

- Write incrementally, test often
- Write incrementally, test often.

- Don't be afraid to break things: it is how we learn how things work in programming.

- Check your assumptions, especially using new functions, operations, and new data types.

Expand Down
Loading