x = input("Guess a number: ") == 7 print(x) x = input("Guess a number: ") == '7' # compare string and string print(x) x = int(input("Guess a number: ")) == 7 # compare int and int print(x) # what data type does the input() function return? # how does == work? # when should you do casting? # --------------------------------- # y = 12 z = y ** 2 print(z, type(z)) z = y ** 2.0 print(z, type(z)) z = float(y) print(z, type(z)) z = str(y) print(z, type(z)) z = y / 5 # natural division, always result in float print(z, type(z)) z = y // 5 # integer division print(z, type(z)) z = y % 5 # remainder print(z, type(z)) print(max("frog", "gorf")) print(max(9, 9.0)) print(len("frog")) # print('len of int = ', len(9)) # What is wrong? # print('len of float = ', len(9.0)) # What is wrong? print('len of string = ', len(str(9))) print(int(12.5)) print(int('12')) # print(int('12.5')) # What is wrong? print(int(float('12.5'))) # int(...string...) works if string looks like int # float(...string...) works if string looks like float