FAQ: Introduction to Functions - Review

ok, all is clear,
thank you very much.

@m33pkittyfawk @smulhern03 and anyone else that’s having issues in this review exercise. I think step 4 is very case sensitive as in you need to output exactly the message in the example.


In @smulhern03 it’s missing “hours” in line 9.

In @m33pkittyfawk’s code for example, you capitalized “Hour” in line 16. That won’t get you the check mark.

Just noting it here in case anyone else is wondering the same.

@board6656560075 Welcome to the forums!

That’s not my experience with the exercises. This one at the very least is straight forward and you may need to reread the exercise to make sure you fully understand what it is asking for. If your answers are very different from the solution perhaps you have interpreted the exercise incorrectly.

Take the first step as an example:

First, like in our previous exercises, we want to make sure to welcome our users to the application.

Create a function called trip_planner_welcome() that takes one parameter called name. The function should use print() to output a message like this: Welcome to tripplanner v1.0

Where <Name Here> represents the parameter variable of name we defined.

Call trip_planner_welcome(), passing your name as an argument.

So right away, you are going to be making a function called trip_planner_welcome().

It has one parameter name.

The body is going to print out a message: Welcome to tripplanner v1.0

You will need to insert the parameter nane in the printed message.

Finally, call the function.

There’s not very many ways you can do this if you follow it one step at a time.

When in doubt, ask the forum!

@jsantorno consider it to be practice for reviewing everything you learned in the functions module? This specifically test your knowledge of built-in functions and user defined functions.

def trip_planner_welcome(name):
print("welcome to tripplanner v1.0 " + name)
it asks me if my function prints the correct message to the terminal, i coded it just as it wanted me to, but it is not working. is there any way i can bypass the… i don’t know what the thing is called that checks the output to see if you’ve done exactly what it wants, but yeah, bypass that so i can continue?

So, when you called the function trip_planner_welcome() what was the result in the terminal?

Also, it’s helpful if you could please format your code so it’s readable.
Use, the </> button above or here.


def trip_planner_welcome(name):
  print("Welcome to tripplanner v1.0" + ", " + (name))

terminal =
welcome to tripplanner v1.0 theDispatcher

though i just realized, it may be angry at this the other function i made:

list-type LFSR(a psudo-random number generator)

#set register to starting seed for rng(default is [0, 0, 0, 0, 0, 0, 0, 1])
#set taps for where in register the bits are xor’d(default = [0, 1])
#set iterations for the amount of times it shifts plus one(default = 1)(runs twice on default)
#set period to the, well, period that you want to output a number, 1 is default
#set output type to “binary” to dispaly raw numbers from register, “decimal” to display decimal equivalent

def LFSR(register = [0, 0, 0, 0, 0, 0, 0, 1], taps = [0, 1], iterations = 1, period = 1, output_type = "decimal"):
  shiftIn = 0
  cycle = 0
  def shift():
    i = 0
    while i < (len(register) - 1):
      register[i] = register[i + 1]
      i += 1
    register[len(register) - 1] = shiftIn
  def get_taps():
    i = 1
    accu = register[taps[0]]
    while i < len(taps):
      accu -= register[taps[i]]
      if accu != 0:
        accu = accu / accu
      accu = round(accu)
      i += 1
    return accu
  def printOutput():
    if cycle % period == 0:
      if output_type == "decimal":
        output = register[0]
        output_length = 1
        while output_length < len(register):
          output += register[output_length] * (2 ** output_length)
          output_length += 1
      if output_type == "binary":
        output = str(register[len(register) - 1])
        output_length = 1
        while output_length < len(register):
          output = output + str(register[(len(register) - 1) - output_length])
          output_length += 1
  while cycle < iterations + 1:
    shiftIn = get_taps()
    cycle += 1

after testing though, same problem
is this the format you were asking for?

Yea, if you add other non-lesson related items you will likely get an error. Comment that other function out.

it’s gone, but i still get the error, does it just need to refresh?

resetting doesn’t work

def trip_planner_welcome(name):
  print("welcome to tripplanner v1.0 " + name)

still ‘Does your function print the correct message to the terminal?’
i’m going to take a break, maybe it’ll work itself out in my head later

Even tho there is output in the terminal, I think they want you to use the print() to call the function.

I can’t view the instructions. Make sure that the string you print matches the instructions exactly (punctuation/spelling/spacing etc.)

You are printing "welcome ...", whereas other posters in the thread have "Welcome ..."

Do the instructions specify the message to be printed? If they do, make sure your output matches the specifications exactly.

This is the message they want you to output:
“Welcome to tripplanner v1.0 (Name Here)”

The instructions say, ’ Call trip_planner_welcome() , passing your name as an argument.’

But, often in lessons they want you to use print(), even if they don’t expressly say so. (which is the opposite of what one would do in Colab or Jupyter to execute code).

small(maybe) problem, it says that i have to upgrade my plan to pro in order to continue, last i checked, i was already on pro. what has happened?

I’m not sure. We cannot answer subscription/billing questions on the forums. For that, you’d have to contact CS and open a support ticket.

CS? what does that mean? you might have to tell me which buttons to push as i don’t think i’ve done that before

Sorry. Customer service/support. Under the Help section on the main page of this site. Codecademy Help>My Account should do it.

Hello, this is driving me insane.

Why isn’t this working?

def trip_planner_welcome(name): print("Welcome to tripplanner v1.0", name) trip_planner_welcome("Paul") def estimated_time_rounded(estimated_time): rounded_time = round(estimated_time) return rounded_time estimate = estimated_time_rounded(2.5) def destination_setup(origin, destination, estimated_time, mode_of_transport = "Car"): print("Your trip starts off in " + origin) print("And you are traveling to " + destination) print("You will be traveling by " + mode_of_transport) print("It will take approximately " + str(estimate) + " hours") destination_setup("Tampa", "Boston", 48)

This is the last step, can someone please give me a code I can just copy and paste so I can move on already? This exercise actually doesn’t allow you to move on, nor does it provide you with a step by step breakdown and it’s beyond frustrating!!!

1 Like