Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions barr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
questions = {
"strong": "Do ye like yer drinks strong?",
"salty": "Do ye like it with a salty tang?",
"bitter": "Are ye a lubber who likes it bitter?",
"sweet": "Would ye like a bit of sweetness with yer poison?",
"fruity": "Are ye one for a fruity finish?"
}

ingredients = {
"strong": ["glug of rum", "slug of whisky", "splash of gin"],
"salty": ["olive on a stick", "salt-dusted rim", "rasher of bacon"],
"bitter": ["shake of bitters", "splash of tonic", "twist of lemon peel"],
"sweet": ["sugar cube", "spoonful of honey", "spash of cola"],
"fruity": ["slice of orange", "dash of cassis", "cherry on top"]
}

response={}
response
print response[value]
43 changes: 29 additions & 14 deletions birthday.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,44 @@
3: 'rd'
}

today = datetime.now()
todays_day = today.day
today = datetime.now() #entire year date + time
todays_day = today.day #just number day


# get the right ending, e.g. 1 => 1st, 2 => 2nd
# but beware! 11 => 11th, 21 => 21st, 31 => 31st

# test your code by forcing todays_day to be something different
# todays_day = 11

ending = 'th'

if todays_day < 10 or todays_day > 20:
# x % y (mod) will give the remainder when x is divided by y
# -- but x needs to be an integer!
number = todays_day % 10
# look up number in number_endings
# and if you find it as a key, put the value in ending
if number in number_endings:
def get_ending(todays_day):
ending = "th"
if todays_day < 10 or todays_day > 20:
# x % y (mod) will give the remainder when x is divided by y
# -- but x needs to be an integer!
number = todays_day % 10
# look up number in number_endings
# and if you find it as a key, put the value in ending
if number in number_endings:
ending= number_endings[number]
return ending

else:
return ending
else:
return ending

# make this print ending, not 'th'
print "Today is the {}th".format(todays_day)
print "Today is the {}".format(todays_day)+get_ending(todays_day)+"."

birthday = int(raw_input("What day of the month is your birthday?"))

# make this print the birthday, and the right ending
print "Your birthday is on the {}th!".format(todays_day)
print "Your birthday is on the {}".format(birthday)+get_ending(birthday)+"!"








3 changes: 1 addition & 2 deletions github.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ def print_user_repository_names():
for repo in repos:
# I don't think I have these keys right
# Also I'd like to print it on one line.
print repo['repo_name']
print repo['repo_description']
print repo['name'] +": "+ repo['description'].strip()


if __name__=="__main__":
Expand Down
20 changes: 10 additions & 10 deletions halloween.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# I can't be bothered to think of a Hallowe'en costume so
# can you help me generate one randomly?

import random

nouns = []
adjectives = []
Expand All @@ -15,27 +15,27 @@
for line in f:
adjectives.append(line.strip())


def generate_costume():

# pick something random from the nouns and adjectives list

noun = "lazy"
adj = "person"

noun = random.choice(nouns)
adj = random.choice(adjectives)
return (noun, adj)


while True:
(noun, adjective) = generate_costume()

print "You go dressed as a {} {} to the party."
(noun, adj) = generate_costume()
happy=False
print "You go dressed as a {} {} to the party.".format(adj, noun)

happy = raw_input("Are you happy with this choice? ")
response= raw_input("Are you happy with this choice? Y/N").upper()
if response=='Y' or response=='YES':
happy=True

# Check if the user typed something like 'yes' or 'y' and
# quit the program if they are happy.
if happy == True:
print "Great. Have a nice time at the party."
exit()
else:
print "OK, I will choose another costume. Hold on..."
Expand Down
9 changes: 5 additions & 4 deletions icecream.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
'cookie dough', 'vanilla', 'lemon']
my_faves = ['mint', 'caramel']

def print_list(my_list):
for item in my_list:
if item in my_faves:
print "I like {}".format(item)

for item in my_list:
if my_faves:
print "I like {}".format(item)

print print_list(all_flavors)
24 changes: 16 additions & 8 deletions keyboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,27 @@
'violin', 'oboe', 'triangle']

