Week 3 · Session 1
Lab 1 questions & the parts of a repository that are not Python.
Read the last line of the error first. It names the problem.
ValueError: invalid literal for int(): you gave int() something that is not a number, often a piece with a stray space in itTypeError: can only concatenate str (not "int") to str: you joined a number onto a string. Convert firstValueError: not enough values to unpack: the left side of mm, dd, yyyy = ... wants exactly three pieces and got a different numberKeyError: 0: get_anchor_day received a month of 0, so a placeholder above it was never replacedRun through these in order before you ask anyone for help.
print(mm, dd, yyyy) show three pieces that look rightmonth, day and full_year integers, or still strings2026, does century hold 20 and decade hold 2611-25-2026: Wednesday, colon and one space includedFix the two lines so they print 20 26.
100. One keeps what division throws away1999 and confirm you get 19 99Session 1
Lines Python ignores, written for the humans reading your code.
# starts a comment. Everything after it on that line is skipped when the program runs# TODO: lines in main.py are comments. They are instructions to you, not codedecade = full_year % 100 # 2026 becomes 26#. That is the spacing Python programmers expect to see# add one to count above count = count + 1 says nothing the code did not already say# a leap year adds an extra day explains something the code cannot say for itselfmain.py is a docstring. Put your name on its Author: line# TODO: once you have done it. A file still full of them reads as unfinishedRun it. Fix line 3. Then comment out line 2 and add a line of your own.
Session 1
The other file you edited in lab: docs/summary.md.
.md file is plain text plus a few punctuation marks that mean formattingdocs/summary.md are written in markdown tooClick Preview to see what this becomes. Then click Write and change it.
Replace the first TODO with a real two-sentence answer, then Preview.
> blockquote, and the word TODO under it is the placeholderThe box on the last two slides is a demonstration. Here is where you do it.
.md file and press Cmd+Shift+V on a Mac, Ctrl+Shift+V on Windows.md file is already rendered when you view it in the browserWeek 3 · Session 2
Joining them, repeating them, and converting into and out of them.
Session 2
"Good" + "bye" gives "Goodbye". No space appears unless you put one there yourselffirst + " " + last is how two names become "Ada Lovelace"+ between two numbers adds. + between two strings joins. Same symbol, and the types decide which job it does"Room " + 101 is an error. "Room " + str(101) gives "Room 101"Run it first. Line 3 prints but is wrong, and line 6 crashes.
room with str()Session 2
"ha" * 3 gives "hahaha". A string times a whole number repeats it"=" * 50 gives a line of fifty equals signs, which is how a banner line gets printed"ha" * "3" is an error. The count has to be an int, not a stringRun it, fix the last line, then change every 10 to 24 and run it again.
"Room " + 101 did, in the other directionSession 2
All three are correct Python. They differ in how much you have to track yourself.
print("Total:", total): commas, and Python puts a space between each piece for youprint("Total: " + str(total)): joining, so every character is yours, including that spaceprint(f"Total: {total}"): an f-string, which converts for you and keeps the text readableFill in all three so each prints: notebook costs 3 dollars
str(). Work out which, and whySession 2
int("26") gives 26. str(26) gives "26". float("3.5") gives 3.5int("3.5") is an error. Go through float first: int(float("3.5")) gives 3input() always hands back a string, so a number the user typed always needs convertinglen("Lovelace") gives 8, the number of characters, and that is an int you can do arithmetic onBefore Lab
uv run gatorgrade --config gatorgrade.yml from the top folder of your repository, not from inside srcdocs/summary.md. It is graded, it is markdown, and it takes one preview to checkgit add ., then git commit -m "message", then git push. Nothing counts until it is on GitHubIn Lab Today
Code reviews first. Then this, and it uses everything from the last two weeks.
+ and str(), the product with an f-string. Same text, three ways, on purpose