import math def f1(n): log = math.log(n, 2) answer = 'log(' + str(n) + ')=' + str(round(log, 1)) return answer def f2(n): log = (math.log(n, 2) ** 2) answer = 'log^2(' + str(n) + ')=' + str(round(log, 1)) return answer def f3(n): log = (n * math.log(n, 2)) answer = str(n) + 'log(' + str(n) + ')=' + str(round(log, 1)) return answer def f4(n): power = math.pow(n,2) answer = str(n) + '^2' + '=' + str(int(power)) return answer def f5(n): power = math.pow(2,n) answer = '2^' + str(n) + '=' + str(int(power)) return answer def f6(n): factorial = math.factorial(n) answer = str(n) + '!' + '=' + str(int(factorial)) return answer def f7(n): power = math.pow(n, n) answer = str(n) + '^' + str(n) + '=' + str(int(power)) return answer def printGraph(func1, func2, n): answer = [(func1(x), func2(x)) for x in range(1, int(n+1))] # strAnswer = ' '.join([str(i) for i in answer]) # strAnswer = ' '.join(map(str, answer)) # answer.tanslate(None, ",()") # print(answer[0][0] + '\t' + answer[0][1]) # print(answer[1][0] + '\t' + answer[1][1]) # print(answer[2][0] + '\t' + answer[2][1]) # print(answer[3][0] + '\t' + answer[3][1]) # print(answer[4][0] + '\t' + answer[4][1]) # [print(i, j) for i in answer for j in answer] for i in range(0, int(n)): print(answer[i][0] + '\t\t' + answer[i][1]) # print(strAnswer + '\n')
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question