Operators behave differently depending on the type:
"u"+"m"+"d"
umd
"umd "*5
umd umd umd umd umd
What are Statements?
Statements are the most basic units of executable Python code.
A Python program is a series of statements executed in order.
Try these statements to input and print a variable:
username =input("Enter your name: ")print("Hello", username)
What are Conditionals?
In practice, you often do not want every statement in a program to be executed every time.
Instead, you want your program to execute depending on the logical state of data or input when your program is running.
The basic building blocks for this logic are conditionals, which are constructed with the keywords if, else and elif.
Structure of Conditionals
if1>0:print("yes")else:print("no")
yes
Practice with Conditionals
order =input("What can I get you? ")if order =="burger": side =input("Would you like fries? ")elif order =="salad': side = input("What kind of dressing? ")else: print("We only sell burgers and salads.")print("You ordered:", order, side)
So …
We’ve covered a lot but now you know the basic buiding blocks of all Python programs, and imperative programming languages in general: