#πŸ”’ Asking for hint and advice on how to approach assignment project for homework.

94 messages Β· Page 1 of 1 (latest)

low bluff
#

I have an assignment which I am tasked to create a calculator that calculates the compatibility of two names while using functions. The objectives would be to ask the user for two names. From the input, count the number of T’s, R’s, U’s, E’s, L’s, O's, V’s, and E’s (again) from the names. Add the numbers with each other until I end up with 2 digits then when adding, discard the tens digit and only retain the 1’s digit.
Ex. 6 + 8 = 4. 6 + 4 = 0.

Using the optional template provided by teacher:

def main():
person1 = input("Input name of Person 1: ")
person2 = input("Input name of Person 2: ")

compatibility = calculate(person1, person2)
print(person1, "and", person2, "are", compatibility, "% compatible")

def calculate(person1, person2):
return 0

main()

I started running into some confusion in VSCode where it keeps saying syntax error unless I run it in debug. On the other hand, the code works nevertheless. Putting that aside, I tried reviewing my readings from my prof but then realized that the lessons had no exercises nor further examples on how I can use my learnings to approach this task.

crude willowBOT
#

@low bluff

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

low bluff
#

I went to ask my friend on advice on this and was given this but did not add the command to count the numbers to be compared with the two inputted names. The code is

def main():
person1 = input("Input name of Person1:")
person2 = input("Input name of Person2:")

compatibility = round(calculate(person1,person2),2)

print(person1, "and", person2,"are", compatibility,"% compatible")

def calculate(person1,person2):
name1 = list(person1)
name2 = list(person2)

common = list(set(name1).intersection(name2))

percentage = (len(common) / (len(name1) + len(name2)))*100
return percentage

main()

I am not asking for the answer, I genuinely want to learn. Hoping for advice, links, hints, etc. on how I can approach this. The readings from prof is from Snakify.org. I hope for advice/hints so I can self study on this matter. Ty

rocky rose
#

I honestly don't know what you're asking

#

advice and hints? Write some unit tests

low bluff
#

I meant like what part of functions am I missing that can add the letters to be compared with the inputs from person1 & person2 πŸ˜…

#

Like it's asking

rocky rose
#

heck I dunno, I didn't look at it that closely

low bluff
#

person1 = input

#input is Johnny

then the letters are

P - 0
Y - 1
T - 0
H - 1
O - 1
N - 2

#

Then I have to add code that adds the numbers constantly till it ends up with a 2 digit output to turn into percentage

#

like

rocky rose
#

oh that's not too hard

low bluff
#

But then, idk how to apply my readings to this

rocky rose
#

does it have to happen in multiple steps like that?

low bluff
#

yeah

rocky rose
#

how tedious

low bluff
#

This is the template

#

def main():
person1 = input("Input name of Person 1: ")
person2 = input("Input name of Person 2: ")

compatibility = calculate(person1, person2)
print(person1, "and", person2, "are", compatibility, "% compatible")

def calculate(person1, person2):
return 0

main()

low bluff
# rocky rose how tedious

That's the thing, prof didn't give further examples and thus only those who had experience with coding before the subject say it's a breeze πŸ˜†

rocky rose
#

well again: I'd write unit tests. Like ```py
def test_32():
input = "302"
expected output = "32"
assert my_as_yet_unwritten_function(input) == expected_output

#

I don't think it's a breeze, but I might misunderstand.

#

I think it's tricky and that's why I recommend you write a couple of tests first

low bluff
rocky rose
#

heh

low bluff
#

The ones who said it's a breeze were my friends who took a look at the template code

rocky rose
#

that's more like it

low bluff
#

well more cuz they haven't touched python in a while or haven't at all

low bluff
#

Been thinking the answer is using def max() but still in the process of how to apply it into the assignment

rocky rose
#

whaddya do if the digits you're adding together add up to 10 or more? πŸ€”

low bluff
#

Idk if that'd mean manually from output or I would have to put that into the code that'd automatically do it

rocky rose
#

ok, got it

#

ask away

low bluff
#

to apply to this one my friend added

#

I went to ask my friend on advice on this and was given this but did not add the command to count the numbers to be compared with the two inputted names. The code is

def main():
person1 = input("Input name of Person1:")
person2 = input("Input name of Person2:")

compatibility = round(calculate(person1,person2),2)

print(person1, "and", person2,"are", compatibility,"% compatible")

def calculate(person1,person2):
name1 = list(person1)
name2 = list(person2)

common = list(set(name1).intersection(name2))

percentage = (len(common) / (len(name1) + len(name2)))*100
return percentage

main()

I am not asking for the answer, I genuinely want to learn. Hoping for advice, links, hints, etc. on how I can approach this. The readings from prof is from Snakify.org. I hope for advice/hints so I can self study on this matter. Ty

#

cuz my friend said there's only 1 line of code I have to do

low bluff
#

To be compared with the two inputted names

rocky rose
#

well, "is this the correct way to approach" can be stated more simply: "does it work"

rocky rose
rocky rose
#

there might be a way to squash that all into a single line, but it'd be incomprehensible

low bluff
#

Imma search up a YT vid on explaining max and def max if I'm going on the right direction hehe

rocky rose
#

I didn't use max in how I did it.

#

fwiw

low bluff
#

Hmm

rocky rose
#

!e print(max([3, 4]))

low bluff
#

Lemme review the readings

crude willowBOT
rocky rose
#

not a lot to "max"

#

the hardest thing about "max" is the "key" argument, which isn't required

low bluff
#

By any chance

#

The answer is in the functions category or some other

rocky rose
#

no idea what that means

low bluff
#

i meant like

#

cuz the lessons in python are chopped up into pieces

#

Which would be:

Input,print and numbers

#

conditions

#

strings

#

lists

#

functions

#

etc.

#

Prof said to use Functions in the assignment

rocky rose
#

I'd be more likely to understand you if you wrote complete, grammatical English sentences

low bluff
#

but then I'm starting to think it isn't the answer cuz there is already functions in the template provided

#

Like is the solution related to functions or it is related to another topic like Loops or Lists

#

I assumed it would be max because this was the readings before the assignment

pure crest
#

So you have to play the game "True Love", perhaps understanding the game rules and implementing those rules programmatically. I can't make sense of addition from that image. But it does look like a balanced binary tree.

low bluff
#

And remove common = list(set(name1).intersection(name2))

percentage = (len(common) / (len(name1) + len(name2)))*100
#

from my friends code

#

maybe xD

#

Thinking of adding this

pure crest
#

I don't think using that would help you understand the logic your prof is trying to teach.

low bluff
#

true xD

#

Planning to take a crash course video in YT to review the lessons from past weeks in case I missed anything

#

Cuz like I know theory ish. like what to answer in a quiz but then have little experience on application sense from said learning

#

Like, in baking a cake, I know that flour makes the cake rise and eggs make it denser.

Now the prof is asking me to bake a cake using my understanding of those theories with 1/4th the recipe and the rest is to my own understanding T-T

pure crest
#

"Theory will take you only so far..."

low bluff
#

Aight so

#

My academic experience came in clutch

#

teachers from senior high, elementary, college

#

they tend to copy paste from other teachers :/

pure crest
#

ofc they do.

low bluff
#

Will dissect this bit by bit.

#

That way in the future I can do application solo without losing braincells haha

crude willowBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.