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
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
1. In Python, 'mutable' objects such as lists are passed to functions 'by reference'. This means:...
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...
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 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...
Page 3 of 7 (Python) For each substring in the input string t that matches the regular expression r, the method call re. aub (r, o, t) substitutes the matching substring with the string a. Wwhat is the output? import re print (re.aub (r"l+\d+ " , "$, "be+345jk3726-45+9xyz")) a. "be$jk3726-455xyz" c. "bejkxyz" 9. b. "be$jks-$$xyz" d. $$$" A object a- A (2) 10. (Python) What is the output? # Source code file: A.py class A init (self, the x): self.x-...
11.2 Problem Set 2: PostScript Stack Commands (in python please) For this assignment you are to implement a PostScript command interpreter using a Stack. You must implement the stack using a singly-linked list. Solutions that use a data structure other than a singly-linked list will received no credit. The interpreter must read and execute a string of PostScript commands based on the following definitions: 1. = objn objn-1 … obj1 = : objn-1 … obj1 This command removes the topmost...
Create a python add the following functions below to the module. Each section below is a function that you must implement, make sure the function's names and parameters match the documentation (Copy-Paste). DO NOT put the functions in an if-name-main block. 1. def productSum(x: int, y: int, z: int) -> int This function should return: The product of x and y, if the product of x and y is less than z. Else it should return the sum of x...
PYTHON this implementation is really hard, Im stuck especially with the requirements they give. PLEASE HELP! THANK YOU! RECURSIVE! Give a recursive python implementation of the following function: def check_Decreasing_Order(lissy): Given lissy, a python list of integers, the above function will return True if lissy is sorted in decreasing order, otherwise it will return false. For example, print(check_Decreasing Order([100,50,8, -2])) True print(check_Decreasing_Order([108,50,8,2,35])) False Implementation Requirements: 1. Your implementation must be recursive. 2. If you need more parameters, you may define...
PYTHON please help! im stuck on this homework question, THANK YOU! please follow the rules! Give a recursive python implementation of the following function: def check_Decreasing_Order(lissy): Given lissy, a python list of integers, the above function will return True if lissy is sorted in decreasing order, otherwise it will return false. For example, print(check_Decreasing Order([100,50,8, -2])) True print(check_Decreasing_Order([108,50,8,2,35])) False Implementation Requirements: 1. Your implementation must be recursive. 2. If you need more parameters, you may define new functions or helper...
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...
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...