Header Ads Widget

Python program to find the value of y for a particular value of n

 

Python program to find the value of y for a particular value of n 

Write a program to find the value of y for a particular value of n. The a, x, b, n is input by user    

  • if n=1 y=ax%b
  •  if n=2 y=ax²+b²
  • if n=3 y=a-bx 
  • if n=4 y=a+x/b .

Sample input

2 3 41 1 (Values of a,x,b,n)

Sample output

Value of the y is: 6

Python program to find the value of y for a particular value of n 

The objective of the code is to find the value of y .

Code(Python):-

a,x,b,n=map(int,input("Enter the value of a,x,b,n\n").split())
if(n==1):
y=(a*x)%b
if(n==2):
y=(a*x*x)+(b*b)
if(n==3):
y=a-b*x
if(n==4):
y=a+(x/b)
print(f"Value of the y is: {y}")

Output:-

Enter the value of a,x,b,n
2 3 41 1
Value of the y is : 6

Recommended Post :-

HCL Coding Questions:-

Capgemini Coding Questions:-

Companies interview:-

Full C course:-    

Key points:-

Cracking the coding interview:-

 Array and string:-

Tree and graph:-

Hackerearth Problems:-

Hackerrank Problems:-

Data structure:-

 MCQs:-