Python入门(简明Python教程)——丑

运算符和表达式

  1. **是乘方
  2. //是整除
  3. not是布尔“非”
  4. and是布尔“与”
x=True
y=not x
print('{}'.format(y))
print('{}'.format(not (x and not y)or x))
#结果
False
True

5.运算优先级

python左至右结合

控制流与逻辑结构

  1. elif else
  2. 冒号的应用
  3. for循环(首项,尾项,步长)
    number=23
    guess=int(input('Enter	an	integer	:	'))
    if	guess==number:
        print('Congratulations,	you	guessed	it.')
        print('(but	you	do	not	win	any	prizes!)')
    elif	guess<number:
        print('No,	it	is	a	little	higher	than	that')
    else:
        print('No,	it	is	a	little	lower	than	that')
    print('Done')
    
    
    
    for i in range(1,5):
        print(i)
    else:
        print('The	for	loop	is	over')
    
    
    for i in range(1,5,2):
        print(i)
    else:
        print('The	for	loop	is	over')

    结果:

    list(range(1,5))
    [1, 2, 3, 4]

     

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值