码迷,mamicode.com
首页 > 其他好文 > 详细

FirstDay

时间:2017-09-19 22:55:34      阅读:271      评论:0      收藏:0      [点我收藏+]

标签:range   time   style   class   年龄   eth   none   string   技术   

*print some lines

info = ‘‘‘

you can write something you like

‘‘‘

print(info)

*python is not like java in most ways,no "{}" in java ,just 4 ‘    ‘

*circle symbol

-*-if

 

 1 _username = oscar
 2 _password = 123456
 3 username = input("username:")
 4 password = input("password:")
 5 print(username,password)
 6 
 7 if _username == username and _password == password:
 8     print("Welcome user {name} login ...".format(name =username))
 9 else:
10     print("Invalid User")

 

 

 

 1 _username = oscar
 2 _password = 123456
 3 username = input("username:")
 4 password = input("password:")     
 5 print(username,password)
 6 
 7 if _username == username and _password == password:
 8     print("Welcome user {name} login ...".format(name =username))
 9 else:
10     print("Invalid User

-*-interactor

 1 name = input("name:")
 2 age = int(input("age:"))
 3 job = input("job:")
 4 salary = input("salary:")
 5 info = ‘‘‘
 6 -------info of %s --------    
 7 Name :%s
 8 Age :%d
 9 Job :%s
10 Salary :%s
11 ‘‘‘%(name,name,age,job,salary)
12 #%d number
13 # %s   string
14 #print (info)
15 
16 info2 = ‘‘‘
17 -------info of {_name} --------    
18 Name :{_name}
19 Age :{_age}
20 Job :{_job}
21 Salary :{_salary}
22 ‘‘‘.format(_name=name,
23            _age= age,
24            _job= job,
25            _salary=salary)
26 
27 print (info2)

*-*while

 1 username = oscar
 2 userage = int(40)
 3 count = 0
 4 while True:
 5     if count = 3:
 6         break
 7     guess = input("guess age :")
 8     if guess == userage:
 9         pirnt("good boy!")
10     elif guess > userage:
11         pirnt("he is yonger!")
12     else:
13         pirnt("he is older!")
14     count +=1
15     if count ==3:
16         print("You have tried too much times")

-*-猜年龄小游戏

 1 youname = int(55)
 2 count = 0
 3 while True:
 4     if count == 3:
 5         confirm = input("do you want try again?")
 6         if confirm != n:
 7             count = 0
 8     guess = int(input("guess age:"))
 9     if guess == youname:
10         print("Good job!")
11         break
12     elif guess > youname:
13         print("He is smaller!")
14     else:
15         print("He is older!")
16     count += 1

-*-   for

for a in range(0,9,2):     # 

    print (a)

 

FirstDay

标签:range   time   style   class   年龄   eth   none   string   技术   

原文地址:http://www.cnblogs.com/PurpleSun/p/7553959.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!