Question: Problem 1 For this exercise you will write three functions The first function called calculate _ interest will calculate the interest and return it .
Problem
For this exercise you will write three functions
The first function called calculateinterest will calculate the interest and return it
The second function is called makewithdrawal will perform withdrawal and return the new balance if the withdrawal is successful, otherwise
The third function is called makedeposit will perform diposit and return the new balance if the deposit is successful, otherwise
Interest formula:
interest principal rate time
# DON'T CHANGE THE TEMPLATES BELOW. WRITE THE SOLUTIONS FOR THE GIVEN FUNCTIONS
# Initialize a global constant Rate
RATE
# Function to calculate new interest
def calculateinterestprincipal time:
# Write your logic for this function here.
interest principal RATE time
return interest
# Function to calculate new balance after a withdrawal
def makewithdrawalbalance amount:
# Write your logic for this function here.
if amount balance:
balance amount
return balance
else:
return
# Function to calculte new balance after a deposite
def makedepositbalance amount:
# Write your logic for this function here.
if amount :
balance amount
return balance
else:
return
Problem
Describe your program here.
Write a function that take three inputs num num and op and performs arithmetic operations such as addition subtraction multiplication and division Your program must return the operation results based on the operator specified by the op variable.
Input:
performarithmeticoperations
Output:
Input:
performarithmeticoperations
Output:
Input:
performarithmeticoperationsb
Output:
Invalid input!.
Input:
performarithmeticoperations ~
Output:
Unknown operator!
Input:
performarithmeticoperations
Output:
Impossible operation!
Variables: num num op
# Write the function here
def performarithmeticoperationsnum num op:
# Write your function body here.
try:
num floatnum
num floatnum
except ValueError:
return "Invalid input!"
# Perform the operation based on the operator
if op :
return num num
elif op :
return num num
elif op :
return num num
elif op :
if num:
return "Impossible operation!"
return num num
else:
return "Unknown operator!"
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
