CS106 Summer 2026 Michael Eckmann Lab 01 July 01, 2026 ================== Purpose: To get more familiar with using idle for creating and running Python programs. To write programs that print to the screen. To understand some of the syntax errors that will be encountered. To get familiar with if/else, user input, variables, etc. ================== I suggest doing the following first: after you login to a linux machine, open a terminal window to make a new folder type: mkdir cs106 and then hit enter then to change into that folder type: cd cs106 and then hit enter then type: idle3 & and then hit enter then do File -> New File for each of these problems and File -> Save and type a name with .py extension and save to the cs106 folder ================== 1. Write a program that prints the poem: Roses are red Violets are blue Sugar is sweet And so are you save it in poem.py If you wrote that program using 4 print calls, write another program using just one print call and save it in poem2.py (if you wrote it with one print the first time, then write it with 4 prints the second time) 2. Write a program that asks the user for two numbers and then prints exactly one of the following: The first number __ is larger than __ The second number __ is larger than __ The two numbers __ and __ are equal where you replace the __ with the actual numbers entered by the user I require you to use if, elif, and else save your program in numcompare.py Test out your program enough so that you get each message to print 3. Get experience with some syntax errors: start from the following code: age = 21 print('your age is', age) and make the following changes and run the code each time and read the error that python displays to see if it makes sense. Also, always start from the original before you make a change --- that is do not keep the changes made earlier: 1. change print to prnt 2. change the age after the , in the print to Age 3. change the print to: print('your age is age') 4. remove the last ' in the original print 5. remove the first ' in the original print 4. age = 21 if age >= 21: print('21 or over') if age < 18: print('less than 18') else: print('18 or over') Read the code and write down a guess as to the output. Then do File->New File enter the code and save it as iftest.py Then run the code and even if you guessed correctly, explain why it worked that way. Expected output: Actual execution output: Explanation (your understanding of why it behaved the way it did): 5. Now if you replace age = 21 with age = 18 what would happen? Expected output: Actual execution output: Explanation (your understanding of why it behaved the way it did): 6. Write a program named average.py that asks the user for 3 numbers (1 at a time) and prints out the following sentence as close as you can to this (if 12.3, 77, and 13 are the numbers the user entered): You entered 12.3, 77, and 13 The average of those numbers is 34.1 ======================================================== Show me the code for these when you are done: poem.py poem2.py numcompare.py iftest.py average.py