Week 3: Python Basics & Control Flow
=
).variable_name = value
.snake_case
for variable names in python (e.g., first_name
, user_age
). Names should be descriptive.str
(string): used for text. enclosed in single ('
) or double ("
) quotes.int
(integer): used for whole numbers.float
(floating-point): used for numbers with a decimal point.bool
(boolean): used for True
or False
values.input()
function.input()
function always returns the data as a string.int()
or float()
.input()
to ask the user for nouns, verbs, and adjectives.print()
with an f-string to plug their words into a story.if
if
, elif
(else if), and else
keywords to control which blocks of code are executed.for
loop: use this when you want to do something for every item in a collection.while
loop: use this when you want to keep doing something as long as a certain condition is true.while
loop to keep the game running until the user guesses correctly.if/elif/else
statements to tell the user if their guess is too high, too low, or correct.pytest
pytest
is a popular Python framework for writing tests.test_
(e.g., test_lab03.py
).test_
(e.g., def test_...():
).pytest
testassert
keyword is the core of the test.assert
is True
, the test passes. If it’s False
, the test fails.pytest
every single time you git push
your code..github/workflows/main.yml
.on: [push]
: “Run this workflow every time someone pushes code.”runs-on: ubuntu-latest
: “Spin up a fresh, new virtual computer running Linux.”steps:
: “Then, follow these steps in order:”
pytest
library.pytest
command.pytest
and continuous integration with github actions.labs/lab03/README.md
for full instructions.IS4010: App Development with AI