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
#write a program that can encrypt texts with an alphabetical caesar cipher. | |
#This cipher can ignore numbers, symbols, and whitespace. | |
x = 0 | |
scramb = "" | |
final = "" | |
characterloc = 0 | |
cleanword = raw_input("please input your secret message: ") | |
cleanword = str.upper(cleanword) | |
clean_array = list() | |
cipher = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ ") |
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
#Your challenge for today is to create a program which is password protected, and wont open unless the correct user and password is given. | |
#For extra credit, have the user and password in a seperate .txt file. | |
#for even more extra credit, break into your own program :) | |
userChoice = 0 | |
valUser = '' | |
valPass = '' | |
progQuest = 0 | |
loop = True | |
userList = {'admin':'password'} | |
while loop: |
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
#You're challenge for today is to create a program that can | |
#calculate pi accurately to at least 30 decimal places. | |
import math | |
#or import math * | |
jelly = math.pi | |
#if the second method was used I would write: | |
#jelly = pi | |
print jelly |
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
#Write a program that can translate Morse code in the format of ...---... | |
#A space and a slash will be placed between words. ..- / --.- | |
alphaBeta = { | |
'.-' : 'a', | |
'-...' : 'b', | |
'-.-.' : 'c', | |
'-..' : 'd', | |
'.' : 'e', | |
'..-.' : 'f', |
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
#write a program that will print the lyrics to | |
#"99 bottles of beer on the wall". | |
#for extra credit, do not allow the program to | |
#print each loop on a new line | |
n = 99 | |
x = 0 | |
for x in range(0, 99): | |
if n == 1: | |
print "%d bottle of beer on the wall, %d bottle of beer." % (n, n) | |
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
#write a program that will allow the user to input digits, and arrange | |
#them in numerical order. | |
#for extra credit, have it also arrange strings in alphabetical order | |
sortList = [] | |
print "Please enter the amount of items you would like to sort:" | |
times = raw_input('1 - 20)> ') | |
if 1 <= times <= 20: | |
for x in range(1, times + 1): | |
sortItem = raw_input("please enter item #%d: " % x) | |
sortList.append(sortItem) |
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
#The exercise today asks you to validate a telephone number, as if written on an input form. Telephone numbers can be written as ten digits, or with dashes, spaces, or dots between the three segments, or with the area code parenthesized; both the area code and any white space between segments are optional. | |
#Thus, all of the following are valid telephone numbers: 1234567890, 123-456-7890, 123.456.7890, (123)456-7890, (123) 456-7890 (note the white space following the area code), and 456-7890. | |
#The following are not valid telephone numbers: 123-45-6789, 123:4567890, and 123/456-7890. | |
import re | |
phoneNum = raw_input("Please enter a phone number: ") | |
matchObj = re.match( r'^([1]?)([\(\/\. ]?)[2-9][\d]{2}([\.\- \)]?)[2-9][\d][\d][/\.\- ]?[\d]{4}$', phoneNum) | |
if matchObj: | |
print "Great! you gave me a good phone number: %s" % phoneNum | |
else: | |
print "You should try again that phone number sucked!" |
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 datetime | |
Days = ['Monday', 'Tuesday', 'Wedneday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] | |
loop = True | |
print "Welcome to the magical emporium of fun!" | |
print "Give me your birth date, and I will tell you what day of the week you were born on." | |
while loop: | |
year = input('Enter your birth year (YYYY): ') | |
month = input('Enter your birth month (MM): ') |
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
#find the number of the year for the given date. For example, January 1st | |
#would be 1, and december 31st is 365 | |
import datetime | |
loop = True | |
print "We are going to figure out what day number you chose based on the date you input." | |
while loop: | |
year = input('Enter a year (YYYY): ') | |
month = input('Enter a month (MM): ') |
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
#write a program to right, or left justify text in a file. | |
start = False | |
f = open('chuckles.txt', 'r+') | |
test = f.readlines() #creating a copy of the file for looping while modifying the original file. | |
for line in test: | |
scoop = line.rjust(50) | |
if not start: # puts block at the top of the file to overwrite the existing text | |
f.seek(0) | |
start = True | |
f.writelines(scoop) |
OlderNewer