Flashcards in Syntax Deck (10):
What is an Identifier
it is a name used to identify a variable, function, class, module or other object. An identifier starts with a letter A to Z or a to z or an underscore followed by zero or more letters, underscores and digits. Python is case sensitive.
Do class names start with an upper or lowercase letter
How do you form a multi line statement
This is done with the line continuation character ( \ )
total = item_one + \
item_two + \
How is quotation used in Python
Python accepts sing('), double(") and triple (''' or """) quotes to denote string literals, so long as the same type of quote starts and ends the string.
How are triple quotes used ( """ )
Triple quotes are used to span the string across multiple lines.
paragraph = """This is a paragraph. It is
made up of multiple lines and sentences."""
What does the hash sign do ( # )
The hash sign tells python to ignore that section of code.
How does Python handle a blank line?
Python ignores this whitespace
How do you allow for multiple statements on a single line?
The semicolon ( ; ) allows multiple statements on a single line given that no statement starts a new code block.
import sys; x = 'foo'; sys.stdout.write(x + '\n')
What are groups of individual statements called?
These are called suites. Compound or complex statements, such as if, while, for, def, and class require a header line and a suite.