Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Style Guide for Python Code


Sample Python Projects



Basic Python projects

https://morioh.com/p/f7286d9ee563?f=5c224490c513a556c9042463&fbclid=IwAR2wHrK-pi5FQ2-zH9fWgdHbu63UIa5yU0TBCwV59D4HM1HHFRG2Hd7j0so

...

Code Block
languagepy
titlePython and MySQL
collapsetrue
import mysql.connector

#connecting to a database
con = mysql.connector.connect(
    host = "husseinmac",
    user = "root",
    password = "password",
    database = "husseindb",
    port = 3306
)

print("Hey, I think I'm connected")

#cursor 
cur = con.cursor()
#insert a new row

for i in range(100):
    cur.execute("INSERT INTO employees (ID, NAME) VALUES (%s, %s)", (i+10, f'Mark{i}' ))

#execute the query
cur.execute("SELECT ID,NAME FROM employees")

#cur.execute("SELECT ID,NAME FROM employees where NAME = %s", ("Yara",))

rows = cur.fetchall()

for r in rows:
    print(f" ID = {r[0]} NAME = {r[1]}")

#commit the transaction
con.commit()

#close the cursor
cur.close()
#close the connection
con.close()



Simplest Neural Network in Python - Perceptron

https://morioh.com/p/512d41219fda?f=5c21fb01c16e2556b555ab32&fbclid=IwAR34w7O9dK5RtqoTryI9QI5op7UUfNXNHJ6wMz7Uenr83DdfgXbdz0Ng3Pg

In this video I'll show you how an artificial neural network works, and how to make one yourself in Python. In the next video we'll make one that is usable, but if you want, that code can already be found on github. I recommend watching at 1.5x speed, unless you're coding along.

video

Widget Connector
urlhttp://youtube.com/watch?v=kft1AJ9WVDk

video 2 

Widget Connector
urlhttp://youtube.com/watch?v=Py4xvZx-A1E


https://morioh.com/p/512d41219fda

Create a Simple Neural Network in Python from ScratchImage Added

Github code

https://github.com/jonasbostoen/simple-neural-network

reating a simple neural network in Python with one input layer (3 inputs) and one output neuron. A neural network with no hidden layers is called a perceptron. In the training_version.py I train the neural network in the clearest way possible, but it's not really useable. The outputs of the training can be found in outputs.txt . neural_network.py is an object and can be used by giving in different inputs.

Thanks to Milo Spencer-Harber for this: https://medium.com/technology-invention-and-more/how-to-build-a-simple-neural-network-in-9-lines-of-python-code-cc8f23647ca1

And to Andrew Trask for this: https://iamtrask.github.io/2015/07/12/basic-python-network/

What does it do?

The neural_net.py tries to predict the output given 3 binary inputs. If the first input is 1, the output should be one. Otherwise the output should be 0.


Code Block
languagepy
titlesimple neural network - perceptron
collapsetrue



Potential Value Opportunities

...