Python Flashcards
F-strings
Formatted strings in python. Use the curlies {} as a placeholder for variables.
Syntax: f”This is a string. This is an {object}.”
Data Types
Python stores data in different types. For e.g., text is stored in strings, numbers are stored in integers or floats. Booleans are used to represent True or Flase.
Boolean Operators
There are operations in python that evaluate to a Boolean. E.g.: =, <, >, >=, 1=, <=, …
3 + 3 == 6 evaluates to True.
If/Else Conditions
If/else conditionals always start with an if block, everything else is optional. To chain them together, use elif until the last else block.
Syntax:
if (conditional):
—-body of the if block
What is the assignment operator in Python?
To assign values to an object, use the equal sign. The label goes on to the left, and the value goes on the right. Example:
> name = cool
Function
Single input with one output