s13day1第一堂课

s13day1第一堂课
python基础知识总结如下:
1、变量的命名,只能是字母、数字和下划线的组合
(两种规范驼峰写法和下划线,我觉得下划线写法更好看!!!)

2、import 用来引入模块
比如引入sys模块,查看当前python的全局环境变量

import sys
print(sys.path)

3、判断语句
if elif else 后面以冒号结尾连接下一行 严格的缩进(4个空格)
几个例子:

###guess age
counter = 0
age = 28
for i in range(10):
    if counter < 3:
        print("------>counter",counter)
        guess_num = int(input("input your guess num:"))
        if guess_num == age :
            print("Congratulations! you get it!")
            break
        elif guess_num > age:
            print("think smaller!")
        else:
            print("think big!")
    else:
        continue_confirm = input("Do you want to continue play?")
        if continue_confirm == 'yes':
            counter = 0
            continue
        else:
            print("bye")
            break
    counter += 1

猜你喜欢

转载自blog.51cto.com/20has/2130011