def get_cat_and_instrument(position):
cat = cats[position]
instrument = instruments[position]
return "{} plays the {}".format(cat, instrument)
cat = cats[position]
instrument = instruments[position]
return "{} plays the {}".format(cat, instrument)

# Print out my cat orchestra one by one
total_cats = len(cats)
position = 0

while True:
if position >= total_cats:
break
if position >= total_cats:
break

else:
print get_cat_and_instrument(position)
position += 1

# Could you do the assignment of cats and instruments any other ways?


#while position <= total_cats:
# print get_cat_and_instrument(position)
# position += 1

print get_cat_and_instrument(position)
position += 1

# Could you do the assignment of cats and instruments any other ways?
26 changes: 26 additions & 0 deletions names.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Black Widow
Wonder Woman
Atom Girl
Rainbow Brite
She Ra
Captain Marvel
Lightning Lass
Red Guardian
Crimson Avenger
White Witch
Wind Dancer
Miss Victory
Poison Ivy
Killer Frost
Dark Phoenix
Lady Mastermind
Silk Fever
Princess Python
Amazing Grace
Doctor Poison
Emerald Empress
Granny Goodness
Saturn Queen
Silver Banshee
Star Sapphire
Pink Pearl
42 changes: 42 additions & 0 deletions superhero.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import string
uppers = string.uppercase
username= raw_input('what is your name...')

first_letter= username[0].upper() #returns capitalized the first letter in user's name
first_position= uppers.find(first_letter)
superheroList=[]

with open('names.txt') as f:
for line in f:
superheroList.append(line.strip('\n'))

print "Hi "+ username+". Your superheroine name is... "+ superheroList[first_position]
#part 2


import random

firstnames=[]
lastnames=[]

for name in superheroList:
firstnames.append(name.split(' ')[0])
lastnames.append(name.split(' ')[1])

randoName=random.choice(firstnames)+" "+ random.choice(lastnames)

print "Your random superheroine name is: " + randoName














44 changes: 28 additions & 16 deletions vacation.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@


vacation_spots = ['Tahoe', 'Hawaii', 'New York', 'Mexico']

seasons = ['spring', 'summer', 'fall', 'winter']
seasons = ['spring', 'summer', 'fall', 'winter', 'autumn']

weather_patterns = {
'spring': 'rain',
'summer': 'sun',
'fall': 'wind',
'winter': 'snow'
'winter': 'snow',
'autumn':'wind'

}

activities = {
Expand All @@ -28,42 +29,53 @@ def best_vacation_spot(weather_type):
# Look at the weather type and return the vacation spot that
# is the best for that weather.
# You can use this mapping:
# snow = Tahoe
# wind = Hawaii
# rain = New York
# sun = Mexico

return "Stay at home"
if weather_type=='snow':
vacation_spot='Tahoe'
return 'Tahoe'
elif weather_type=='wind':
vacation_spot='Hawaii'
return 'Hawaii'
elif weather_type=='rain':
vacation_spot='New York'
return 'New York'
elif weather_type=='sun':
vacation_spot='Mexico'
return 'Mexico'
else:
return "Stay at home"


def vacation_activity(weather_type):
# Look up the vacation activity from activities
# and return just the activity itself
print activity
activity= activities[weather_type]
return activity


def get_my_vacation():

season = raw_input("What season do you want to travel? ")
season = raw_input("What season do you want to travel? ").lower()

# check if season is in the seasons list
if not seasons:
if season not in seasons:
print "Sorry, that isn't a season. I can't help you."

quit()
# look up the weather type for that season
weather = weather_patterns[season]

# get the best vacation spot for that type
best_vacation_spot(weather_type)
vacation_spot = best_vacation_spot(weather)

# get the best vacation activity for that type
vacation_activity(weather_type)
vacay_activity=vacation_activity(weather)

print "You should travel to {}, where you can spend your time {}!".format(vacation_spot, vacation_activity)
print "You should travel to {}, where you can spend your time {}!".format(vacation_spot, vacay_activity)


def main():
print "Welcome to the Vacation-o-Matic!"
get_my_vacation()



if __name__=="__main__":
Expand Down