[Python] if statement

if statement

important point ・ **: ** after the conditional expression ・ Else if is ** elif ** ・ When the conditional expression is equal on the left and right, ** == **

if money > total_price:
    print("Apples" + str(count) + "I bought one")
    print("The balance is" + str(money - total_price) + "It's a yen")
elif money == total_price:
    print("Apples" + str(count) + "I bought one")
    print("The wallet is empty")
else:
    print("Not enough money")
    print("I couldn't buy an apple")

Conditional expression combination

and Satisfy both conditions

if time > 10 and time < 15:

or Either condition is met

if time == 10 or time == 15:

not Negation of conditions

if not time == 20:

Comparison operator

Unlike js, the number of = when the left and right are equal changes. image.png

Recommended Posts

[Python] if statement
Python basic if statement
Addition with Python if statement
Unfamiliar if statement
Python exec statement
[python] Correct usage of if statement
Python assert statement
[Python] File operation using if statement
[Introduction to Udemy Python3 + Application] 33. if statement
Python basics ② for statement
[Python] for statement error
Python list, for statement, dictionary
Python "if __name__ == ‘__main__’: ”means
Python
Julia quick note [05] if statement
[Python] if __name__ == What is'__main__' :?
A Java programmer studied Python. (for, if, while statement)
About 2-variable, 4-branch if statement
[Python / PyQ] 4. list, for statement
Why do you add a main ()-if statement in Python?
[Python] How to write an if statement in one sentence.
[Python] What is a with statement?
Summary if using AWS Lambda (Python)
exec, eval to execute [python] statement
python sql statement extracted by time
Create python directory Support if directory exists
Python for statement ~ What is iterable ~
if True> = False: Python "True" Go "What ???"
If Python 3.5.0 installation fails on Mac
[Python] Multiplication table using for statement
Difference in how to write if statement between ruby ​​and python
[Python] Basic pattern and usage of if statement (comparison operator and Boolean operator)
kafka python
Python basics ⑤
python + lottery 6
Python Summary
Built-in python
Python technique
[Python] Super easy test with assert statement
Studying python
Python 2.7 Countdown
Python memorandum
python tips
python function ①
Python basics
Python memo
ufo-> python (3)
install python
Python Singleton
Python basics ④
Python Memorandum 2
python memo
Python Jinja2
Python increment
atCoder 173 Python
[Python] function
Python installation
python tips
Installing Python 3.4.3.
Try python
Python iterative