range(0, 5)
CSCI 1012
last_digit.pypizza_party.pyodd_string.py.zip with all the .py files
check_even.py vs. checkEven.pydef check_even(x): vs. def check_evens(x):1 2 3 vs. 1 2 3Read your autograder output!
while loopfor loopTrue and Falseif statementselifelseValues:
False
x == 3 is an expressionFalsey is assigned FalseTrue
True
False
True
False
False
ifelifelseand executes if both sides are Trueor executes if either side is Truenot “flips” the truth valuex will be an integerTrue if x’s last digit is 0 or 1
Falsewhile loopif statement:
Truewhile loop:
Truewhile5
while loops need a “stopping condition”while looppizza_party.py
True if one pie can be equally shared by the number of peoplepeople can equally share the slices
pizza_party(2) returns 1pizza_party(6) returns 3pizza_party(5) returns 5for loopwhile loop:
while loop has “indeterminate” number of iterationsrangerange in Python is a special “collection”
range functionrange(0, 5)
range with for loop0
1
2
3
4
for Loopodd_string.py
odd_string(5) should return "1 3 5"odd_string(8) should return "1 3 5 7"Reading: Think Python Chapter 6
Homework 5 due Sunday, 28 Sep 11:55 PM