CMPSC 100 Computational Expression
Introduction to Python programming fundamentals
defExamples:
You can name variables almost anything, but:
❌ Cannot start with numbers:
✅ Can contain letters, numbers, underscores:
❌ Cannot use Python keywords:
Balance descriptive and easy to type:
Python variables can hold different types of data:
int: Integer numbersfloat: Decimal numbersstr: Text (string)bool: True or Falselist: Collection of itemsExamples:
Use # to create single-line comments:
Use triple quotes for multi-line comments:
Think of variables as containers or labeled boxes that hold values:
print() to display outputExample:
How Python reads your code
Python executes code line by line, from top to bottom:
Complete output:
5
7
9
main() function for your program’s main logicExample:
Comments
#""" ... """Examples: