对python的初步了解

python第一天总结

  1. 交换值
a = 1
b = 2
a, b =b, a
print('a: ',a,'b: ',b)
  1. if-else 与 if -elif
#猜拳游戏
import  random
player = input('请输入:剪刀(0),石头(1),布(2)')
player = int(player)
#生成0-2的随机整数
computer = random.randint(0, 2)#左闭右闭
if (player == 0 and computer == 2) or (player == 1 and computer == 0) or (player == 2 and computer == 1):
    print('you win')
elif player == computer:
    print('equl')
else:
    print('you lose')
  1. while 循环
#九九乘法表
i = 1
while i<= 9:
    j = 1
    while j <= i:
        print('{}*{}={}'.format(j,i,j*i),end=' ')
        j += 1
    print('')
    i += 1
  1. pyhton官网->docs.python.org,进入官方文档
  2. 设置模板
    进入setting-->Editor-->File and Code Templates-->选择需要修改的模板

你可能感兴趣的:(对python的初步了解)