From dc1b2df9221e53f89e9bf75d166299afa80e669f Mon Sep 17 00:00:00 2001
From: cprutean <cip.pruteanu@ed.ac.uk>
Date: Wed, 23 Aug 2023 19:51:24 +0100
Subject: [PATCH] Upload New File

---
 CodeExamples/WhileLooptoList.ipynb | 70 ++++++++++++++++++++++++++++++
 1 file changed, 70 insertions(+)
 create mode 100644 CodeExamples/WhileLooptoList.ipynb

diff --git a/CodeExamples/WhileLooptoList.ipynb b/CodeExamples/WhileLooptoList.ipynb
new file mode 100644
index 0000000..e295a2b
--- /dev/null
+++ b/CodeExamples/WhileLooptoList.ipynb
@@ -0,0 +1,70 @@
+{
+ "cells": [
+  {
+   "cell_type": "markdown",
+   "id": "15c99cef",
+   "metadata": {},
+   "source": [
+    "# While Loop to List"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "id": "a90d92d5",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "\"\"\"\n",
+    "   Example to demonstrate a while loop to write theta and cos theta\n",
+    "   to a list\n",
+    "\"\"\"\n",
+    "\n",
+    "import math\n",
+    "\n",
+    "def main():\n",
+    "    n_point = 50\n",
+    "    delta_theta = 2.0*math.pi/n_point # theta increment\n",
+    "    theta = 0.0                   # theta start\n",
+    "    theta_data = []               # empty list \n",
+    "    cos_data = []                 # empty list\n",
+    "\n",
+    "\n",
+    "    while theta < 2.0*math.pi:              # while loop\n",
+    "        cos = math.cos(theta)\n",
+    "        theta_data.append(theta)            # Add values to list\n",
+    "        cos_data.append(cos)\n",
+    "        theta += delta_theta                # increment theta\n",
+    "\n",
+    "    #         Do a default print (not very tidy output, replace this and \n",
+    "    #         a loop and make it nicer)\n",
+    "    print(str(theta_data))\n",
+    "    print(str(cos_data))\n",
+    "\n",
+    "\n",
+    "main()"
+   ]
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python 3 (ipykernel)",
+   "language": "python",
+   "name": "python3"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 3
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython3",
+   "version": "3.9.7"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}
-- 
GitLab