Tags » Python

First website project for FreeCodeCamp & Python.

I finished the website that I made for the first assignment on FCC, I still need to have it tested to see if it passes but I am pretty sure I hit all the points that it wanted  me to include. 227 more words

#List[ ] in Python

Characteristics:

#Sequential, ordered, mutable(can update/change).
# [ ], values/item, represented comma separated
#del
#extend
#insert
#remove
#sort
#reverse
#append
#copy
#count
#pop
#index
#min
#max… 31 more words

Python - Performance Tuning with Nvidia

Step 1:
Read this first
https://weeraman.com/put-that-gpu-to-good-use-with-python-e5a437168c01

Step 2: Install NVidia in Mac
https://docs.nvidia.com/cuda/cuda-installation-guide-mac-os-x/index.html

>brew tap caskroom/drivers
>brew cask install nvidia-cuda

Then you also need to add the following to your file ~/.bash_profile: 185 more words

Python

Port Scanner

Another simple port scanner written in Python, for testing. Implements threading.

#!/usr/bin/python
import threading
import socket

target = '192.168.1.104'
target = 'pythonprogramming.net'
#ip = socket.gethostbyname(target)

def portscan(port):
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.settimeout(0.5)# 

    try:
        con = s.connect((target,port))
        print('Port :',port,"is open.")
        con.close()
    except: 
        pass
r = 1 
for x in range(1,100): 
    t = threading.Thread(target=portscan,kwargs={'port':r}) 
    r += 1     
    t.start() 

$ ./a.py 
('Port :', 22, 'is open.')
('Port :', 80, 'is open.')
Python

Pattern Matching

Test pattern matching using Python

#!/usr/bin/python
import re

filepath = 'data.txt' 
prog = re.compile('+(?:\.+){3}:+')

with open(filepath) as fp: 
  line = fp.readline()
  cnt = 1
  while line:
    print("Line {}: {}".format(cnt, line.strip()))
    line = fp.readline()
    if prog.match(line):
      print 'matched'
    else:
      print 'not matched'
    cnt += 1

$ cat data.txt
192.168.1.1:20
192.168.1.1:20-30

$ ./b.py
Line 1: 192.168.1.1:20
matched
Line 2: 192.168.1.1:20-30
not matched
Python

Automation: Pythonista, Reports, and Graphs

I had a bit of free time this evening and tried my hand at reporting on iOS using Pythonista. I had heard from various blog posts about the idea of using a Python script to massage and process data in a way that would be easier than the lower-code options of… 451 more words

Technology

Data Analysis & Interpretation 2.2

Week 2

Run a Chi-Square Test of Independence. The null hypothesis is that the relative proportions of one variable are independent of the second variable; in other words, the proportions of one variable are the same for different values of the second variable. 305 more words

Data Analytics