This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import numpy as np | |
img1 = cv2.imread('NewCuyama.jpg') | |
img = cv2.cvtColor(img1, cv2.COLOR_BGR2GRAY) | |
# img is now a numpy array. | |
# Find the mean of all non-zero pixels. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script> | |
<script> | |
'use strict'; | |
var x = "0"; | |
var y = "1"; | |
var answer = parseInt(x); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tkinter as tk | |
class Calculator: | |
def __init__(self, master): | |
self.master = master | |
master.title("Calculator") | |
# Create display | |
self.display = tk.Entry(master, width=35, borderwidth=5, font=('Arial', 16)) | |
self.display.grid(row=0, column=0, columnspan=4, padx=10, pady=10) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
def display_board(board): | |
print(board[0] + "|" + board[1] + "|" + board[2]) | |
print("------") | |
print(board[3] + "|" + board[4] + "|" + board[5]) | |
print("------") | |
print(board[6] + "|" + board[7] + "|" + board[8]) | |
def player_input(first_move): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lines = """\ | |
ABCDE12345_001,FGHIJ6789_002,ABCDE12345_001 | |
KLMNO5432_003,KLMNO5432_003,FGHIJ6789_002 | |
PQRST24680_123,UVWXY13579_555,UVWXY13579_555 | |
ZABCD876530_009,ZABCD876530_009,AABBCCDDEE_987 | |
AABBCCDDEE_987,AABBCCDDEE_987,LMNOP98765_999 | |
LMNOP98765_999,ZYXWV54321_777,ZYXWV54321_777""".splitlines() | |
record = [] | |
for row in lines: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from datetime import datetime | |
# Define the component prices for each day | |
prices = { | |
datetime(2020, 1, 31): [197.2525, 253.2126, 653.266, 653.2678], | |
datetime(2020, 2, 3): [197.063, 253.2231, 652.3695, 652.3759], | |
datetime(2020, 2, 4): [196.6896, 252.9168, 649.9793, 649.9858], | |
datetime(2020, 2, 5): [197.3429, 252.8294, 653.5655, 653.5588], | |
datetime(2020, 2, 6): [197.4554, 252.7901, 652.3171, 652.3172], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def physics(data): | |
block = [[int(i) for i in row.split(',')] for row in data.split(';')] | |
width = len(block[0]) | |
height = len(block) | |
water = block[0].index(1) | |
for row in range(1,height): | |
for possible in (-1,0,1): | |
if water+possible in range(width) and block[row][water+possible]: | |
water += possible |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This does what you are trying to do, but with all the extraneous code eliminated. | |
Notice that strings are iterables, just like lists. Any time you are making a list | |
of single characters, you should probably use a string. Also notice that we write | |
`'xxx'.upper()`, not `str.upper('xxx')`. Also note that it is silly to write ` | |
if result='N': pass`. Just test for what you want to know. | |
""" | |
import random | |
lower_case_letters = 'abcdefghijklmnopqrstuvwxyz' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import struct | |
# Return a RIFF file | |
class LIST: | |
def __init__(self, name, f): | |
# contains a type and a list of subchunks. | |
self.offset = f.tell() - 4 | |
self.name = name.decode() | |
size = struct.unpack('I', f.read(4))[0] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# OK, I ran the following Python to create the database: | |
import sqlite3 | |
import random | |
import os | |
os.remove( 'test.db' ) | |
db = sqlite3.connect( "test.db" ) | |
cursor = db.cursor() | |
cursor.execute( """\ |
NewerOlder