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 FirstReverse(str): | |
array = list(str) | |
length = len(array) - 1 | |
reverse = [] | |
while length > 0: | |
for char in array: | |
reverse.append(array[length]) | |
length -= 1 | |
value = ''.join(reverse) | |
return value |
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 pygame | |
import random | |
screen = pygame.display.set_mode([1024, 768]) | |
height = pygame.display.Info().current_h | |
width = pygame.display.Info().current_w | |
pygame.display.set_caption('Window Caption') | |
clock = pygame.time.Clock() | |
#create the locations of the stars for when we animate the background |
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 pygame | |
screen = pygame.display.set_mode([1024, 768]) | |
height = pygame.display.Info().current_h | |
width = pygame.display.Info().current_w | |
pygame.display.set_caption('Window Caption') | |
clock = pygame.time.Clock() | |
#define some commonly used colours | |
WHITE = (255, 255, 255) |
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 string | |
def is_prime(n): | |
n = abs(int(n)) | |
if n < 2: | |
return False | |
if n == 2: | |
return True | |
if not n & 1: | |
return False |
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 is not my code! | |
// | |
// Stolen from http://docs.oracle.com/javase/tutorial/java/nutsandbolts/switch.html | |
// for purposes of teaching myself java. As per their license, the following must be included: | |
// | |
// Copyright (c) 2013, Oracle America, Inc. | |
// All rights reserved. | |
// | |
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
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
from random import randint | |
while True: | |
string = str(raw_input("Dice: ")) #how about "3d6", for example | |
split = string.split("d") #create a list containing 3 and 6 | |
modifier = None | |
while modifier is None: | |
modifier = int(raw_input("Modifier: ")) | |
if modifier is "": | |
modifier = 0 |