Skip to content

Commit ef93859

Browse files
committed
my changes
1 parent 7069807 commit ef93859

File tree

5 files changed

+126
-0
lines changed

5 files changed

+126
-0
lines changed

advanced/console/calculator.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# This function adds two numbers
2+
def add(x, y):
3+
return x + y
4+
5+
# This function subtracts two numbers
6+
def subtract(x, y):
7+
return x - y
8+
9+
# This function multiplies two numbers
10+
def multiply(x, y):
11+
return x * y
12+
13+
# This function divides two numbers
14+
def divide(x, y):
15+
return x / y
16+
17+
18+
print("Select operation.")
19+
print("1.Add")
20+
print("2.Subtract")
21+
print("3.Multiply")
22+
print("4.Divide")
23+
24+
while True:
25+
# take input from the user
26+
choice = input("Enter choice(1/2/3/4): ")
27+
28+
# check if choice is one of the four options
29+
if choice in ('1', '2', '3', '4'):
30+
try:
31+
num1 = float(input("Enter first number: "))
32+
num2 = float(input("Enter second number: "))
33+
except ValueError:
34+
print("Invalid input. Please enter a number.")
35+
continue
36+
37+
if choice == '1':
38+
print(num1, "+", num2, "=", add(num1, num2))
39+
40+
elif choice == '2':
41+
print(num1, "-", num2, "=", subtract(num1, num2))
42+
43+
elif choice == '3':
44+
print(num1, "*", num2, "=", multiply(num1, num2))
45+
46+
elif choice == '4':
47+
print(num1, "/", num2, "=", divide(num1, num2))
48+
49+
# check if user wants another calculation
50+
# break the while loop if answer is no
51+
next_calculation = input("Let's do next calculation? (yes/no): ")
52+
if next_calculation == "no":
53+
break
54+
else:
55+
print("Invalid Input")

flask/helloWorld/helloworld.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from flask import Flask
2+
3+
app = Flask(__name__) #creating the Flask class object
4+
5+
@app.route('/') #define the default route
6+
def home():
7+
return "hello world!!";
8+
9+
if __name__ =='__main__':
10+
app.run(debug = True)
11+
#try hitting http://localhost:5000

flask/requestResponse/reqres.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from flask import Flask, request, jsonify, render_template
2+
3+
# create the flask app
4+
app = Flask(__name__)
5+
6+
# what html should be loaded as the home page when the app loads?
7+
@app.route('/')
8+
def home():
9+
return render_template('app_frontend.html', prediction_text="")
10+
11+
# define the logic for reading the inputs from the WEB PAGE,
12+
# running the model, and displaying the prediction
13+
@app.route('/predict', methods=['GET','POST'])
14+
def predict():
15+
16+
# get the description submitted on the web page
17+
a_description = request.form.get('description')
18+
return render_template('app_frontend.html', prediction_text=a_description)
19+
20+
# boilerplate flask app code
21+
if __name__ == "__main__":
22+
app.run(debug=True)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
5+
<link rel="stylesheet" href="{{ url_for('static', filename='asset_code.css') }}">
6+
</head>
7+
<body>
8+
<h1>Predict Code</h1>
9+
10+
<form action="/predict" method="POST">
11+
<label form="description">Description:</label>
12+
<input type="text" id="description" name="description">
13+
<button type="submit" class=cv_btn>Predict Code</button>
14+
15+
</form>
16+
<br>
17+
<br>
18+
Prediction: {{ prediction_text }}
19+
20+
</body>
21+
</html>

installation/Readme.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
python+pip installation
2+
3+
https://www.python.org/downloads/windows/
4+
https://www.digitalocean.com/community/tutorials/install-python-windows-10
5+
6+
7+
create command prompt in admin mode
8+
pip install flask
9+
10+
mkdir flask
11+
cd flask
12+
13+
python
14+
15+
import flask
16+
(no output) - installation successful.
17+

0 commit comments

Comments
 (0)