Friday, December 2, 2016

Blog 30

Why does this program not work? What is wrong with it? How do you fix it?


def summ(x,y):
    z= x+y
    return z

print z

13 comments:

  1. I think no sum this word in program, fix summ to sum.
    -lux lei

    ReplyDelete
  2. z is not defined outside of the function. In order to print the desired value from the function, the line would instead have to be:

    print (summ(x,y))
    with x and y substituted by the values desired, respectively.

    -Katelyn

    ReplyDelete
  3. Chris VanYe
    1. z is a local variable within the function and the function isn't called.
    2. the function needs to be called
    3. call/print the function with two numbers put in for x and y

    ReplyDelete
  4. 1. z isn't called outside the definition of the function.
    2. z needs to be called outside the definition.
    3. call the function using numbers outside the definition.

    Josh Lee

    ReplyDelete
  5. This program doesn't work because you defined the variable z within the local scope (within a function). You have to print the var inside the function and then call the function.

    - Abby Peterson

    ReplyDelete
  6. u can't return then print.
    return z
    z= x+y
    print z
    -Gary Gao

    ReplyDelete
  7. x and y do not have a variable you need to define x and y

    jonathan

    ReplyDelete
  8. (____) around the z and indent the print line
    then call the function

    - Owen Luther

    ReplyDelete
  9. Z isn't defined outside the function
    -Sean

    ReplyDelete
  10. 1. z isn't called.
    2. it needs to be called.
    3. call it with 2 numbers defined for x and y
    Alex Haston

    ReplyDelete
  11. fix sum, this wouldn't work
    Charlie Lin

    ReplyDelete
  12. 1. z is not defined out of the function so it will result in an error.
    2. we need to print the function instead of the variable.
    3. first fix summ to sum. Next, change the print command to print sum(any interger, another interger).
    Joe Haj

    ReplyDelete