In: Computer Science
Q. 3 [35 pts] Print out the following output.
You must use exactly 2 for statements, 2 range statements, and 3 print statements. No modules are to be used for this problem.
Calculating x ** 1 1 3 5 ==== Calculating x ** 2 1 9 25 ==== Calculating x ** 3 1 27 125 ====
Python Code:
for i in range(1,4): #Loop will run 3 times i=1,2,3
print("Calculating x **",i) #one print statement
for j in range(1,6,2): #Loop will run 3 times j=1,3,5
print(j**i) #printing square
print("====") #printing required output
Here I am using only 2 for statements, 2 range statements, and 3 print statements. No module is used in above Program
Output Screenshot:
If you have any doubt feel free to ask and if you like the answer please upvote it .
Thanks