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

while True:

operation = input("What operation would you like to do? Input add, sub, mult, or div: ")

num1 = int(input("What's your first number? "))

num2 = int(input("What's your second number? "))

if operation == "add":
print("Your result is " + str(num1 + num2))
elif operation == "sub":
print("Your result is " + str(num1 - num2))
elif operation == "mult":
print("Your result is " + str(num1 * num2))
elif operation == "div":
print("Your result is " + str(num1 / num2))

9 changes: 9 additions & 0 deletions challenges/02-reverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,12 @@
# 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():
string = input("Enter a string: ")
reverse = ""
for letter in reversed(string):
reverse += letter
print(reverse)

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

balance = input("Your current balance is\n")
balance = int(balance)
action = input("What would you like to do? (deposit, withdraw, check_balance)\n")
if action == "deposit":
deposit_amount = input("How much would you like to deposit?\n")
deposit_amount = int(deposit_amount)
new_balance = balance + deposit_amount
print("Your current balance is " + str(new_balance))
elif action == "withdraw":
withdraw_amount = input("How much would you like to withdraw?\n")
withdraw_amount = int(withdraw_amount)
new_balance = balance - withdraw_amount
print("Your current balance is " + str(new_balance))
elif action == "check_balance":
print("Your current balance is " + str(balance))
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 = "teststring"
string_list = list(string)
string_list.sort()
string = "".join(string_list)
print(string)