6) GitHub Link included for the further code review
Topic Nr. 1
1) How to Limit Input Range between -100 and 100
2) We used while loop in Python to ensure that if the given number is less than -100 then we raise an error, if the number is above 100 we also raise an error, we have done that by conducting a loop and letting the user know that the number must be no greater than 100 and no less than -100.
3) The following images of the Code before its run:
4) Images of Code after its run (output):
5) Explanation:
The first image you can see how the input numbers are in the range between -100 and 100, therefore no error is raised.
Whereas the error is raised in the second image because the numbers are greater than 100, and therefore an error is raised.
1) Using def function to perform basic math calculations
2) Developed first and second input for numbers, and declared sum, must, time and diff variables, to return a value, meaning calculating and finding the sum of those two numbers.
3) The following images of the Code before its run:
4) Images of Code after its run (output):
5) Explanation:
In the code every math calculation is defined by a variable, and when that variable is printed, it calculates for those two numbers, printing the result shown in the second image.
1) What are Exceptions in Python? Dealing with Errors.
2) Developed few exceptions when certain errors like ValueError, NameError are raised. Printed a message during an exception.
3) The following images of the Code before its run:
4) Images of Code after its run (output):
5) Explanation:
Firstly there is no error and the numbers is printed successfully. Second image shows how Zero number is not allowed and it raised an error. And the third image shows how x is not a value, and it raised also an error, this time a Value error.
1) What are Data Structures in Python? Such as Tuples,Dictionaries,Lists,Sets.
2) Developed Sets of numbers, Dictionaries representing a variable with values. Sets represented with different type of brackets.
3) The following images of the Code before its run:
4) Images of Code after its run (output):
5) Explanation:
Firstly we have dictionary represented with curly brackets. And keys and values. Keys serves as a variable, and value, as an answer for that variable. Then we have Tuples represented by circle brackets, normal brackets. Whereas the list is represented with square brackets. You can see in all images how sorting method can organize our data inside the square brackets, and that is usually the list that needs to be orgnized in order.