I want to write a function for f(y) = xy^2 in Python. Like if I pass value such as f(3) then it should give output as 9x. How to do it?
Aug 5, 2019 in Python 1,554 views

## 1 answer to this question.

This is very easy. have a look at the following code -

```>>> def f(y):
return str(y**2) + 'x'
>>> f(9)

'81x'```

And if you have the value of constant then

```def f(y):
x=2
return x*(y**2)
>>> f(2)
8
>>> ```

Suppose you have a polynomial equation such as

p(x)=x4−4⋅x2+3⋅xp(x)=x4−4⋅x2+3⋅x then in this case :

```>>> def p(x):
return x**4 - 4*x**2 + 3*x
>>> p(2)
6

```
• 3,020 points

edited Aug 6, 2019 by Kalgi

## How to create lambda function inside a list in Python?

Hi@akhtar, The lambda statement can appear in places ...READ MORE

## how to print array integer without [] bracket in python like result = 1,2,3,4,5

Hey @abhijmr.143, you can print array integers ...READ MORE

## How to create and read from a temporary file in Python?

Hi, there is a very simple solution ...READ MORE

## How to create a GUID/UUID in Python

The uuid module, in Python 2.5 and ...READ MORE

## how can i randomly select items from a list?

You can also use the random library's ...READ MORE

+1 vote

## how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

## Lowercase in Python

You can simply the built-in function in ...READ MORE