''' Purpose: demonstrate the processing numeric input ''' # get input # remember input gives you a string of what the user types # reply is a string reply = input( 'Enter rectangle width and height: ' ) # we have two numbers in a string we cant use them this way # every string has a split function; it splits the string int a list of strings # this splits on spaces so the first number we type will go into w and the # second will go into h # split into two components ( cant do more or less than 2 or error) # split is not a built in function it is a behavior of strings w, h = reply.split() # we will learn how to split on something other than spaces later print( w, type( w ) ) print ( h, type( h ) ) # still strings so w and h are glued together rather than numerically added s = w + h # s is a string print( s, type( s ) ) # we want them to be numbers! # cast them to int # must convert list of numbers one at a time # w, h = int(w, h) # int wants one thing that can be converted into an integer # w, h = int( reply )# wont work cuz reply isn't split and int can only work on one value at a time w, h = int( w ), int( h ) # int converts strings (that can be ints) into integers print( w, type( w ) ) print ( h, type( h ) ) # compute area area = w * h # display result print( area )