# Name: Example Solutions # homework_1_sol.py ##### Template for Homework 1, exercises 1.2-2.1 ###### print "********** Exercise 1.3 **********" # Do your work for Exercise 1.2 here ## The pipe (straight vertical line) is on the right-hand side of ## your keyboard, above the enter key. Make sure that you put quotes ## around non-variables when printing. print " | | " print "--------" print " | | " print "--------" print " | | " print "********** Exercise 1.4 **********" # Do your work for Excercise 1.3 here. Hint - how many different # variables will you need? ## Make sure that you name your variables clearly! We saw a lot of variables ## with names like a, b, line1, and line2. Use something more descriptive. ## First, I'm creating two variables to represent the two different lines. ## The spaces around the "=" make things easier to read. pipes = " | | " hyphens = "--------" ## Now, I just want to print them out as in Exercise 1.2. print pipes print hyphens print pipes print hyphens print pipes print "********** Exercise 2.1 **********" # Do your work for Exercise 2.1 here. ## Get the first and last name of the user. Notice my use of CamelCase -- ## capitalizingTheBeginningOfWordsInVariableNames -- which makes things ## easier to read. Note that the first letter should be lowercase (we'll ## learn why later). firstName = raw_input("Please enter your first name: ") ## There's an extra space after the colon but before the " to make sure ## that the user's response isn't right on top of the text. Not necessary, ## just legibility/good practice. lastName = raw_input("Please enter your last name: ") ## Next line doesn't collect input, so I'm just using "print" print "Enter your date of birth:" month = raw_input("Month? ") day = raw_input("Day? ") year = raw_input("Year? ") # Print all the information out on one line print firstName, lastName, "was born on", month, day + ",", year + "."