Compare commits
12 Commits
adventure-
...
5546a6d8f9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5546a6d8f9 | ||
|
|
d592cc5b0b | ||
|
|
9f9c84428c | ||
|
|
149df344ce | ||
|
|
ca1e52929c | ||
|
|
ab881dd578 | ||
|
|
d27d5025fb | ||
|
|
cb99c6af49 | ||
|
|
f5ef14dee8 | ||
|
|
247b241041 | ||
|
|
1b92f1d3f6 | ||
|
|
89b8c97671 |
13
3/3.10 Tweet Decoder/tweet_decoder/main.py
Normal file
13
3/3.10 Tweet Decoder/tweet_decoder/main.py
Normal file
@@ -0,0 +1,13 @@
|
||||
tweet = input('Enter abbreviation from tweet:\n')
|
||||
|
||||
tweet_dict = {
|
||||
'LOL': 'LOL = laughing out loud',
|
||||
'BFN': 'BFN = bye for now',
|
||||
'FTW': 'FTW = for the win',
|
||||
'IRL': 'IRL = in real life'
|
||||
}
|
||||
|
||||
try:
|
||||
print(tweet_dict[tweet.upper()])
|
||||
except KeyError:
|
||||
print("Sorry, don't know that one")
|
||||
16
3/3.11 Smallest Number/smallest_number/main.py
Normal file
16
3/3.11 Smallest Number/smallest_number/main.py
Normal file
@@ -0,0 +1,16 @@
|
||||
|
||||
def get_input():
|
||||
result = []
|
||||
print('Enter a number when prompted. Press enter to stop')
|
||||
while True:
|
||||
_input = input('Input a number: ')
|
||||
if len(_input) == 0:
|
||||
break
|
||||
try:
|
||||
_input = int(_input)
|
||||
result.append(_input)
|
||||
except ValueError:
|
||||
print("Error, only accepts numbers")
|
||||
return result
|
||||
|
||||
print(min(get_input()))
|
||||
53
3/3.12 Seasons/seasons/main.py
Normal file
53
3/3.12 Seasons/seasons/main.py
Normal file
@@ -0,0 +1,53 @@
|
||||
from datetime import datetime
|
||||
import logging
|
||||
|
||||
logging.basicConfig(level=logging.ERROR)
|
||||
|
||||
input_month = input('Input a month to analyse: ')
|
||||
input_day = int(input('Input a day of that month: '))
|
||||
|
||||
def convert_doy_to_season(doy):
|
||||
if not isinstance(doy, int):
|
||||
return 'Invalid'
|
||||
|
||||
if 79 <= doy <= 171:
|
||||
return 'Spring'
|
||||
if 172 <= doy <= 264:
|
||||
return 'Summer'
|
||||
if 265 <= doy <= 354:
|
||||
return 'Autumn'
|
||||
if 355 <= doy <= 365 or 1 <= doy <= 78:
|
||||
return 'Winter'
|
||||
|
||||
def convert_month_to_num(month_name):
|
||||
try:
|
||||
_date = datetime.strptime(month_name, "%B")
|
||||
logging.debug(_date.month)
|
||||
return int(_date.month)
|
||||
except ValueError:
|
||||
logging.warning('Was unable to convert from full month name, trying with shortname.')
|
||||
try:
|
||||
_date = datetime.strptime(month_name, "%b")
|
||||
logging.debug(_date.month)
|
||||
return int(_date.month)
|
||||
except ValueError:
|
||||
logging.error('Was unable to convert the month {0}! Tried long name and short name.'.format(month_name))
|
||||
return None
|
||||
|
||||
def day_of_year(month,day):
|
||||
try:
|
||||
# Cannot handle leap years!!!
|
||||
if day > 30 or day <= 0:
|
||||
raise OverflowError
|
||||
|
||||
result = int((275 * month) / 9.0) - 2 * int((month + 9) / 12.0) + day - 30
|
||||
logging.debug(result)
|
||||
return result
|
||||
except TypeError:
|
||||
return None
|
||||
except OverflowError:
|
||||
return None
|
||||
|
||||
|
||||
print(convert_doy_to_season(day_of_year(convert_month_to_num(input_month), input_day)))
|
||||
|
||||
40
3/3.13 Exact Change/exact_change/main.py
Normal file
40
3/3.13 Exact Change/exact_change/main.py
Normal file
@@ -0,0 +1,40 @@
|
||||
try:
|
||||
user_cents = int(input('Cents: '))
|
||||
except ValueError:
|
||||
print('Cannot cannot parse input.')
|
||||
exit()
|
||||
|
||||
change = []
|
||||
coins = [
|
||||
['Dollars', 'Dollar'],
|
||||
['Quarters', 'Quarter'],
|
||||
['Dimes', 'Dime'],
|
||||
['Nickels', 'Nickel'],
|
||||
['Pennies', 'Penny']]
|
||||
|
||||
while user_cents >= 100:
|
||||
user_cents -= 100
|
||||
change.append(coins[0])
|
||||
while user_cents >= 25:
|
||||
user_cents -= 25
|
||||
change.append(coins[1])
|
||||
while user_cents >= 10:
|
||||
user_cents -= 10
|
||||
change.append(coins[2])
|
||||
while user_cents >= 5:
|
||||
user_cents -= 5
|
||||
change.append(coins[3])
|
||||
for _i in range(user_cents):
|
||||
change.append(coins[4])
|
||||
|
||||
if len(change) != 0:
|
||||
for coin in coins:
|
||||
num_coins = change.count(coin)
|
||||
if num_coins != 0:
|
||||
if num_coins > 1:
|
||||
print('{0} {1}'.format(num_coins, coin[0]))
|
||||
else:
|
||||
print('{0} {1}'.format(num_coins, coin[1]))
|
||||
else:
|
||||
print('No change ')
|
||||
|
||||
5
4/4.2/4.2.3/main.py
Normal file
5
4/4.2/4.2.3/main.py
Normal file
@@ -0,0 +1,5 @@
|
||||
user_num = int(input())
|
||||
|
||||
while user_num >= 1:
|
||||
user_num = user_num / 2 # We operate on the value first, before printing it
|
||||
print(user_num)
|
||||
9
4/4.3/4.3.3/main.py
Normal file
9
4/4.3/4.3.3/main.py
Normal file
@@ -0,0 +1,9 @@
|
||||
num_insects = int(input()) # Must be >= 1
|
||||
|
||||
result = []
|
||||
|
||||
while num_insects <= 100:
|
||||
result.append(num_insects)
|
||||
num_insects = num_insects * 2
|
||||
|
||||
print(*result, end = ' ')
|
||||
12
4/4.5/4.5.2/main.py
Normal file
12
4/4.5/4.5.2/main.py
Normal file
@@ -0,0 +1,12 @@
|
||||
contact_emails = {
|
||||
'Sue Reyn' : 's.reyn@email.com',
|
||||
'Mike Filt': 'mike.filt@bmail.com',
|
||||
'Nate Arty': 'narty042@nmail.com'
|
||||
}
|
||||
|
||||
new_contact = input()
|
||||
new_email = input()
|
||||
contact_emails[new_contact] = new_email
|
||||
|
||||
for contact in contact_emails:
|
||||
print('{0} is {1}'.format(contact_emails.get(contact), contact))
|
||||
8
4/4.8/4.8.1/main.py
Normal file
8
4/4.8/4.8.1/main.py
Normal file
@@ -0,0 +1,8 @@
|
||||
num_rows = int(input())
|
||||
num_cols = int(input())
|
||||
|
||||
for _i in range(num_rows):
|
||||
print('*', end=' ')
|
||||
for _i in range(num_cols - 1):
|
||||
print('*', end=' ')
|
||||
print()
|
||||
11
4/4.8/4.8.2/main.py
Normal file
11
4/4.8/4.8.2/main.py
Normal file
@@ -0,0 +1,11 @@
|
||||
num_rows = int(input())
|
||||
num_cols = int(input())
|
||||
|
||||
# Note 1: You will need to declare more variables
|
||||
# Note 2: Place end=' ' at the end of your print statement to separate seats by spaces
|
||||
|
||||
for row_num in range(1, num_rows + 1):
|
||||
for col_char in map(chr, range(ord('A'), ord('A') + num_cols)):
|
||||
print('{0}{1}'.format(row_num, col_char), end=' ')
|
||||
|
||||
print()
|
||||
Reference in New Issue
Block a user