流程控制之if判断

1.什么是if判断微信

       判断一个条件若是成立则作...不成立则作...spa

2.为什么要有if判断code

       让计算机可以像人同样具备判断的能力input

3.如何用if判断语法

'''计算机

#语法1:co

'''if判断

if 条件1:

    code1

    code2

    code3

    .......

'''

age=18

if age != 18:

    print('你好啊小伙子')
    print('加个微信吧...')

print('other code...')

 

# 语法2:

 

if 条件:

    code1

    code2

    code3

  ......

else:

    code1

    code2

    code3

    ......

#

age=22

sex = 'male'

x='dd'

is cool = True

 

if age>16 and age<25 and\

x='dd' and is cool:

    print('你好')

else:

    print('再见')

 

# 语法3

 

 if 条件1:

    if 条件2:

        code1

        code2

        code3

    code2

    code3

      .......

 

age = 18

sex = 'hemale'

shencai = 'good'

is_beautiful = True

is_rich = True

 

 

if age >16 and age< 25 and sex = 'hemale'\

and shencai = 'good' and is_beautiful:

    print ('表白')

    if is_rich: 

        print('在一块儿')

    else:

        print('你是谁')

else:

    print('8888888')

 

 

# 语法4

if 条件1:

        子代码块1

elif 条件2:

        子代码块2

elif 条件3:

        子代码块3

elif 条件4:

        子代码块4

.............

else:

        子代码块5

 

#

score = input('your score:')

score = int(score)

if score >= 90:

    print('A')

elif score >= 80:

    print('B')

elif score >= 70:

    print('C')

else:

    print('laji')

相关文章
相关标签/搜索