Question

Using python 3.6.0 Write a function, called cubic, which takes in two parameters, say x and...

Using python 3.6.0

Write a function, called cubic, which takes in two parameters, say x and y and computes the following formula: x3 + x + y and returns the computed value.

Sample output 1:
Enter x: 2
Enter y: 1
The value of the function is : 11

Sample output 2:
Enter x: 1
Enter y: 3
The value of the function is : 5

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

#Cubic.py

def cubic(x,y): # Function cubic takes two parameters x and y
   value = (x**3)+x+y #Calculating function value, where x**3 represents = x*x*x
   return value # Returning value into cubic
x = int(input("Enter x:")) # Reading value a and yand converting into int
y = int(input("Enter y:"))
result = cubic(x,y) #Calling function and store the returned value
print "The value of the function is:"+str(result) #Printing function value by converting into string to concat

#Output:

Administrator: C:Windows\ System32icmd.exe C:Python27 python Cubic.py Enter x: 2 Enter y 1 The evali of the funct ion 1s: 11

Add a comment
Know the answer?
Add Answer to:
Using python 3.6.0 Write a function, called cubic, which takes in two parameters, say x and...
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
  • Write a Python function called string_times that takes two parameters: a string and a number, and...

    Write a Python function called string_times that takes two parameters: a string and a number, and prints output in the following format: • string_times('Hi', 2) → 'HiHi' • string_times('Hi', 3) → 'HiHiHi' You MUST use a while loop in your solution.

  • Write a Python function, called counting, that takes two arguments (a string and an integer), and...

    Write a Python function, called counting, that takes two arguments (a string and an integer), and returns the number of digits in the string argument that are not the same as the integer argument. Include a main function that inputs the two values (string and integer) and outputs the result, with appropriate labelling. You are not permitted to use the Python string methods (such as count(), etc.). Sample input/output: Please enter a string of digits: 34598205 Please enter a 1-digit...

  • python program please Write a function called backwards which takes two parameters. The first is a...

    python program please Write a function called backwards which takes two parameters. The first is a file object that has already been opened in read mode called essayfile. The second is called filename, which contains the filename for the output file that will need to be properly opened and closed in your function. The function should read from already opened file object line by line. Each line in the file should have the words on the line reversed. For example,...

  • Python 1 Write a function called sum_odd that takes two parameters, then calculates and returns the...

    Python 1 Write a function called sum_odd that takes two parameters, then calculates and returns the sum of the odd numbers between the two given integers. The sum should include the two given integers, if they are odd. You can assume the arguments will always be positive integers, and the first smaller than or equal to the second. 3 To get full credit on this problem, you must define at least 1 function, use at least 1 loop, and use...

  • Use Python 3.7 to Write a function called volume_of_box() that takes three parameters (the length, width,...

    Use Python 3.7 to Write a function called volume_of_box() that takes three parameters (the length, width, and height of the box) and returns the volume of the box. Then, use that function in a program which prompts the user to enter the dimensions of a box and returns the volume. Your program should include input validation to ensure that the values entered are positive and should be able to accept float values. Many thanks for all your time and effort...

  • python Write a function called has_odd_even that takes three integers as parameters and that returns True...

    python Write a function called has_odd_even that takes three integers as parameters and that returns True if there is at least one odd and at least one even among the three numbers and that returns False otherwise. Below are some sample calls and the appropriate value to return. Function call Value returned has_odd_even(2, 4, 6) False has_odd_even(2, 3, 4) True has_odd_even(12, 4, 17) True has_odd_even(5, 17, 4) True has_odd_even(14, 7, 5) True has_odd_even(5, 4, 2) True has_odd_even(13, 20, 91) True...

  • Write a C++ program that contains a function called swapNums. This function takes two integer parameters,...

    Write a C++ program that contains a function called swapNums. This function takes two integer parameters, swaps them in memory, and outputs the results (there is nothing to return). In main, ask the user to enter two different numbers, output them as entered (step 1), call the function swapNums() which will output the numbers swapped (step 2), and then output the values again in main (step 3). You should have three sets of output. Sample run (10 and 5 were...

  • How to solve it using Python? 5. Write a function called no_squares which takes an input...

    How to solve it using Python? 5. Write a function called no_squares which takes an input parameter N, a positive integer, and returns: 1 if N is not divisible by a square and has an even number of prime factors -1 if N is not divisible by a square and has an odd number of prime factors 0 if N is divisible by a square For example, no-squares (10) returns 1 (since 10 = 2x5), no-squares (30) returns-1 (since 30...

  • Jupyter code (PYTHON) True error Write a function called trueError that takes the following inputs: •...

    Jupyter code (PYTHON) True error Write a function called trueError that takes the following inputs: • X, the new value • Xtrue, the previous value And returns the following output: • error, the calculated relative error The formula for the relative error is shown below: errue = 11100% In (): def trueError(x,xtrue): # YOUR CODE HERE raise Not ImplementedError() In (): # You can call and test your function here # YOUR CODE HERE raise Not ImplementedError()

  • Python Write a function that takes in two numbers as parameters. The function will then return...

    Python Write a function that takes in two numbers as parameters. The function will then return the value of the first parameters squared by the second parameter. Print the value of the return statement. Take a screenshot of both your code and your properly executed code after you have run it. Submit the screenshots here along with your .txt file.

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