diff --git a/UST-python-exercises.txt b/UST-python-exercises.txt new file mode 100644 index 0000000..7a9da4f --- /dev/null +++ b/UST-python-exercises.txt @@ -0,0 +1,96 @@ +"Install the latest version of Python and verify the installation. + +─────────────────────────────────────────────────────────────────────────────── + +─────────────────────────────────────────────────────────────────────────────── +─────────────────────────────────────────────────────────────────────────────── + +Write a simple Python script that prints ""Hello, World!"" to the console. +─────────────────────────────────────────────────────────────────────────────── +D:\PraiseTheLord\HSBGInfotech\Others\vilas\Learn-PowerShell-Code-Examples\PowerShell\scripts +─────────────────────────────────────────────────────────────────────────────── +─────────────────────────────────────────────────────────────────────────────── + +Create a script to perform basic arithmetic operations (addition, subtraction, etc.). +─────────────────────────────────────────────────────────────────────────────── + +─────────────────────────────────────────────────────────────────────────────── +─────────────────────────────────────────────────────────────────────────────── + +Write a program that uses conditional statements to check if a number is positive or negative. +─────────────────────────────────────────────────────────────────────────────── + +─────────────────────────────────────────────────────────────────────────────── +─────────────────────────────────────────────────────────────────────────────── + +Define a function that takes a list and returns its sum. +─────────────────────────────────────────────────────────────────────────────── + +─────────────────────────────────────────────────────────────────────────────── +─────────────────────────────────────────────────────────────────────────────── + +Create a for loop that prints numbers 1 to 10. +─────────────────────────────────────────────────────────────────────────────── + +─────────────────────────────────────────────────────────────────────────────── +─────────────────────────────────────────────────────────────────────────────── + +Use Jupyter Notebooks to document a Python project with explanations. +─────────────────────────────────────────────────────────────────────────────── + +─────────────────────────────────────────────────────────────────────────────── +─────────────────────────────────────────────────────────────────────────────── + +Implement error handling using try/except blocks." +─────────────────────────────────────────────────────────────────────────────── + +─────────────────────────────────────────────────────────────────────────────── +─────────────────────────────────────────────────────────────────────────────── + +"Write a script to automate file creation and deletion in a specified directory. +─────────────────────────────────────────────────────────────────────────────── + +─────────────────────────────────────────────────────────────────────────────── +─────────────────────────────────────────────────────────────────────────────── + +Use the os module to list all files in a directory and display their sizes. +─────────────────────────────────────────────────────────────────────────────── + +─────────────────────────────────────────────────────────────────────────────── +─────────────────────────────────────────────────────────────────────────────── + +Implement a regular expression to search for email addresses in a text file. + +─────────────────────────────────────────────────────────────────────────────── + +─────────────────────────────────────────────────────────────────────────────── +─────────────────────────────────────────────────────────────────────────────── +Create a program that reads a large CSV file and processes its data. +─────────────────────────────────────────────────────────────────────────────── + +─────────────────────────────────────────────────────────────────────────────── +─────────────────────────────────────────────────────────────────────────────── + +Write a hashing script using the hashlib library to secure passwords. +─────────────────────────────────────────────────────────────────────────────── + +─────────────────────────────────────────────────────────────────────────────── +─────────────────────────────────────────────────────────────────────────────── + +Create a virtual environment, install a package, and save dependencies to requirements.txt. +─────────────────────────────────────────────────────────────────────────────── + +─────────────────────────────────────────────────────────────────────────────── +─────────────────────────────────────────────────────────────────────────────── + +Implement unit tests for a sample function using the unittest framework. +─────────────────────────────────────────────────────────────────────────────── + +─────────────────────────────────────────────────────────────────────────────── +─────────────────────────────────────────────────────────────────────────────── + +Mock a function in a unit test to simulate behavior without executing the actual code." +─────────────────────────────────────────────────────────────────────────────── + +─────────────────────────────────────────────────────────────────────────────── +─────────────────────────────────────────────────────────────────────────────── diff --git a/advanced/console/calculator.py b/advanced/console/calculator.py new file mode 100644 index 0000000..738c193 --- /dev/null +++ b/advanced/console/calculator.py @@ -0,0 +1,55 @@ +# This function adds two numbers +def add(x, y): + return x + y + +# This function subtracts two numbers +def subtract(x, y): + return x - y + +# This function multiplies two numbers +def multiply(x, y): + return x * y + +# This function divides two numbers +def divide(x, y): + return x / y + + +print("Select operation.") +print("1.Add") +print("2.Subtract") +print("3.Multiply") +print("4.Divide") + +while True: + # take input from the user + choice = input("Enter choice(1/2/3/4): ") + + # check if choice is one of the four options + if choice in ('1', '2', '3', '4'): + try: + num1 = float(input("Enter first number: ")) + num2 = float(input("Enter second number: ")) + except ValueError: + print("Invalid input. Please enter a number.") + continue + + if choice == '1': + print(num1, "+", num2, "=", add(num1, num2)) + + elif choice == '2': + print(num1, "-", num2, "=", subtract(num1, num2)) + + elif choice == '3': + print(num1, "*", num2, "=", multiply(num1, num2)) + + elif choice == '4': + print(num1, "/", num2, "=", divide(num1, num2)) + + # check if user wants another calculation + # break the while loop if answer is no + next_calculation = input("Let's do next calculation? (yes/no): ") + if next_calculation == "no": + break + else: + print("Invalid Input") \ No newline at end of file diff --git a/basics/installing-python.md b/basics/installing-python.md index 249cc4b..f9f6997 100644 --- a/basics/installing-python.md +++ b/basics/installing-python.md @@ -63,7 +63,7 @@ going to make things easier later. 1. Open a terminal. How exactly this is done depends on your operating system, but most operating systems have some way to search for programs. Search for a program called terminal and launch it. -2. Type `python3` and press Enter. You should see something like this: +2. Type `python3 / python` and press Enter. You should see something like this: ![Running Python on my terminal.](../images/terminal.png) diff --git a/flask/helloWorld/helloworld.py b/flask/helloWorld/helloworld.py new file mode 100644 index 0000000..e55a716 --- /dev/null +++ b/flask/helloWorld/helloworld.py @@ -0,0 +1,11 @@ +from flask import Flask + +app = Flask(__name__) #creating the Flask class object + +@app.route('/') #define the default route +def home(): + return "hello world!!"; + +if __name__ =='__main__': + app.run(debug = True) +#try hitting http://localhost:5000 \ No newline at end of file diff --git a/flask/requestResponse/reqres.py b/flask/requestResponse/reqres.py new file mode 100644 index 0000000..180b16e --- /dev/null +++ b/flask/requestResponse/reqres.py @@ -0,0 +1,23 @@ +from flask import Flask, request, jsonify, render_template + +# create the flask app +app = Flask(__name__) + +# what html should be loaded as the home page when the app loads? +@app.route('/') +def home(): + return render_template('app_frontend.html', prediction_text="test") + + +# define the logic for reading the inputs from the WEB PAGE, +# running the model, and displaying the prediction +@app.route('/predict', methods=['GET','POST']) +def predict(): + + # get the description submitted on the web page + a_description = request.form.get('description') + return render_template('app_frontend.html', prediction_text=a_description) + +# boilerplate flask app code +if __name__ == "__main__": + app.run(debug=True) \ No newline at end of file diff --git a/flask/requestResponse/templates/app_frontend.html b/flask/requestResponse/templates/app_frontend.html new file mode 100644 index 0000000..16bf14d --- /dev/null +++ b/flask/requestResponse/templates/app_frontend.html @@ -0,0 +1,21 @@ + + + + + + + +

