This file contains 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 java.util.*; | |
class Main { | |
public static void main(String[] args) { | |
Scanner scanner = new Scanner(System.in); | |
System.out.println("Enter a number"); | |
int n = scanner.nextInt(); // read an integer from input stream. | |
System. out. println(n); // print n. | |
System.out.println("Hello world!"); | |
} | |
} |
This file contains 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
<html> | |
<head> | |
</head> | |
<body> | |
<p>Temp: <br /> | |
<input type="text" id="tempInput" /><br /> | |
<input id="radioCT" type="radio" name="conversionType" value="CToF" checked>Celsius to Fahrenheit</input><br /> | |
<input id="radioCT" type="radio" name="conversionType" value="FToC">Fahrenheit to Celsius</input><br /> | |
<button onclick="convertTemp()">Convert</button> | |
</p> |
This file contains 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
function myFunction() { | |
// Usercan copy the current file with a new name. | |
var ui = DocumentApp.getUi(); | |
var newFileName = ""; | |
while (newFileName != "Q"){ | |
if (newFileName != "Q") | |
{ | |
Logger.log('File name is not Q'); | |
}else | |
{ |
This file contains 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
#variables | |
var1 = 1 | |
var2 = 2 | |
#a method | |
def my_method(): | |
global var2 | |
var1 = 2 | |
print('Method var1',var1,'var2:',var2) |
This file contains 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
"""J3 Hidden Palindrome | |
http://cemc.math.uwaterloo.ca/contests/computing/2016/stage%201/juniorEn.pdf | |
This strategy loops from the longest possible palindrome to the shortest""" | |
word=input() | |
#0-3 | |
#1-2 | |
foundpalindrome = True #sentinal value | |
keeplooping = True#Stop when palindrom found | |
#start with the longest possible, work in | |
for i in range(len(word),1,-1): |
This file contains 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 urllib.request #part of the standard library | |
#provide the url to open | |
u = urllib.request.urlopen('https://docs.python.org/3/_static/py.png') | |
#write the image data to a file | |
with open('p.png','wb') as f: | |
f.write(u.read()) |
This file contains 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 | |
import cv2 | |
# Create a black image | |
#img = np.zeros((512,512,3), np.uint8) | |
img = cv2.imread('images/test_image.png') | |
# Write some Text | |
font = cv2.FONT_HERSHEY_SIMPLEX | |
cv2.putText(img,'Hello World!',(10,200), font, 1,(255,255,255),2) |
This file contains 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 | |
#note the libraries that need importing | |
# Camera 0 is the integrated web cam on my netbook | |
camera_port = 0 | |
#Number of frames to throw away while the camera adjusts to light levels | |
ramp_frames = 30 |
This file contains 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, os.path | |
import pygame | |
from pygame.locals import * | |
SCREENRECT = Rect(0, 0, 370, 720) | |
class Ball: | |
def __init__(self): | |
self.location = (50,50,50,50) | |
self.y = 50 | |
def update(self): |
This file contains 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
#!/usr/bin/env python | |
import random, os.path | |
#import basic pygame modules | |
import pygame | |
from pygame.locals import * | |
SCREENRECT = Rect(0, 0, 640, 480) | |
GAME_ON = True |
NewerOlder