摘要:
import random all_choices = ['石头','剪刀','布'] computer = random.choice(all_choices) player = input('请出拳: ') print('Your choice:', player, "Computer's choice:", computer) # 另外一种写法: # print("Your choic... 阅读全文
摘要:
score = int(input('分数: ')) if score >= 60 and score = 90: print('优秀') else: print('你要努力了') 输出: 阅读全文
摘要:
score = int(input('分数: ')) if score >= 90: print('优秀') elif score >= 80: print('好') elif score >= 70: print('良') elif score >= 60: print('及格') else: print('你要努力了') 输出: 阅读全文
摘要:
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... 阅读全文
摘要:
import getpass # 导入模块 username = input('username: ') # getpass模块中,有一个方法也叫getpass password = getpass.getpass('password: ') if username == 'bob' and password == '123456': print('Login successful... 阅读全文
摘要:
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) 输出: 阅读全文