Skip to content

Commit

Permalink
Merge pull request #18 from fhdsl/S4
Browse files Browse the repository at this point in the history
Update 01-intro-to-computing.Rmd
  • Loading branch information
caalo authored Aug 22, 2024
2 parents e3ac92e + 9e6948b commit 27660a7
Showing 1 changed file with 10 additions and 6 deletions.
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

0 comments on commit 27660a7

Please sign in to comment.