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
27 changes: 27 additions & 0 deletions challenges/01-calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,30 @@
# 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.


def math(operator, num1, num2):
# if adding
if (operator == "add"):
return num1 + num2
# else if subtracting
elif (operator == "subtract"):
return num1 - num2
# else if multiplying
elif (operator == "multiply"):
return num1 * num2
# num 1 * num 2
# else
elif (operator == "divide"):
return num1 / num2
# num 1 / num 2
else:
return "try again"


# print(math("divide", 4, 5))
operator = input("What calculation would you like to do?")
num1 = input("What is number 1?")
num2 = input("What is number 2?")
print(math(operator, int(num1), int(num2)))
# math("divide", 8, 2)
7 changes: 7 additions & 0 deletions challenges/02-reverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,10 @@
# 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

def reverse(string):
reversed = ""
for i in (string):
reversed = i + reversed
return reversed
print(reverse("my_name_is_myles"))
11 changes: 11 additions & 0 deletions challenges/03-bank.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
print("Welcome to Chase bank.")
print("Have a nice day!")

balance = input("Your current balance is\n")
process = input("What would you like to do?\n")

if process == "deposit":
question = input("How much would you like to deposit?\n")
balance = int(balance) + int(question)
elif process == "withdraw":
question = input("How much would you like to withdraw? \n")
balance = int(balance) - int(question)

print(f"Your current balance is {balance}")
10 changes: 10 additions & 0 deletions challenges/04-alphabetical.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# 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.

def alphabetize(string):
alpha_list = sorted(string)
alpha_string = ''
for i in alpha_list:
alpha_string = f"{alpha_string}{i}"
return alpha_string


print(alphabetize("alphabet"))