6.3 Inline IF Flashcards
1
Q
What is an inline F statement?
A
It is a simpler form of an IF statement and is more convenient if you need to perform a very simple task.
2
Q
What’s the syntax for inline F statement?
A
do Task A if condition is True else do Task B.
3
Q
Write the script for inline F function.
A
userInput = input (“Enter 1 or 2:”)
print(“This is task A” if userInput == “1” else “This is task B”)