From b0537073ec75589f7efcfe16d4558ac7eb8cf0c9 Mon Sep 17 00:00:00 2001
From: Nathan <nathan@druids.tech>
Date: Sun, 8 Oct 2023 19:43:02 +0100
Subject: [PATCH] week8

---
 .gitignore                |   1 +
 manifests/week8.md        |   3 +
 practicals/week8/tasks.md | 143 ++++++++++++++++++++++++++++++++++++++
 practicals/week8/week8.md |  27 +++++++
 practicals/week8/week8.py |   0
 5 files changed, 174 insertions(+)
 create mode 100644 .gitignore
 create mode 100644 manifests/week8.md
 create mode 100644 practicals/week8/tasks.md
 create mode 100644 practicals/week8/week8.md
 create mode 100644 practicals/week8/week8.py

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..e43b0f9
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+.DS_Store
diff --git a/manifests/week8.md b/manifests/week8.md
new file mode 100644
index 0000000..ea3bf4d
--- /dev/null
+++ b/manifests/week8.md
@@ -0,0 +1,3 @@
+practicals/week8/tasks.md
+practicals/week8/week8.md
+practicals/week8/week8.py
\ No newline at end of file
diff --git a/practicals/week8/tasks.md b/practicals/week8/tasks.md
new file mode 100644
index 0000000..4cf2a17
--- /dev/null
+++ b/practicals/week8/tasks.md
@@ -0,0 +1,143 @@
+# Week 8 Tasks for practicals
+
+# Task 1 - Intro to Python
+
+In Task 1 we will begin to build up a set of notes (in week8.md) about python as we learn new concepts. The process for this should include the following for each of the following headings:
+- writing simple bits of code in `week8.py` 
+- testing the code by running and observing the output
+- copying the code into code blocks in `week8.md` and providing your own descriptions for future reference
+
+> (Optional) If you already feel confident and more experienced with Python, you can still find and document more advanced feature(s) for each of these categories. Some ideas may include tuples, sets, dictionaries or lists for variables, pattern matching, iterators and lambda functions for other topics respectively.
+
+## Printing in python
+
+We have covered printing in python during our lecture session. We also have a description available in the `ctap-resources/guides` [here](https://gitlab.uwe.ac.uk/ctap/ctap-resources/-/blob/main/guides/printing-in-python.md).
+
+## Variables
+
+In Python, variables are used to store and manipulate data. They act as containers that hold values, which can be of different types such as numbers, strings, or boolean values. Variables are created by assigning a value to a name using the assignment operator (=). For example, `x = 5` creates a variable named "x" and assigns it the value of 5. Variables can be updated by assigning a new value to them. Python is a dynamically typed language, which means that variables can hold values of different types throughout the program execution.
+
+```python
+# Example 1: Assigning a value to a variable 
+x = 5   
+```
+  
+In this example, a variable named "x" is created and assigned the value of 5.  
+
+```python
+# Example 2: Updating the value of a variable   
+x = 5   
+x = x + 3
+```
+  
+In this example, the value of the variable "x" is updated by adding 3 to its current value. After the update, "x" will hold the value of 8.  
+  
+```python
+# Example 3: Variables with different data types
+name = "John"
+age = 25
+is_student = True
+```
+In this example, three variables are created: "name" holds a string value, "age" holds an integer value, and "is_student" holds a boolean value.  
+  
+```python
+# Example 4: In python variables can change their data type
+x = 5
+x = "Hello" 
+``` 
+  
+In this example, the variable "x" initially holds an integer value of 5, but later its value is updated to a string "Hello". Python allows variables to change their data type during program execution.  
+  
+These examples demonstrate the basic usage of variables in Python, including assigning values, updating values, and handling different data types.
+
+> Task: In a similar style to above, document the use of a data type that is not used in the example above (such as decimal numbers).
+
+## Conditionals
+
+Conditionals primarily refer to the use of the keywords `if`, `else` and `elif`. 
+
+> Task: In the style of the Variables section, program, test and document the use of these keywords, creating some simple examples
+
+## Loops
+
+Loops primarily refer to the use of the keywords `for`,and `while` in python. 
+In Python, the `for` loop is used to iterate over a sequence of elements. The `for` loop with `range` is a common way to iterate a specific number of times. Here's a brief description of `for` loops using 'for in range' syntax:  
+
+```python
+# Example 1: Basic usage of for loop with range
+for i in range(5):
+	print(i)
+```
+  
+In this example, the `for` loop iterates over the sequence of numbers generated by `range(5)`, which produces numbers from 0 to 4. The loop variable `i` takes on each value in the sequence, and the code inside the loop (indented under the `for` statement) is executed for each iteration. The output will be the numbers 0 to 4 printed on separate lines.
+
+> Task: In the style of the Variables section, program, test and document the use of the `for` keyword, creating some simple examples
+
+## Functions
+Functions are defined using the `def` keyword, followed by the function name and parentheses containing any input parameters. The function body is indented below the definition.
+```python
+# example function 1
+def print_hello():  
+	print('hello!')
+```
+```python
+# example function 2
+def square(number):  
+	result = number ** 2  
+	return result
+```
+> Task:  In the style of the Variables section, program, test and document the use of the functions, creating some simple examples using both parameters and return values.
+
+# Task 2 - Some Simple Puzzles
+
+### Puzzle 1: Print Even Numbers
+
+Write a program that prints all even numbers from 1 to 10.
+
+### Puzzle 2: Sum of Odd Numbers
+
+Write a program that calculates the sum of all odd numbers from 1 to 10
+
+### Puzzle 3: Guess the Number
+
+Write a program that asks the user to guess a number between 1 and 10. If the user guesses the correct number, print "Congratulations!", otherwise, print "Try again!".
+
+# (Optional) Task 3
+
+A Caesar cipher is a simple encryption technique that involves shifting the letters of the alphabet by a certain number of positions. It is named after Julius Caesar, who is said to have used this method to communicate secretly with his generals.  
+  
+Here's how a Caesar cipher works:  
+  
+- Choose a shift value: The shift value determines how many positions each letter should be shifted in the alphabet. For example, a shift value of 3 means that 'A' will be encrypted as 'D', 'B' as 'E', and so on.  
+  
+- Encrypting a message: To encrypt a message using a Caesar cipher, each letter in the message is shifted by the chosen shift value. Non-alphabetic characters, such as spaces or punctuation, are left unchanged. The shifted letters wrap around to the beginning of the alphabet if they go beyond 'Z'.  
+  
+- Decrypting a message: To decrypt a message encrypted with a Caesar cipher, the same shift value is used in reverse. Each letter in the encrypted message is shifted back by the chosen shift value to reveal the original message.  
+  
+Here's an example to illustrate the Caesar cipher:  
+  
+Original message: "HELLO"  
+Shift value: 3  
+  
+Encryption:  
+- 'H' shifted by 3 positions becomes 'K'  
+- 'E' shifted by 3 positions becomes 'H'  
+- 'L' shifted by 3 positions becomes 'O'  
+- 'L' shifted by 3 positions becomes 'O'  
+- 'O' shifted by 3 positions becomes 'R'  
+  
+Encrypted message: "KHOOR"  
+  
+Decryption:  
+- 'K' shifted back by 3 positions becomes 'H'  
+- 'H' shifted back by 3 positions becomes 'E'  
+- 'O' shifted back by 3 positions becomes 'L'  
+- 'O' shifted back by 3 positions becomes 'L'  
+- 'R' shifted back by 3 positions becomes 'O'  
+  
+Decrypted message: "HELLO"  
+  
+The Caesar cipher is a basic encryption technique and can be easily cracked through brute force or frequency analysis. However, it serves as a good introduction to the concept of encryption and can be a starting point for more complex encryption algorithms. If you are able to complete this exercise, you could further explore the concept of using a more advanced cypher such as Vigenère Cipher.
+
+> The Vigenère cipher is an extension of the Caesar cipher. Instead of using a single shift value, it uses a keyword to determine multiple shift values. Each letter of the keyword corresponds to a shift value, and the message is encrypted by shifting each letter by its corresponding shift value.  
+
diff --git a/practicals/week8/week8.md b/practicals/week8/week8.md
new file mode 100644
index 0000000..4ff24c8
--- /dev/null
+++ b/practicals/week8/week8.md
@@ -0,0 +1,27 @@
+# Task 1
+## Variables
+## Conditionals
+## Loops
+## Functions
+
+# Task 2
+## Puzzle 1: Print Even Numbers
+
+```python
+# After testing, paste your solution here to reference in future
+# A program that prints all even numbers from 1 to 10:
+
+```
+
+## Puzzle 2: Sum of Odd Numbers
+```python
+# A program that calculates the sum of all odd numbers from 1 to 10:
+
+```
+
+## Puzzle 3: Guess the Number
+
+```python
+# a simple guess the number game:
+
+```
diff --git a/practicals/week8/week8.py b/practicals/week8/week8.py
new file mode 100644
index 0000000..e69de29
-- 
GitLab