python if-else-example.py

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python if-else-example.py相关的知识,希望对你有一定的参考价值。

#if-statements
var=10
var1=0
if var:
    print("Value of var is "+str(var))
if var1:
    print("Value of var1 is " +str(var1))

#if-else statements
if var1:
    print("Value of var1 is not equal to zero")
else:
    print("Value of var1 is equal to zero")

#Nested-if
if var<50:
    print("Value of var is less than 50")
    if var==30:
        print("Which is 30")
    elif var==10:
        print("Which is 10")
    else:
        print("Which is not either 10 or 20")
elif var>50:
    print("Value of var is more than 50")
else:
    print("Couldn't find value of var")

以上是关于python if-else-example.py的主要内容,如果未能解决你的问题,请参考以下文章

001--python全栈--基础知识--python安装

Python代写,Python作业代写,代写Python,代做Python

Python开发

Python,python,python

Python 介绍

Python学习之认识python