Python Exercise 4.1 Generate a power table of 3

Enter a non-negative integer n to generate a power-of-three table of 3 and output the value of 3 ~ 3 The power function can be called to calculate the power of 3.

Input format:

The input gives a non-negative integer n on one line.

Output format:

The n + 1 lines are output in increasing order of power, and the format of each line is "pow (3, i) = 3 to the power of i value". The problem is to ensure that the output data does not exceed the range of long integers.

code show as below:

#!/usr/bin/python
# -*- coding: utf-8 -*-

n = int(input())
for i in range(0,n+1):
    print("pow(3,{:d}) = {:d}".format(i,3**i))

This program is a simple loop, nothing to analyze.


There is always a book and fitness on the road

Guess you like

Origin www.cnblogs.com/Renqy/p/12732186.html