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



# age = input("Please enter your age: ")
# age = int(age)
# print("In ten years, you will be", age + 10, "years old.")
#


# input to allow users to enter something
calc = input("Enter the a num operation you like to do: (add, sub, mult, div) ")

num1 = int(input("The First Number: "))
num2 = int(input("The Second Number: "))

if calc == "add":
result = num1 + num2
elif calc == "sub":
result = num1 - num2
elif calc == "mult":
result = num1 * num2
elif calc == "div":
result = num1 / num2
else:
print("Invalid input, please try again.")
exit()

print("Your result is", result)


17 changes: 17 additions & 0 deletions challenges/02-reverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,20 @@
# 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



#prompt the user to inter something
string = input(" Enter the string to reverse")
#initiliazing empty string
reversed_string = ""

for i in range(len(string)):
reversed_string += string[len(string)-i-1]
# The expression 'string[len(string)-i-1]'
# calculates the index of the character to be added to the
# 'reversed_string' variable.

# The loop continues until all the characters in the input string have been added to the
# 'reversed_string' variable.
print(reversed_string)
79 changes: 79 additions & 0 deletions challenges/03-bank.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,82 @@
print("Welcome to Chase bank.")
print("Have a nice day!")

balance = 4000

def deposit(balance, amount):
return balance + amount

def withdraw(balance, amount):
return balance - amount

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


# takes input from customers
transaction = input("What would you like to do? (deposit, withdraw, check_balance)\n")

if transaction == "deposit":

# prompts with questions in new line
amount = int(input("How much would you like to deposit?\n"))
balance = deposit(balance, amount)
print("Your current balance is", balance)
elif transaction == "withdraw":
amount = int(input("How much would you like to withdraw?\n"))
balance = withdraw(balance, amount)
print("Your current balance is", balance)
elif transaction == "check_balance":
print("Your current balance is", balance)

done = input("Are you done?\n")

if done == "yes":
print("Thank you!")




# from hashlib import new


# print("Welcome to Chase bank.")
# print("Have a nice day!")
# session = True
# account = 0


# def new_operation():
# global session
# input("something else? (yes, no) \n")
# if (new_operation == "yes"):
# session = True
# elif (new_operation == "no"):
# session = False


# while session == True:

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

# if (operation == "deposit"):
# num1 = input("Deposit quantity \n")
# num1 = int(num1)
# account = account + num1
# print(f"Your account is now {account}")
# new_operation()

# elif (operation == "withdraw"):
# num2 = input("Withdraw quantity \n")
# num2 = int(num2)
# account = account - num2
# print(f"Your account is now {account}")
# new_operation()

# elif (operation == "check balance"):
# print(f"your balance is {account} \n")
# new_operation()
# print(session)


# print("Have a nice day!")
44 changes: 41 additions & 3 deletions challenges/04-alphabetical.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,41 @@
# 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.
# # 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):
# # convert string to a list of characters
# chars = list(string)
# # sort the list in alphabetical order
# chars.sort()
# # join the list of characters back into a string
# alphabetized_string = ''.join(chars)
# return alphabetized_string

# # example usage
# user_string = input("Give me a string to alphabetize\n")
# result = alphabetize_string(user_string)
# print("Alphabetized:", result)



# print('Please Enter Anything to Reverse.')
# 00
# string = input()
# sorted_string = sorted(string)
# new_string = "".join(sorted_string)
# print(new_string)



def reverse_str():
# Ask the user to enter a string
string = input("Enter a something: ")
# slicing method
reversed_str = string[::-1]
return reversed_str

# Example usage:
print(reverse_str())