摘要: import random all_choices = ['石头','剪刀','布'] computer = random.choice(all_choices) player = input('请出拳: ') print('Your choice:', player, "Computer's choice:", computer) # 另外一种写法: # print("Your choic... 阅读全文
posted @ 2019-05-13 18:20 hejp 阅读(424) 评论(0) 推荐(0) 编辑
摘要: score = int(input('分数: ')) if score >= 60 and score = 90: print('优秀') else: print('你要努力了') 输出: 阅读全文
posted @ 2019-05-13 16:35 hejp 阅读(143) 评论(0) 推荐(0) 编辑
摘要: score = int(input('分数: ')) if score >= 90: print('优秀') elif score >= 80: print('好') elif score >= 70: print('良') elif score >= 60: print('及格') else: print('你要努力了') 输出: 阅读全文
posted @ 2019-05-13 16:32 hejp 阅读(171) 评论(0) 推荐(0) 编辑
摘要: import random num = random.randint(1,10) # 随机生成1-10之间的数字。 answer = int(input('guess a number: ')) # 将用户输入的字符转成整数。 if answer > num: print('猜大了') elif answer < num: print('猜小了') else: pri... 阅读全文
posted @ 2019-05-13 15:41 hejp 阅读(98) 评论(0) 推荐(0) 编辑
摘要: import getpass # 导入模块 username = input('username: ') # getpass模块中,有一个方法也叫getpass password = getpass.getpass('password: ') if username == 'bob' and password == '123456': print('Login successful... 阅读全文
posted @ 2019-05-13 15:34 hejp 阅读(500) 评论(0) 推荐(0) 编辑
摘要: a = 10 b = 20 if a < b: smaller = a else: smaller = b print(smaller) s = a if a < b else b # 和上面的if-else语句等价的。 print(s) 输出: 阅读全文
posted @ 2019-05-13 14:58 hejp 阅读(231) 评论(0) 推荐(0) 编辑