Not Yet Answered # function of two variables

Schol-R-LEA 1,003 Anicia Schol-R-LEA 1,003 David W 119 Write a C program that should create a 10 element array of random integers (0 to 9). The program should total all of the numbers in the odd positions of the array and compare them with the total of the numbers in the even positions of the array and indicate ...

1

First off, you should understand that a Python function is not a function in the mathematical sense of a relationship between a set of values *n<sub>x</sub>* in a domain and a value *m* in a co-domain. Rather, it is a series of expressions that perform a computation, and may or may not return a value. This can be confusing, if you are coming from a mathematical background.

Also, there is a keyword `del`

in Python that has nothing to do with the three functions variously given that name. You'll want to define your own `curl()`

, `gradient()`

or `divergence()`

function to compute the value in question.

Are the two values `x`

and `y`

actually the vector <x,y>? If so, you would do well to define a vector class, if you know how to. If not, you can use lists to pass the vectors around as a unit. Thus, you would actually define your function as taking three parameters, something like this:

```
def a(vec, i, j):
vec[0] = grad(i, x)
vec[1] = grad(j, y)
return vec
```

As I say, though, a class would actually be preferable:

```
class Vector(Object):
def __init__(self, x, y):
self.__x = x
self.__y = y
def __str__(self):
return '<{x},{y}>'.format(x=self.__x, y=self.__y)
def a(self, i, j):
x = grad(i, self.__x)
y = grad(j, self.__y)
return Vector(x, y) # return a new vector
def b(self, i, j):
# put your function definition here
if __name__ == "__main__":
vec = Vector(2.0, 7.5)
new_vec = vec.a(3.3, 4.5)
```

Of course, this is assuming that you are really working with 2-dimensional vectors, and that the function you are performing on the vector components is gradient.

*Edited 2 Years Ago by Schol-R-LEA*

0

write a code fragment for the flow chart .assume that the varibles x and y are integers and z is a floating-point number.thanks i need the answer right now.please.

1

**NO**.

Don't go hijacking other people's threads. Don't go dropping your homework on us without any context. And most of all, don't go *demanding* code for a project **you** are supposed to be doing.

We are a patient and, for the most part, helpful group here. Helping you fix problems with your code is what we are here for. So is helping you improve your programming skills. Helping you cheat isn't part of the deal.

With the attitude you are giving in just this one post, I doubt anyone here will *ever* respond to you unless you make some contrite apologies *right away*.

*Edited 2 Years Ago by Schol-R-LEA*

1

@Anicia ... if you do really wish help, on your Python coding problem, please start a new thread and show what work (and code) that you have so far ... in the direction of solving the problem.

This article has been dead for over six months. Start a new discussion instead.

Recommended Articles

the function that I created to find the ...

Hi. so this is actually a continuation from another question of mineHere but i was advised to start a new thread as the original question was already answered.

This is the result of previous question answered :

code for the listbox - datagridview interaction

At the top of the code ...