AIのためのPython入門

このページはAIのためのPython入門の参考プログラムを掲載しています。

Python for AI

You will find sample programs for the lecture 'Python for AI.

1-1-0.Short exam

print('Short Exam')

print('Caliculate 7/3 with caution to decimal')

print('Answer:')

print('7 / 3 = '+str(Decimal(7)/Decimal(3)))

1-2-3.The best gain

print(x[1][0],'gain:',(x[1][1]-x[1][2])*x[1][3])

print(x[2][0],'gain:',(x[2][1]-x[2][2])*x[2][3])

print(x[3][0],'gain:',(x[3][1]-x[3][2])*x[3][3])

print('Total gain:',(x[1][1]-x[1][2])*x[1][3]+(x[2][1]-x[2][2])*x[2][3]+(x[3][1]-x[3][2])*x[3][3])

2-0-0.Try it

Comp='Borot:'

You='You:'

 

print(Comp,'What do you want to eat at lunch tomorrow?')

print(You,end=' ')

ans=input()

 

print(Comp,'You need',ans+'? Me, too!')