Question

Hello! I am confused on the code for this question. Write a complete Python function called...

Hello! I am confused on the code for this question.

Write a complete Python function called Frog, with two integer parameters M and N, where N has the default value of 5. The function computes and returns one of two results: if N is odd it returns the equation 2 * M + N, but if it is even it returns the equation 3 * M - N instead.

Homework Answers

Answer #1

def Frog(M,N=5):    #Since N has a default value

  if N%2==1:        #check if N is odd or even using Modulus

    return (2 * M + N)

  else:

    return (3 * M - N)

Frog(4)

OUTPUT

Know the answer?
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
Similar Questions
8) Write Python code for a function called occurances that takes two arguments str1 and str2,...
8) Write Python code for a function called occurances that takes two arguments str1 and str2, assumed to be strings, and returns a dictionary where the keys are the characters in str2. For each character key, the value associated with that key must be either the string ‘‘none’’, ‘‘once’’, or ‘‘more than once’’, depending on how many times that character occurs in str1. In other words, the function roughly keeps track of how many times each character in str1 occurs...
Please write the python code for a function called called count_all_words that takes a phrase as...
Please write the python code for a function called called count_all_words that takes a phrase as an argument and counts each unique word in the phrase. The function should return a list of lists, where each sub-list is a unique [word, count] pair. (See example below.) Hint: A well-written list comprehension can solve this in a single line of code, but this approach is not required.
Write C++ code to: Create a function called “ReadFile” that: Accepts a filename as input Opens...
Write C++ code to: Create a function called “ReadFile” that: Accepts a filename as input Opens the file for reading Reads an integer from the file and returns it. Create a main function that Asks the user to input a file Passes that file to the “ReadFile” function Prints the returned integer to the screen Extra Credit: Set a default argument of “intfile.txt” for the “ReadFile” function Write an overloaded function of “ReadFile” that accepts two filenames and reads an...
This is an intro to Python question: #Write a function called linear() that takes two parameters...
This is an intro to Python question: #Write a function called linear() that takes two parameters #- a list of strings and a string. Write this function so #that it returns the first index at which the string is #found within the list if the string is found, or False if #it is not found. You do not need to worry about searching #for the search string inside the individual strings within #the list: for example, linear(["bobby", "fred"], "bob") #should...
Hello! I am a bit confused about this question,, I was under the impression that a...
Hello! I am a bit confused about this question,, I was under the impression that a residual in statistics is the difference between the observed and predicted values of the dependent variable Y for a given value of X. Here is the question along with my choices... A residual is: The difference between a data point and the regression line. A value that can be 1 or zero. A value that is always negative because it is a difference The...
Write a Python function called sumNxN with three parameters. The first parameter is a nested list...
Write a Python function called sumNxN with three parameters. The first parameter is a nested list (matrix) representing a matrix of size N x N. The second parameter is the integer N, and the third is a list of N zeros. Modify the list of zeros so that each entry is the sum of the corresponding column. There is no return. Note: You may assume the sizes provided are all correct.
Hello I need a flowchart made for reference I am using flowgorithm Here is the python...
Hello I need a flowchart made for reference I am using flowgorithm Here is the python code that I need a flowchart for def get_user_input_validated(): """ Module Name: get_user_input_validated Parameters: None Description: Defence program validates input as rock, paper or scissors returns input in lowercase making input case insensitive """ choice=["rock","paper","scissors"] while True: user_choice = input("Please enter your choice (rock/paper/scissors):") if user_choice.lower() in choice: break else: print("Sorry - that selection is not valid.",end="") return user_choice.lower()
How to code this in python Write a program that computes and prints the first 1000...
How to code this in python Write a program that computes and prints the first 1000 prime numbers - simply write out each prime number on a new line. In implementing this solution I want you to define 2 functions: is_prime which can be used to test whether a number is a prime (e.g. is_prime(17) returns True but is_prime(9) returns False) and compute_primes which will return an array (or Python list) of the first n primes where n is passed...
Complete the following question in R. Problem 5. Write a function in R called like which...
Complete the following question in R. Problem 5. Write a function in R called like which takes an input vector dat, assumed to be Poisson random variates, and computes the Maximum-Likelihood Estimator for λ
Hello, I created a class in Python and am struggling to figure out how to complete...
Hello, I created a class in Python and am struggling to figure out how to complete the last part. How can you verify that a date is before in a pythonic way? I am struggling with the operands and what to check first. Thank you! class Date(object): "Represents a Calendar date" def __init__(self, day=0, month=0, year=0): "Initialize" self.day = day self.month = month self.year = year def __str__(self): "Return a printable string representing the date: m/d/y" return f'{self.month}/{self.day}/{self.year}' def before(self,...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT