Question

1. In Python, 'mutable' objects such as lists are passed to functions 'by reference'. This means:...

1. In Python, 'mutable' objects such as lists are passed to functions 'by reference'. This means:

a.) Changes made to the object within the function persist after the function completes

b.) The function receives a copy of the object

c.) Python keeps a history of where then object was used

d.) Statements in the function can refer to the object by nickname

2. Which of the following is NOT a requirement for a Python function:

a.) The function must have at least one input parameter

b.) All statements in the function body must have the same indenting

c.) The function definition line must end in a colon

d.) The function body must have at least one statement

3. Suppose you've written the below function and it's not correctly printing the value of x. Which is the reason?

def myFunction():
  x = 1
  return x
  print(x)

a.) Python functions don't execute any commands after the 'return' statement

b.) The function has no input parameters

c.) The print() command needs a string

d.) The function doesn't modify x from its original value

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer

1)  a.) Changes made to the object within the function persist after the function completes
2)  a.) The function must have at least one input parameter
3)  a.) Python functions don't execute any commands after the 'return' statement
Add a comment
Know the answer?
Add Answer to:
1. In Python, 'mutable' objects such as lists are passed to functions 'by reference'. This means:...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • USING PYTHON 3. For this question, you will build three helper functions and one main function....

    USING PYTHON 3. For this question, you will build three helper functions and one main function. All four functions must work together to draw the letter ‘H. Every line of code written should be inside of a function. Here are the function specifications: 1) Helper function (given): def draw_edges(symbol, width): print(symbol + " "*(width-2) + symbol) 2) Helper function: draw_H(symbol, width, height): This function will draw an "H" symbol, given the symbol, width, and height. This function must call the...

  • (Must be written in Python) You've been asked to write several functions. Here they are: yourName()...

    (Must be written in Python) You've been asked to write several functions. Here they are: yourName() -- this function takes no parameters. It returns a string containing YOUR name. For example, if Homer Simpson wrote this function it would return "Homer Simpson" quadster(m) -- this function takes a value m that you pass it then returns m times 4. For example, if you passed quadster the value 7, it would return 28. isRratedMovieOK(age) -- this function takes a value age...

  • 1. In Python, Write a function to convert inches into yards, feet and inches. The functions...

    1. In Python, Write a function to convert inches into yards, feet and inches. The functions should take one parameter, 'inches', and print out the number of yards, feet, and inches equivalent to the value of the argument. Call the function after prompting the user to enter the number of inches. Don't forget to convert the input to an 'int'. 2. In Python,Write a function to convert celsius to fahrenheit. The function should return a value, which you should assign...

  • In PYTHON! Exercise 3: Lists and Functions In this exercise we will explore the use of...

    In PYTHON! Exercise 3: Lists and Functions In this exercise we will explore the use of lists and functions with multiple inputs and multiple outputs. Your task is to implement the separate_and_sort function. This function takes two input parameters: 1. A list containing strings and integers in any order. 2. An optional integer parameter size which controls how many items in the list the function will process. If the length of the list is smaller than the value of size,...

  • In python, please help me fill in these functions given their limitations. Please use for loops....

    In python, please help me fill in these functions given their limitations. Please use for loops. def palindrome(x): """ For a given string, determine if the string is a palindrome. (The same forward and back) Input: String of any size (including empty) Return: Boolean (True if palindrome, False otherwise) Limitation: You must use a loop. Only function allowed to be used is len (if needed). Cannot use "in" besides "for var in container" """ pass def getCount(char, strng): """ Get...

  • Python Programing : Convert to binary - functions Write a program that takes in a positive...

    Python Programing : Convert to binary - functions Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binary. For an integer x, the algorithm is: As long as x is greater than 0 Output x % 2 (remainder is either 0 or 1) x = x // 2 Note: The above algorithm outputs the 0's and 1's in reverse order. You will need to write a...

  • Python: Arrays and Lists (do code on repl.it) Part C (4 points) - more advanced lists...

    Python: Arrays and Lists (do code on repl.it) Part C (4 points) - more advanced lists You will need a Python repl to solve part C. In Python, define a function named secondHighest which accepts a list of numbers, and returns the second highest number from the list. If the highest value occurs more than once, then it is also the second highest (see example). Assume the input list will always have length at least two (so there is always...

  • Python Lesson Assignment Implement the following 4 functions: fancy_min(a, b) Input: two formal parameters: a and...

    Python Lesson Assignment Implement the following 4 functions: fancy_min(a, b) Input: two formal parameters: a and b Output: return the minimum of a and b Notes: a and b can either be a number or None if a is None, return b if b is None, return a if both are None, return None otherwise return the minimum of a and b do not use the built in function min() fancy_max(a, b) Input: two formal parameters: a and b Output:...

  • PYTHON l functions must include docstrings. Programs with functions must have the statement if __name__==__”main”__ The...

    PYTHON l functions must include docstrings. Programs with functions must have the statement if __name__==__”main”__ The main() function is provided, write the functions that are called in the main() function to produce these outputs. >>> ========== RESTART: E:/IVC/CS10 Python/Labs/lab 03-4_commission.py ========== Enter the monthly sales: 14550.00 Enter the amount of advanced pay, or enter 0 if no advanced pay was given. Advanced pay: 1000.00 The pay is $746.00 >>> ========== RESTART: E:/IVC/CS10 Python/Labs/lab 03-4_commission.py ========== Enter the monthly sales: 9500...

  • Data Structure ( PYTHON) 1 - What is the output to the terminal with this Python...

    Data Structure ( PYTHON) 1 - What is the output to the terminal with this Python code                                 Dick = [“white”; 0x000000, “black” ;0xFFFFFF]                                                    For item in dict;                                                    Print(item) 2 - Which condition must a linked list implementation of a queue satisfy when the queue is empty                                 Front is empty                                 Rear is empty                                 Front is null                                 Rear is null                 3 -  Which method is to be used with a list in Python?                                ...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT