""" Authors: Peter Mawhorter Consulted: Date: 2021-9-5 Purpose: SOLUTION for Lab01 First Program """ # Note: this file contains lots of different examples from the lab, but # all of them except the last one are disabled ("commented out") using # '#' signs (just like these lines of text, which we call a "comment"). # You an remove the '#' signs (and any leading spaces) to re-enable # specific lines to see what they do. Thonny has a shortcut for this: # select the lines, and press control (or command on a mac) plus the 3 # key. # First example program # x = 1 + 2 # y = x + 4 # print("x + y is:") # print(x + y) # Example for working with strings # name = 'Peter' # print("Welcome to CS111, " + name) # Example of repeating a string # print("HA" * 8) # Example of using input # name = input("What is your name? ") # print("Hi, " + name) # Example of simplifying function results # result = input("First number: ") + input("Second number: ") # print("The result is: " + result) # Underline program string = input("Enter a string: ") print(string) print('-' * len(string)) # Here's another way to achieve the same thing, using more variables # string = input("Enter a string: ") # length = len(string) # underline = '-' * length # print(string) # print(underline)