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
# Hedgehog Dodge Game | |
# Game where the user moves the hedgehog left or right to dodge falling blocks | |
# Blocks fall quicker as the game progresses | |
import pygame, sys, os, time, random | |
from pygame.locals import * | |
pygame.init() # initialise pygame | |
FPS = 30 # set frames per second | |
fpsClock = pygame.time.Clock() # set fpsClock |
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
# Have the function LetterChanges(str) take the str parameter being passed | |
# and modify it using the following algorithm. | |
# Replace every letter in the string with the letter following it in the alphabet | |
# (ie. c becomes d, z becomes a). | |
# Then capitalize every vowel in this new string (a, e, i, o, u) and | |
# finally return this modified string. | |
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
# Have the function FirstReverse(str) take the str parameter being passed and return the string in reversed order. | |
# For example: "Hello World and Coders" should return the string "sredoC dna dlroW olleH". | |
def FirstReverse(str): | |
str = str[::-1] | |
return str | |
print FirstReverse(raw_input()) |
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
# Have the function FirstFactorial(num) take the num parameter being passed and return the factorial of it. | |
# E.g. if num = 4, return (4 * 3 * 2 * 1) = 10. | |
# For the test cases, the range will be between 1 and 18 and the input will always be an integer. | |
def FirstFactorial(num): | |
# Set var sum to be 1 | |
sum = 1 | |
# For x in the range 2 to num+1, let sum be equal to sum multiplied by x ------- range(start, stop, step) |
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
# Have the function LongestWord(sen) take the sen parameter being passed and return the largest word in the string. | |
# If there are two or more words that are the same length, return the first word from the string with that length. | |
# Ignore punctuation and assume sen will not be empty. | |
def LongestWord(sen): | |
import re | |
length_greatest = 0 | |
# Convert string to lowercase | |
sen = sen.lower() | |
# Only keep alphabet + numbers + white space |
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
# Hangman game | |
# import packages | |
import random | |
import os | |
# define function to replace "?" with letters guessed | |
def progress(word, question_marks, letter): | |
progress = "" | |
for i in range(0,len(word)): |
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
# create a board | |
board = [" " for i in range(9)] | |
# print instructions | |
print("Hello, welcome to Tic Tac Toe!") | |
print() | |
print("To play, just input the number of the space you wish to have...") | |
row1 = "| 1 | 2 | 3 |" |
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
# Multiple choice quiz sample code | |
# Complete the lists detailed below | |
# question_titles, questions_asked, poss_answers, answers_ page ref. | |
# Import random package and sys | |
import random | |
# Print welcome | |
print("Hello, welcome to the [Quiz Name Here]." | |
"\nBefore we start, let me ask a few questions...") |
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
# Program where the user has to guess the number in the given number of lives. | |
# User inputs the difficulty which determines the range the number is generated from. | |
# User also inputs the number of guesses they feel they need. | |
# import random package | |
import random | |
# Print welcome to the game | |
print("Hello, welcome to the number guessing game.") |
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
# Create pig latin based on string inputted | |
# Get sentence from user | |
sentence = input("Please type in a sentence to be converted into pig-latin: ").strip().lower() | |
# Split sentence into sentence | |
sentence = sentence.split() | |
# Loop through sentence and convert to pig-latin | |
new_sentence = [] |