intro to programming - syntax from chp 2

0.0(0)
studied byStudied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/4

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 6:33 PM on 10/10/25
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

5 Terms

1
New cards

Output with print()

  • Use to display text or variables

  • Combine text and variables with commas

  • Customize output with or blank lines

2
New cards

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: "))

3
New cards

Expressions and Operators

  • Arithmetic: +, -, *, /

  • Exponentiation(2 ** 5/ two to the power of 5): **

  • Integer division(removes reminader): //

  • Modulus (remainder): %

  • Operator precedence follows math rules (PEMDAS)

4
New cards

Assignment Statements

  • Assign values with =

  • Reassign variables anytime

  • Swap values: x, y = y, x

  • Simultaneous assignment is allowed

5
New cards

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")