''' Purpose: demonstrate int and float numeric input processing ''' # get inputs x_reply = input( 'Enter base (integer): ' ) # x_reply stores our base int from user n_reply = input( 'Enter exponent (decimal): ' ) # n_reply stores our exponent float from user # BUT REMEMBER, input() gives us back strings!!! NOT numbers!!!! # print( 'type of x_reply is', type( x_reply ) ) # type(x) is a function that tells you what type x is # print( 'type of n_reply is', type( n_reply ) ) print() # convert inputs to numerics x = int( x_reply ) # cast string x_reply to get an int n = float( n_reply ) # cast string n_reply to get a decimal # int(x): x must be an int, float, or an integer numeric string # has to be direct conversion # if x is a string like '3.8' --> will fail # compute x to the nth power value = x ** n # We have to convert our replies into numeric types (int, float) to do exponentiation # otherwise, cannot do this with strings # display result print( value )