Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

finished deliverable #209

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
40 changes: 40 additions & 0 deletions challenges/01-calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,43 @@
# input() always returns a string value. If you ever want someone
# to enter a number you have to use the `int()` function to convert
# what they typed in to a string.



is_running = True

while is_running:
prompt = '>'
print('hello user')
print('tell me what kind of math you want to do')
print('Possible choices: add, sub, mul, div')
math_choice = input(prompt)
print(f'math choice: {math_choice}')
print('excellent math choice! Enter the first number: ')
number_one = input(prompt)
print("Now, enter a second number: ")
number_two = input(prompt)
print(number_one, number_two)

try:
number_one = int(number_one)
number_two = int(number_two)
except ValueError as e:
print('that wasnt a real number')

switch = {
'add': number_one + number_two,
'sub': number_one - number_two,
'mul': number_one * number_two,
'div': number_one / number_two
}

if math_choice in switch:
print(f'result: {switch[math_choice]}')
else:
print(f'i lied, {math_choice} isnt a math I know about')

print('would you like to continue? Y/n')
should_quit = input(prompt)
if should_quit == 'n':
is_running = False
4 changes: 4 additions & 0 deletions challenges/02-reverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@
# several ways to reverse a string, and it's a good read!
#
# http://www.techbeamers.com/essential-python-tips-tricks-programmers/?utm_source=mybridge&utm_medium=blog&utm_campaign=read_more#tip1

string = 'hello'
print(''.join(reversed(string)))

21 changes: 21 additions & 0 deletions challenges/03-bank.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
print("Welcome to Chase bank.")
print("Have a nice day!")

balance = 4000

def banking():
print("Welcome to Chase bank.")

global balance

transaction = input("What would you like to do? (deposit, withdraw, balance)\n")

if transaction == 'deposit':
deposit_amount = float(input("How much would you like to deposit?\n"))
balance += deposit_amount
return f"Your new balance is {balance}."
elif transaction == 'withdraw':
withdraw_amount = float(input("How much would you like to withdraw?\n"))
balance -= withdraw_amount
return f"Your new balance is {balance}."
elif transaction == 'balance':
return f"Your current balance is {balance}."

print("Have a nice day!")
6 changes: 6 additions & 0 deletions challenges/04-alphabetical.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# You'll need to use a couple of built in functions to alphabetize a string.
# Try to avoid looking up the exact answer and look at built in functions for
# lists and strings instead.

string = 'supercalifragilisticexpialidocious'
string_list = list(string)
string_list.sort()
string = "".join(string_list)
print(string)