|
4 | 4 | > Lecturer: Dr Ian McLoughlin
|
5 | 5 | > [Original Problem Sheet](https://github.com/emerging-technologies/emerging-technologies.github.io/blob/master/problems/python-fundamentals.md)
|
6 | 6 |
|
7 | | -*Need to add some error handling.* |
8 | | - |
9 | 7 | ## Goals
|
10 | 8 |
|
11 | 9 | The aim of these problems is to give you a good knowledge of basic Python. The problems are good for either learning Python from scratch or refreshing your memory of the language. They cover a variety of variable types, calculations, loops, user input, and in-built functions, among other things.
|
12 | 10 |
|
| 11 | +### Getting Set Up |
| 12 | +I'm using Python 3.6 (download [here](https://www.python.org/downloads/)),which is slightly different to Python 2.7. For example, Python 2.7 doesn't require parentheses in `print` statements, whereas 3.6 does - keep this in mind when running these programs. [Anaconda](https://www.anaconda.com/download/) is great for managing packages and libraries used in Python, so I'd recommend downloading that. |
| 13 | +Once you have Python set up, open command line and `cd` to wherever you want to save the repository, type `git clone https://github.com/rebeccabernie/PythonFundamentals.git` and finally, `cd PythonFundamentals`. To run any program, type `python programname.py`. |
| 14 | +*If you're getting errors when trying to run a program, you may need to [add python to your path variable](https://docs.python.org/3.3/using/windows.html#configuring-python).* |
| 15 | + |
13 | 16 | ## Exercises
|
14 | 17 |
|
15 | 18 | **1. Hello World**
|
@@ -70,7 +73,7 @@ The user enters a word (or sentence), and the program tests whether the string i
|
70 | 73 | The user enters two lists containing three numbers each. The program merges the two lists into one, and sorts the new list from lowest to highest.
|
71 | 74 |
|
72 | 75 | **9. Newton's Square Root Method**
|
73 | | -The user enters a number and their guess for the square root of that number. The program uses Newton's method to calculate the square root using the user's guess (z), the original number(x), and the new approximate(the equation result from the last iteration of the loop): |
| 76 | +The user enters a number and their guess for the square root of that number. The user can't enter any negative number for x () The program uses Newton's method to calculate the square root using the user's guess (z), the original number(x), and the new approximate(the equation result from the last iteration of the loop): |
74 | 77 |
|
75 | 78 | ```
|
76 | 79 | newApproximate = z - ((z* - x) / (2 * z))
|
|
0 commit comments