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
17 changes: 17 additions & 0 deletions challenges/01-calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,20 @@
# 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 simple_calc():
user_choice = input("what would you like to do? Type '+', '-', '*', or '/': ")
num1 = int(input('what is number 1? '))
num2 = int(input('what is number 2? '))
if (user_choice == '+'):
print(num1 + num2)
elif (user_choice == '-'):
print(num1 - num2)
elif (user_choice == '*'):
print(num1 * num2)
elif (user_choice == '/'):
print(num1 / num2)
else:
return 'no valid option entered'

simple_calc()
10 changes: 10 additions & 0 deletions challenges/02-reverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,13 @@
# 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(word):
word_reversed = ''
for character in word:
word_reversed = character + word_reversed

print("Here is your original word: ", word)
print("Here is the reversed word: ", word_reversed)

reverse_string(input('What word would you like to reverse today? '))
42 changes: 40 additions & 2 deletions challenges/03-bank.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,41 @@
print("Welcome to Chase bank.")
print("Have a nice day!")

balance = int(input('Enter your starting balance: \n'))

print("Welcome to PNC Bank!")

def going_to_bank():
services = input('How may we help you today? (Deposit, Withdraw, Check Balance) \n')
if (services == 'Deposit' or services == 'deposit'):
deposit_amount = int(input('How much would you like to deposit today? \n'))
print(f"You have deposited ${deposit_amount}. Your new balance is ${deposit_amount+balance}")
anything_else = input("Is there anything else you would like to do today? (Yes or No) \n")
if (anything_else == 'Yes' or anything_else == 'yes'):
going_to_bank()
elif (anything_else == 'No' or anything_else == 'no'):
print('Have a great day!')
else:
print("Hmm, I didn't understand that. Goodbye!")
elif (services == 'Withdraw' or services == 'withdraw'):
withdraw_amount = int(input('How much would you like to withdraw today? '))
print(f"You have withdrawn ${withdraw_amount}. You have ${balance-withdraw_amount} left in your account.")
anything_else = input("Is there anything else you would like to do today? (Yes or No) \n")
if (anything_else == 'Yes' or anything_else == 'yes'):
going_to_bank()
elif (anything_else == 'No' or anything_else == 'no'):
print('Have a great day!')
else:
print("Hmm, I didn't understand that. Goodbye!")
elif (services == 'Check Balance' or services == 'check balance'):
print(f"You have ${balance} in your account")
anything_else = input("Is there anything else you would like to do today? (Yes or No) \n")
if (anything_else == 'Yes' or anything_else == 'yes'):
going_to_bank()
elif (anything_else == 'No' or anything_else == 'no'):
print('Have a great day!')
else:
print("Hmm, I didn't understand that. Goodbye!")
else:
print("Sorry, I didn't catch that.")
going_to_bank()

going_to_bank()
9 changes: 9 additions & 0 deletions challenges/04-alphabetical.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# 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 alphabetical():
word = input("\n Give me a string to alphabetize: \n")
character_array = list(word)
character_array.sort()
sorted_word = "".join(character_array)
print("\n Here is your word alphabetized: \n", sorted_word)

alphabetical()