""" CS 101 - Homework 1 @author: YOUR NAME HERE Lab: YOUR LAB SECTION HERE (W, X, Y, or Z) """ """ 1. Python code to produce the following output: 0: 0 1: 1 2: 2 3: 3 4: 4 5: 5 The initial number and colon can be text (i.e., in quotes), but the second copy of the number must be the result of an evaluated Python expression. This expression can use any of the arithmetic operators and parentheses. The challenge is that the only number we can use is the number 4. In addition, we use 4 (and only 4) of them. The first line is given as an example. """ print("0:", 4 + 4 - 4 - 4) # YOUR CODE HERE """ 2. According to xkcd (https://xkcd.com/314/), the 'standard creepiness rule' states that it is creepy to date someone under half your age plus seven. We calculate the youngest and oldest one could date without violating this rule, and store these ages in variables lowerAge and upperAge respectively. Some initial code and a print statement to report the result is given. """ # the float() function here converts the string input to a floating point number age = float(input('Enter your age: ')) # YOUR CODE HERE print('Your dating pool stretches from',lowerAge,'to',upperAge) """ 3. We are given a quantity of cups. We want to distribute these to have the fewest number of containers, but we do not want to waste space by not filling a container. The containers we have come in gallon, quart, pint, and cup size. The last line (provided below) will print out the contents of variables named gallons, quarts, pints and cups. Example: the user has entered 5 as the number of cups. We would report 0 gallons, 1 quarts, 0 pints, 1 cups Challenge: The extra 's' on the end of the labels look weird when a quantity is 1. Can you fix this? [It cannot be fixed using just what we have seen in class so far so this will take some research] [Hint: integer division and the % operator will be very useful in this problem.] """ # note we use the int() function to convert the string input to an integer so we can treat it as a number userCups = int(input('Enter the number of cups: ')) # YOUR CODE HERE print(gallons,'gallons,',quarts,'quarts,',pints,'pints,',cups,'cups') """ 4. Practice with strings The strings to print are: fireman banana romana time lord man down to be or not to be """ str1 = 'gallifrey' str2 = 'cyberman' str3 = 'doctor who' # fireman print(str1[5] + str1[4] + str1[6:8] + str2[5:]) # YOUR CODE HERE