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 done #203

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
31 changes: 31 additions & 0 deletions challenges/01-calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,34 @@
# 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 calculator():
# Ask for the operation
operation = input("What do you want to do?(add, sub, mult, div)\n")

# Ask for the numbers
num1 = int(input("Num 1?\n"))
num2 = int(input("Num 2?\n"))

# Perform the calculation
if operation == 'add':
result = num1 + num2
elif operation == 'sub':
result = num1 - num2
elif operation == 'mult':
result = num1 * num2
elif operation == 'div':
if num2 != 0:
result = num1 / num2
else:
print("Error: Division by zero is not allowed.")
return
else:
print("Error: Invalid operation.")
return

# Print the result
print("Your result is " + str(result))

calculator()
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):
reverse_string = ''
for i in range(len(string)-1, -1, -1):
reverse_string += string[i]
return reverse_string

print(reverse('Supacalafircationstions'))

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

def prompt(account):
balance = 500
account = input("Do you want to see your balance, withdraw or deposit?")

if account == 'balance':
print('Your balance is', balance)
elif account == 'withdraw':
withdraw = int(input("How much would you like to withdraw?"))
if withdraw <= balance:
balance -= withdraw
else:
print("Insufficient balance.")
elif account == 'deposit':
deposit = int(input("How much would you like to deposit?"))
balance += deposit

return balance

print(prompt("Egor"))


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

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