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,等





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值