您好,登錄后才能下訂單哦!
1、小程序
實現用戶交互,引號,判斷用法,變量實現。
[root@node1 day1]# cat jiaohu.py
#!/usr/bin/env python
#!coding:utf-8
name = raw_input('what your name?: ')
age = raw_input('how old are you?: ')
sex = raw_input('what your sex?: ')
job = raw_input('what is yout jobs?: ')
msg = """
Infomation of commpany staff:
Name : \033[42;1m%s\033[0m;
Age : %s
Sex : \033[31;1m%s \033[0m;
Job : %s
""" %(name, age, sex, job)
if int(age)>50:
print "You too old, you can onlu work ..."
elif int(age)>30:
print "you are in middle age, go on ..."
else:
print 'you still very young ...'
print msg
[root@node1 day1]#
2、while循環練習
[root@node1 day1]# cat whilet.py
#!/usr/bin/env python
#!coding:utf-8
i = 0
while True:
i = i + 1
if i == 5:
print 'I have got to the 50th'
continue
elif i>9:break
print i
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。