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

Deliverable completed #201

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
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"[python]": {
"editor.defaultFormatter": "ms-python.autopep8"
},
"python.formatting.provider": "none"
}
25 changes: 25 additions & 0 deletions challenges/01-calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,28 @@
# 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.


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

number1 = float(input("What is number 1? "))
number2 = float(input("What is number 2? "))

result = None

if calculation == "add":
result = number1 + number2
elif calculation == "sub":
result = number1 - number2
elif calculation == "mult":
result = number1 * number2
elif calculation == "div":
if number2 != 0:
result = number1 / number2
else:
print("Error: Cannot divide by zero.")
else:
print("Invalid calculation method.")

if result is not None:
print("Your result is", result)
8 changes: 8 additions & 0 deletions challenges/02-reverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,11 @@
# 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 = input("Enter a string: ")
reversed_string = ""

for char in string:
reversed_string = char + reversed_string

print(reversed_string)
45 changes: 44 additions & 1 deletion challenges/03-bank.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,46 @@
print("Welcome to Chase bank.")
print("Have a nice day!")


balance = 4000

def check_balance():
print("Your current balance is")
print(balance)

def deposit():
amount = float(input("How much would you like to deposit?\n"))
global balance
balance += amount

def withdraw():
amount = float(input("How much would you like to withdraw?\n"))
global balance
if amount <= balance:
balance -= amount
else:
print("You are broke")

print ("Your current balance is")
print(balance)

while True:
action = input("What would you like to do? (deposit, withdraw, check_balance)\n")

if action == "deposit":
deposit()
check_balance()
elif action == "withdraw":
withdraw()
check_balance()
elif action == "check_balance":
check_balance()
else:
print("Invalid action.")

done = input("Are you done?\n")
if done == "yes":
print("Thank you!")
print("Have a nice day!")



8 changes: 8 additions & 0 deletions challenges/04-alphabetical.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# 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(string):
alphabetized_string = ''.join(sorted(string))
return alphabetized_string

input_string = input("Give me a string to alphabetize:\n")
result = alphabetize_string(input_string)
print("Alphabetized:", result)