##Demonstrate basic variable assignment x_int=3 x_int = x_int * x_int print(x_int) ####Notice that objects have types, but names don't ##x=3 ##print(x," of type ", type(x)) ##x="three" ##print(x," of type ", type(x)) ####Getting input from the user ##y = input("what is your name? ") ##print("hello, ", y) ####Input always returns a string ##y = input("enter a number: ") ##print(type(y)) ##print(y) ####Use a constructor to get numbers from the user ##y = input("enter a number: ") ##y_float = float(y) ##print(type(y_float)) ##print(y_float) ##print("the square of your number is ", y_float * y_float) ## class exercise 1 # Write a Tipping Calculator # You should prompt the user for a bill amount and a tip percentage # Display the tip amount and the total including tip ####Demonstrate formatting of strings ##tip = 23.425928 ##tip_sentence="The tip is ${:.2f}." ##print(tip_sentence.format(tip)) ####A couple more formatting examples ##print("Formatted wider: ${:10.2f}.".format(tip)) ##print("Wider and left justified: ${:<10.2f}.".format(tip)) ##tip_percent = 0.16 ##print("The tip percentage under default formatting is {} and as a percentage is {:.2%}.".format(tip_percent, tip_percent)) ####find more rules in the textbook, section 4.4 ####Class Exercise 2 ###prompt the user for several words ###insert the words into a few lines of text. ###You can write your own string, or use the string below. ##madlib_str="""Four {} and seven {} ago our {} ##brought forth on this {} a new {}, conceived ##in {}, and dedicated to the {} ##that all {} are created {}.""" ##print(madlib_str)