Q. Write a program whose three sample runs are shown below:

 

Sample Run 1

Random number between 0 and 5 (A): 2

Random number between 0 and 5 (B): 5.

A to the power = 32

 

Sample Run 2

Random number between o and 5 (A): 4

Random number between 0 and 5 (B): 13.

A to the power = 64

 

Sample Run 3

Random number between 0 and 5 (A): 1

Random number between 0 and 5 (B): 1.

A to the power =1

 

Answer =

 

import random
a = random.randint(0,5)
b = random.randint(0,5)
print("Random number between 0 and 5 (A): ",a)
print("Random number between 0 and 5 (B): ",b)
print("A to the power = ", a**b)



Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post