Skip to content

Instantly share code, notes, and snippets.

Exam 1 Covers ch 9, 10, 20, 24 with book Chemistry A Molecular Approach

I am writing this without revision (because I'm lazy), so if something needs refining, there is an error, and/or there is a better way of explaining something, please mention it in the comments.

Chapter 9

Definitions

Electronegativity:

@loriopatrick
loriopatrick / isnb10to13.py
Created January 27, 2013 08:58
A simple method to convert ISBN13 to ISBN10.
def isbn_13_to_10 (isbn):
count = 0
isbn = isbn[3:12]
for x in range(0, 9):
count += int(isbn[x]) * (10 - x)
z = (11 - (count % 11)) % 11
if (z == 10):
z = 'X'
return isbn + str(z)
@loriopatrick
loriopatrick / bruteforce.py
Last active December 11, 2015 18:19
Brute force password generator.
import string
from math import floor, ceil
CHARS = string.ascii_lowercase # + string.ascii_uppercase + string.digits
def gen_key (num, chars=CHARS):
"""
example with chars='ABC'
num | return
0 | A
@loriopatrick
loriopatrick / prime.py
Last active December 11, 2015 18:19
is_prime
def is_prime (num):
to = int(pow(num, 1/2)) + 1
for x in range (2, to):
if num % x == 0:
return False
return True
@loriopatrick
loriopatrick / Database.java
Created January 18, 2013 05:16
Something I always use when handling databases in Java. Has not been throughly tested.
import java.sql.*;
import java.util.Date;
import java.sql.Connection;
import java.util.ArrayList;
public class Database {
public Database(String server, String port, String user, String pass, boolean connect) {
this.server = server;
this.port = port;
this.user = user;