age_ip=eval(input(‘please input your age:‘))
if age_ip >= 18:
print("chengnian")
else:
print(‘yes‘)
== 检查两个值是否相等
!= <= >= < >
and 同真则真
or 有真则真
not 假则真,真则假
需求 根据分数 输出ABCD
sco=int(input(‘please input sco‘))
if sco < 60:
print(‘D‘)
elif sco < 75:
print(‘C‘)
elif sco < 85:
print(‘B‘)
else:
print(‘A‘)
<1>需求
? *
? **
? ***
? ****
index = 1
while index < 6:
i = 1
while i <= index :
print(‘*‘,end=‘‘)
i+=1
print(‘‘)
index+=1
<2>需求 9*9乘法表
index = 1
while index < 10:
i = 1
while i <= index:
print(i,‘x‘,index,‘=%d‘%(index*i),‘\t‘,end=‘‘,)
i+=1
print(‘‘)
index +=1
for i in range(0,3):
print(‘hello world‘)
str1=‘hello world‘
for i in str1:
print(i,‘hello world‘)
for c in ‘hello world‘:
print(c,end=‘\\‘)
for i in range(5):
print(i)
注意:range(start,stop,step)
for i in ‘hello world‘:
print(i,end=‘‘)
if i==‘ ‘:
break
else:
print(‘111111111111‘)
跳出整个循环后 else不执行
for i in ‘hello world‘:
#print(i,end=‘‘) #在if之后方可生效
if i == ‘ ‘:
continue
print(i,end=‘‘)
else:
print(‘‘)
print(‘ceshi‘) #continue之后能够显示else内容.
原文:https://www.cnblogs.com/zhouDEblogs/p/14413225.html