<style>
.reveal {
font-size: 20px;
}
.reveal div.para {
text-align: left;
}
.reveal ul {
display: block;
}
.reveal ol {
display: block;
}
img[alt=drawing] { width: 200px; }
</style>
# COMP1010
## 4 Python in the Real World
---
## Moving away from Colab
* To make our own websites, we need a bit more flexibility than Colab can give us.
* Set up your computer by following the instructions in the course notice.
---
## Example
You can convert any of our programs so far.
* Crochet example
* Users
* Movies
Or write a new one.
* Guess my number
* Tic Tac Toe
---
## Code Style
* Indentation:
* Not tabs - spaces.
* 4 spaces per indentation level is ideal.
* 2, 3 or 4 spaces are acceptable, but they must be consistent.
* Line length:
* Line length should not exceed 79 characters.
* [Reasoning](https://www.python.org/dev/peps/pep-0008/#maximum-line-length)
* If you need help (eg your line of code is longer than this, and you need to put it over 2 lines, but then the code breaks), post your specific example on the forums and we can show you how to do this.
---
# Code Style
* Functions:
* Don't leave chunks of code floating around your file.
* When in doubt, put your code in a (well-named) function, and call it at the right time.
---
# File Structure
```{python}
# import libraries (if you have them)
# define constants (if you have them)
# other functions you write (if you have them)
def main():
# Your code here
if __name__ == '__main__':
main()
```
---
## Checking the main
What is the purpose of this?
```{python}
if __name__ == '__main__':
main()
```
---
## Constants
* Variables, except...
* Don't change throughout your entire code.
* Style: should be defined in capital letters.
* Examples:
* Guess My Number:
* `START_HIGH = 100`
* `START_LOW = 0`
* Tic Tac Toe:
* `BOARD_SIZE = 3`
* `PLAYER_1 = 'X'`
* `PLAYER_2 = 'O'`
* `EMPTY = '-'`
---
{"metaMigratedAt":"2023-06-17T18:13:19.502Z","metaMigratedFrom":"YAML","title":"4 Python in the Real World","breaks":true,"slideOptions":"{\"transition\":\"slide\"}","contributors":"[{\"id\":\"969c3c3d-0ef4-4f08-b22a-2f2b8951224b\",\"add\":2095,\"del\":0}]"}