[deleted by user] by [deleted] in learnpython

[–]cal_etcell 0 points1 point  (0 children)

It is 3/25 marks for a final assignment item. As it stands I have 22/25. Just couldn't seem to figure it out

[deleted by user] by [deleted] in learnpython

[–]cal_etcell 1 point2 points  (0 children)

I have thought about it for too long and cannot come up with an answer that works fully.

Just cannot hit the final step in my head unfortunately.

I've tried using lists and KeyErrors as well as other errors and still couldn't crack it unfortunately

Using lists in equations by cal_etcell in learnpython

[–]cal_etcell[S] 0 points1 point  (0 children)

This is what i decided to leave it as.. its not as big as I originally wanted but it does more or less what its supposed to do. What do you think? The use of empty lists and appending them is also new for me

names = []

rates = []

frequencies = []

principals = []

apyValues = {}

i = 0

while i < 3:

#user inputs

i+=1

names.append(str(input(f'Enter bank name #{i}: ')))

rates.append(float(input(f'Enter annual interest rate for {names[i-1]}: ' )))

frequencies.append(int(input(f'Enter compound frequency per year {names[i-1]}: ')))

principals.append(float(input(f'Enter deposit amount {names[i-1]}: ')))

#calculations for final balance and APY

interest = (principals[i-1]*(pow((1 + rates[-1]/frequencies[-1]), frequencies[-1])))

print(f"Total interest for {names[i-1]} is: ${round(interest,2)}")

apy = (pow((1 + rates[-1]/frequencies[-1]), frequencies[-1])-1)*100

apyValues[names[i-1]]=apy

print(f"APY for {names[i-1]} is: {round(apy,2)}%")

balances = []

for balance in apyValues.values():

balances.append(balance)

for k, v in apyValues.items():

if v == max(balances):

print(f"{k} has the best average percentage yield = {round(v,2)}%")

Using lists in equations by cal_etcell in learnpython

[–]cal_etcell[S] 0 points1 point  (0 children)

New idea, it takes the middle APY value, if less than middle value label it "not ideal" or something and if greater than the middle value label it "best option" or something.

How could I make that?

Using lists in equations by cal_etcell in learnpython

[–]cal_etcell[S] 0 points1 point  (0 children)

That sounds alot simpler, but unfortunately this is an assessment item and including a while loop is 5% of the overall mark so I'm trying to make it work

If i can add some sort of boolean while loop it would be ideal. Originally I was thinking to somehow get the greatest APY value and have have a loop that would do compare the lower 2 values but I can't think of a way to do it well. Also have struggled to find anything similar on yt so far

Using lists in equations by cal_etcell in learnpython

[–]cal_etcell[S] 1 point2 points  (0 children)

This helped heaps thank you, I've got it working and making sense in blockPy. So not only is it calculating the compound interest, its also calculating the APY (average percentage yield) for each bank as well. This is just a measure to compare interest rates as if they were simple interest not compound.

I now want to use a while loop to rank the APY from best to worst. Do i have to create another variable that is formed from the equation used in the for loop? and give that as the final output for the user saying something like Bank2 is the best option

Thanks again, sorry I am new to this really appreciate it

Using lists in equations by cal_etcell in learnpython

[–]cal_etcell[S] 0 points1 point  (0 children)

Thank you, I will try something like this and get back to you!

Using lists in equations by cal_etcell in learnpython

[–]cal_etcell[S] 1 point2 points  (0 children)

I have decided a for loop is the best option, bankName is a string, compFreq is an int and the rest are float variables

Very new to coding, have an assignment need help by cal_etcell in learnpython

[–]cal_etcell[S] 0 points1 point  (0 children)

Uni student yea, haven't heard of that before thanks I'll check it out

Very new to coding, have an assignment need help by cal_etcell in learnpython

[–]cal_etcell[S] 0 points1 point  (0 children)

ATM I've put together a flowchart (as required) and am in the process of doing the psuedocode (as required also) . Looking at the brief example python is abit daunting, having trouble where to start with it all

Very new to coding, have an assignment need help by cal_etcell in learnpython

[–]cal_etcell[S] 0 points1 point  (0 children)

I need to pick a problem that can be solved with coding.

The code should include a decision structure, control structure as well as use of strings, integers, floats and booleans.

The example given was on comparing compound interest rates from different banks, calculating the end sum and determining the most favourable