1/4
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Output with print()
Use to display text or variables
Combine text and variables with commas
Customize output with or blank lines
Input with input()
input()
gets user input as a string
Wrap with int()
or float()
to convert to numbers
Example: age = int(input("Enter age: "))
Expressions and Operators
Arithmetic: +
, -
, *
, /
Exponentiation: **
Integer division: //
Modulus (remainder): %
Operator precedence follows math rules (PEMDAS)
Assignment Statements
Assign values with =
Reassign variables anytime
Swap values: x, y = y, x
Simultaneous assignment is allowed
Definite Loops with for
Loop runs a fixed number of times
Use range(n)
for counting
Loop variable can be named or _
if unused
Example: for _ in range(3): print("Repeat")