Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

compute: $\boldsymbol{\text{val} = w^{|x|}}$ click here for example 1 i…

Question

compute: $\boldsymbol{\text{val} = w^{|x|}}$
click here for example
1 import math
2
3 w = float(input())
4 x = float(input())
5
6 \\\ your code goes here \\\
7
8 print(f\val = {val:.2f}\) # outputs val with 2 decimal places

Explanation:

Step1: Calculate absolute value of x

$|x| = \text{math.fabs}(x)$

Step2: Compute val as w times |x|

$\text{val} = w \times |x|$

Answer:

import math

w = float(input())
x = float(input())

# Your code goes here
val = w * math.fabs(x)

print(f"val = {val:.2f}")