0
A python program to find the square of the sum of two numbers
functions
12 Antworten
+ 11
def square_sum(num1, num2):
return (num1+num2)**2
# numbers can be modified
print square_sum(4, 6)
# python 2.x doesn't needs parenthesis in the print statement, maybe that's what causing you problem.
+ 3
With Python 2.7 print is a statement, so it's not mandatory to use parenthesis, but they are totally accepted... but in Python 3 print is no more a statement, but a function, so parenthesis are mandatory ^^
The two suggested code would well work... maybe the asker verify them with a wrong case ;P
+ 2
def func (num1,num2):
return (num1+num2)**2
+ 2
What do you need exactly?
+ 1
Does the given code give any errors, or it doesn't give thе correct output?
+ 1
Try this code:
def square(x, y):
x = x + y
return (x ** 2)
0
on python 2.7 I want to know how to write a program that prints the square of the sum of two numbers
0
Try using the function with parameters 2 and 2. What is the output of that?
0
(2,2) still
- 1
not giving the required result
- 1
yeah, incorrect output
- 1
I will get back to you later, my PC is down now