Write Python code that does the following: a. Assigns the values 3, 4 and 5 to the variables a, b and c, respectively. b. Write an if statement that prints "OK" if a is less than b c. Write an if statement that prints "OK" if c is less than b d. Write an if statement that prints "OK" if the sum of a and b is equal to c e. Write an if statement that prints "OK" if the sum of a squared and b squared equals c squared. 2. Repeat the previous problem with the additional requirement that "NOT OK" is printed if the condition is false.

Respuesta :

Answer:

// Code in Python

#variable declaration and initialization

a, b, c = 3, 4, 5

#if a is less than b

if a < b:

#print statement

   print('OK')

else:

#print statement

   print("NOT OK")

#if c is less than b

if c < b:

#print statement

   print('OK')

else:

#print statement

   print("NOT OK")

#if a+b equal to c

if a + b == c:

#print statement

   print('OK')

else:

#print statement

   print("NOT OK")

#if sum of square of a &b equals to square of c

if a * a + b * b == c * c:

#print statement

   print('OK')

else:

#print statement

   print("NOT OK")

Explanation:

Declare and initialize a=3,b=4 and c=5.If a<b then print "OK" else print "NOT OK". If c<b then print "OK" else print "NOT OK".Next if a+b=c then print "OK" else print  "NOT OK".In last if sum of square of a & b is equal to square to c then print "OK" else print "NOT OK".

Output:

OK                                                                                                                        

NOT OK                                                                                                                    

NOT OK                                                                                                                    

OK