#
#
print("n", '\t', "2**n") #table column headings
print("---", '\t', "-----")
for x in range(13): #generate values for columns
print(x, '\t', 2 ** x)
I was given this code by my professor and told to modify it with the following instructions.
I did this, but then the table didn't produce the same result as before.
def squareIt(n):
return 2 ** n
print("n", '\t', "2**n") #table column headings
print("---", '\t', "-----")
for x in range(13): #generate values for columns
print(x, '\t', x **2)
Please help, as i'm stuck in this chapter.
You didn't call your function that you wrote.
def squareIt(n):
return 2 ** n
print("n", '\t', "2**n") #table column headings
print("---", '\t', "-----")
for x in range(13): #generate values for columns
print(x, '\t', squareIt(x))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.