上一页 1 ··· 6 7 8 9 10 11 12 下一页
摘要: score = int(input('分数: ')) if score >= 60 and score = 90: print('优秀') else: print('你要努力了') 输出: 阅读全文
posted @ 2019-05-13 16:35 hejp 阅读(151) 评论(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 阅读(191) 评论(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 阅读(104) 评论(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 阅读(519) 评论(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 阅读(235) 评论(0) 推荐(0)
摘要: 单个的数据也可以作为判断条件。 任何值为0的数字,空对象都是False,任何非0数字,非空对象都是True。 阅读全文
posted @ 2019-05-10 16:22 hejp 阅读(206) 评论(0) 推荐(0)
摘要: # 字典是key-value(键 - 值) 对形式,没有顺序,通过键取出值 adict = {'name':'bob','age':30} print(len(adict)) print('bob' in adict) # False print('name' in adict) # True print(adict) adict['email'] = 'aaa@qq.com' adict[... 阅读全文
posted @ 2019-05-10 16:11 hejp 阅读(159) 评论(0) 推荐(0)
摘要: 元组与列表基本上是一样的,只是元组不可变,列表可变。 阅读全文
posted @ 2019-05-10 16:02 hejp 阅读(138) 评论(0) 推荐(0)
摘要: 列表也是序列对象,但它是容器类型,列表中可以包含各种数据。 阅读全文
posted @ 2019-05-10 15:58 hejp 阅读(177) 评论(0) 推荐(0)
摘要: 在Python中,单双引号没有区别,表示的含义是一样的。 sentence = 'tom\'s pet is a cat' # 单引号中间还有单引号,可以转义。 sentence2 = "tom's pet is a cat" # 也可以用双引号包含单引号。 sentence3 = "tom said:\"hello world!\"" sentence4 = 'tom said:"hell... 阅读全文
posted @ 2019-05-10 15:38 hejp 阅读(147) 评论(0) 推荐(0)
上一页 1 ··· 6 7 8 9 10 11 12 下一页