Predict Code

+ +
+ + + + +
+
+
+ Prediction: {{ prediction_text }} + + + \ No newline at end of file diff --git a/installation/Readme.txt b/installation/Readme.txt new file mode 100644 index 0000000..8e8a1ca --- /dev/null +++ b/installation/Readme.txt @@ -0,0 +1,17 @@ +python+pip installation + + https://www.python.org/downloads/windows/ + https://www.digitalocean.com/community/tutorials/install-python-windows-10 + + +create command prompt in admin mode + pip install flask + + mkdir flask + cd flask + + python + + import flask + (no output) - installation successful. + diff --git a/learncopilot.py b/learncopilot.py new file mode 100644 index 0000000..cd8b527 --- /dev/null +++ b/learncopilot.py @@ -0,0 +1,26 @@ +#write me a code to calculate fibonnacci series using recursion + +def fibonacci(n): + if n <= 1: + return n + else: + return fibonacci(n-1) + fibonacci(n-2) + +n = int(input("Enter the number of terms: ")) +if n <= 0: + print("Please enter a positive integer") +else: + print("Fibonacci sequence:") + for i in range(n): + print(fibonacci(i)) + +#Output +#Enter the number of terms: 10 +#Fibonacci sequence: + + +#write documentation and comments for this +#code +#The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding ones, usually starting with 0 and 1. +#The Fibonacci sequence is defined by the recurrence relation: + diff --git a/linkcheck.py b/linkcheck.py old mode 100755 new mode 100644 diff --git a/make-html.py b/make-html.py old mode 100755 new mode 100644 diff --git a/update-ends.py b/update-ends.py old mode 100755 new mode 100644 diff --git a/update-readmes.py b/update-readmes.py old mode 100755 new mode 100644 diff --git a/ust-python-exercises/001_python.py b/ust-python-exercises/001_python.py new file mode 100644 index 0000000..4648e70 --- /dev/null +++ b/ust-python-exercises/001_python.py @@ -0,0 +1 @@ +print("Hello, World!") \ No newline at end of file diff --git a/ust-python-exercises/002_Calculator.py b/ust-python-exercises/002_Calculator.py new file mode 100644 index 0000000..7a9da4f --- /dev/null +++ b/ust-python-exercises/002_Calculator.py @@ -0,0 +1,96 @@ +"Install the latest version of Python and verify the installation. + +─────────────────────────────────────────────────────────────────────────────── + +─────────────────────────────────────────────────────────────────────────────── +─────────────────────────────────────────────────────────────────────────────── + +Write a simple Python script that prints ""Hello, World!"" to the console. +─────────────────────────────────────────────────────────────────────────────── +D:\PraiseTheLord\HSBGInfotech\Others\vilas\Learn-PowerShell-Code-Examples\PowerShell\scripts +─────────────────────────────────────────────────────────────────────────────── +─────────────────────────────────────────────────────────────────────────────── + +Create a script to perform basic arithmetic operations (addition, subtraction, etc.). +─────────────────────────────────────────────────────────────────────────────── + +─────────────────────────────────────────────────────────────────────────────── +─────────────────────────────────────────────────────────────────────────────── + +Write a program that uses conditional statements to check if a number is positive or negative. +─────────────────────────────────────────────────────────────────────────────── + +─────────────────────────────────────────────────────────────────────────────── +─────────────────────────────────────────────────────────────────────────────── + +Define a function that takes a list and returns its sum. +─────────────────────────────────────────────────────────────────────────────── + +─────────────────────────────────────────────────────────────────────────────── +─────────────────────────────────────────────────────────────────────────────── + +Create a for loop that prints numbers 1 to 10. +─────────────────────────────────────────────────────────────────────────────── + +─────────────────────────────────────────────────────────────────────────────── +─────────────────────────────────────────────────────────────────────────────── + +Use Jupyter Notebooks to document a Python project with explanations. +─────────────────────────────────────────────────────────────────────────────── + +─────────────────────────────────────────────────────────────────────────────── +─────────────────────────────────────────────────────────────────────────────── + +Implement error handling using try/except blocks." +─────────────────────────────────────────────────────────────────────────────── + +─────────────────────────────────────────────────────────────────────────────── +─────────────────────────────────────────────────────────────────────────────── + +"Write a script to automate file creation and deletion in a specified directory. +─────────────────────────────────────────────────────────────────────────────── + +─────────────────────────────────────────────────────────────────────────────── +─────────────────────────────────────────────────────────────────────────────── + +Use the os module to list all files in a directory and display their sizes. +─────────────────────────────────────────────────────────────────────────────── + +─────────────────────────────────────────────────────────────────────────────── +─────────────────────────────────────────────────────────────────────────────── + +Implement a regular expression to search for email addresses in a text file. + +─────────────────────────────────────────────────────────────────────────────── + +─────────────────────────────────────────────────────────────────────────────── +─────────────────────────────────────────────────────────────────────────────── +Create a program that reads a large CSV file and processes its data. +─────────────────────────────────────────────────────────────────────────────── + +─────────────────────────────────────────────────────────────────────────────── +─────────────────────────────────────────────────────────────────────────────── + +Write a hashing script using the hashlib library to secure passwords. +─────────────────────────────────────────────────────────────────────────────── + +─────────────────────────────────────────────────────────────────────────────── +─────────────────────────────────────────────────────────────────────────────── + +Create a virtual environment, install a package, and save dependencies to requirements.txt. +─────────────────────────────────────────────────────────────────────────────── + +─────────────────────────────────────────────────────────────────────────────── +─────────────────────────────────────────────────────────────────────────────── + +Implement unit tests for a sample function using the unittest framework. +─────────────────────────────────────────────────────────────────────────────── + +─────────────────────────────────────────────────────────────────────────────── +─────────────────────────────────────────────────────────────────────────────── + +Mock a function in a unit test to simulate behavior without executing the actual code." +─────────────────────────────────────────────────────────────────────────────── + +─────────────────────────────────────────────────────────────────────────────── +───────────────────────────────────────────────────────────────────────────────