@extends('template') @section('title') Lab 1: Part 3: Text in boxes and Codder @stop @section('content') # Lab 1: Part 3: Text in boxes ## Overview In this task, you will write a short python program that asks the user to provide a string, and then prints a box of asterisks (*) around the string. Below are three different runs of your program: Sample 1: ```py Enter a string ==> Hi ************** * Hi * ************** ``` Sample 2: ```py Enter a string ==> Lovely day today **************************** * Lovely day today * **************************** ``` Sample 3: ```py Enter a string ==> Sometimes you feel like a nut ***************************************** * Sometimes you feel like a nut * ***************************************** ``` ## Task A: Get comfy with `input` The python built-in function `input` allows you to ask the user for input. Try this: ```py input('Type your name') ``` Note: you can add an arrow to the prompt, if you like: ```py input('Type your name ==>') ``` Let's say the user types `Selena`. In order to refer to `Selena` later in your program, you'll need to save it in a variable. ## Task B: Draw a box around the user input Let's take another look at one of our examples from above: ```py Enter a string ==> Sometimes you feel like a nut ***************************************** * Sometimes you feel like a nut * ***************************************** ``` There should be 5 spaces of padding on either side of the string in the box (see enlarged image below). Note that your program should work correctly regardless of the length of the provided string. ## Task C [OPTIONAL]: Draw a box around TWO user inputs In this task, the user is asked TWICE to provide strings. Your program will produce a box around both lines of text, with 5 spaces of padding around the longer string in the box. See examples below. Example 1: ```py Enter your first string ==> happy Enter your second string ==> birthday to you! **************************** * happy * * birthday to you! * **************************** ``` Example 2: ```py Enter your first string ==> Row row row your boat Enter your second string ==> gently ********************************* * Row row row your boat * * gently * ********************************* ``` Example 3: ```py Enter your first string ==> Sometimes you feel like a nut Enter your second string ==> Sometimes you do not ***************************************** * Sometimes you feel like a nut * * Sometimes you do not * ***************************************** ``` ## Task D: Get acquainted with Codder In this course we use a Python program called **Codder** that helps test and give you feedback on your code. *Hat tip to the developers of Codder — Ben Wood, Franklyn Turbak and Scott Anderson.* Starting with ps01, Codder will be used to help verify your problem set code is running as expected. You will upload your file to the server (via a web interface), and Codder will test for the most common cases and expectations, but it might not be comprehensive. Codder checks the results of your code— it does not provide feedback for design or [code style](/styleguide). In short: Codder is there to help you reach the correct solution, but you are responsible for your code and you should always “cross your t's & dot your i's” when it comes to testing and checking work before submission. In this part of today's lab, we want to demonstrate how to use Codder so you're familiar with it for the problem sets. We'll use our `textboxes.py` file from the previous task as an example. ## Procedure 1. Go to [cs.wellesley.edu/codder](http://cs.wellesley.edu/codder). You should see this page:
2. Click on the "Please authenticate first" link. This will bring you to the Wellesley login page. Log yourself in using your Wellesley gmail credentials. You must be officially registered in the class for this to work. 3. After you login, you should see this page:
4. Click on the "Choose an activity" button and select `lab01` from the drop-down menu. 5. Click on the "Choose File" button and select your `textbox.py` file from your `lab01` folder on your Desktop. 6. Click on the "submit file" button. 7. If your code passes the three test cases, you will see something like this:
8. Click on the light blue question mark "?" to expand the feedback about each test. Below, we show what happens when test case 1 is expanded (clicking on the question mark toggles the feedback opened and closed):
9. **What if** your code does not pass the test cases? Then you might see something like this:
10. Click on the light blue question mark to expand the feedback:
11. Note the peach highlighting indicates extraneous text in the output. You might see different text, or text missing in yours if there is an error. This feedback will hopefully give you an idea of what needs to be fixed in your code. __You may run Codder as often as you like__, the results are solely for your consumption. ## Troubleshooting Things to check if Codder is not running as expected: + If you are not officially registered in the course, Codder will not work for you at this time. + Confirm your file name **exactly** matches what is in the problem set instructions. Case matters, so if the instructions say `textBoxes.py` but you name your file `textboxes.py`, you will run into problems. ## Required for every problem set: `honorcode.py` Part of your problem set submission includes editing a file called `honorcode.py`. There is a sample in your `lab01` folder. Open `lab01/honorcode.py` and fill in the requested info. As an example, here's a completed `honorcode.py` file if President Johnson worked with Dean Velenchik: @include('/labs/lab01/_toc') @stop