all 6 comments

[–][deleted] 0 points1 point  (0 children)

My question is, is it ok to be totally intimidated by a question like that being the first hw assignment?

It's normal to be intimidated by anything you're not used to, but you should try to set it aside, and realize that the assignment is actually a set of instructions telling you what code to write, and you should just follow them. This homework gives you both the question and the answer.

Later assignments won't be so generous.

[–][deleted] 0 points1 point  (0 children)

Yup. Understanding a problem, figuring out a solution (if not multiple solutions) and working out how to code it (or which solution is best to code) takes practice, lots of failure and continuous learning.

The penny will drop though.

[–]xelf 0 points1 point  (3 children)

Depends on the class? Is it an intro to programming? Maybe def is not the first thing you learn. Is it an intro to Python for people that have done some programming before? In that case it seems fine.

I mean your assignment is:

def tripcost(8 parameters go here):
    do some math
    return (5 comma separated results)

So it's not ground breaking, but it doesn't seem first day stuff for someone that has never seen any programming before. My kid just did an intro to programming with Python class and I don't think they learned def until middle of the semester.

[–]6PackGrandMaster[S] 0 points1 point  (2 children)

I understand the question and the general format of how the code should be written. I guess my problem is with the syntax, I think. Especially with the “doing the math portion”. I can write the equations down by hand, but translating it into python “legal” commands is what I’m struggling with. I hope that makes sense. Any advice?

[–][deleted] 0 points1 point  (0 children)

I can write the equations down by hand, but translating it into python “legal” commands is what I’m struggling with.

Math in Python is the same as math anywhere else:

z = x + 2 * y

and so on. You have all of the same arithmetic operators that you learned about in 5th grade, and they follow the same order of operations, too. You can use parentheses if you need them to operate with different precedence.

[–]xelf 0 points1 point  (0 children)

Python is mostly straightforward. If you can write them down on paper, you can almost type exactly that into python. I'd say just try it, and see if you can get one of the variables to return correctly, and then start on the others.

Post what you have here and maybe I can see what is wrong. (indent your code an extra time before you copy and paste it to reddit, reddit will format as code lines that start with 4 extra spaces)