Python学习之路-——chapter1:

今天的学习任务;

        1.安装了Python3.5;

        2.安装了Pycharm;

        3.了解了Python的基本用法;

#!/usr/bin/env python
#Author by Puppeteer_777

print ("Hello World !")  #It's my first python program;

#!/usr/bin/env python
#Author by Puppeteer_777

name = "lihua"          #name----->lihua
name1 = name            #nmae1----->lihua
print ("My name is",name)
print ("My name is",name1)
name = "wangming"       #name------>wangming

print ("My name is",name)
print ("My name is",name1)

#!/usr/bin/env python
# Author by Puppeteer_777

#输入
username = input ("username:")
password = input ("password:")

#输出
print ("username is",username,"password is",password)
#!/usr/bin/env python
# Author by Puppeteer_777
_username = 'Puppeteer_777'   #注意单引号
_password = '123456'    #注意单引号

username = input("username:")  #输入
password = input("password:")  #输入

print("username:",username,"password:",password) #输出

if _username == username and _password == password:  #逻辑判断
    print("Welcom !")    #####缩进##### 重点了解!!!!!
else:
    print("Invalid username or password")
#!/usr/bin/env python
#Author by Puppeteer_777
#猜年龄游戏

age_of_boy = 23             #初始年龄

count = 0                   #计数
while count < 5:            #计数
    guess_age = int(input("age:"))  #默认输入str,所以更改为int型;

    if guess_age == age_of_boy:
        print("you are right")
        break
    elif guess_age > age_of_boy:
        print("think smaller")
    else:
        print("think bigger")
    count+=1                #计数
else:
    print("You have tried too many times....")
#!/usr/bin/env python
#Author by Puppeteer_777

for i in range(2,5,1):    #左闭右开;循环从2开始,隔1个输出,到5结束,不包括5;
    print("loop:",i)
#!/usr/bin/env python
#Author by Puppeteer_777

for i in range(0,5):   # i = 0,1,2,3,4;
    if i > 3:
        print("loop:",i)
    else:
        continue
    print("i大于4;")

总结:学会输入输出,赋值,循环语句,break,continue,等





阅读更多
下一篇Python学习之路——chapter2{列表,字典,集合,str和文件操作}
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