Python
Code - 1
hrs = input("Enter Hours:")
rate = input("Enter Rate:")
pay = float(hrs * rate)
print("Pay:", pay)
Code - 2
hrs = input("Enter Hours:")
rate = input("Enter Rate:")
pay = float(hrs) * float(rate)
print("Pay:", pay)
While executing the Code - 1 I'm getting the following error - "TypeError: can't multiply sequence by non-int of type 'str' on line 5" but the Code - 2 is completely fine and running. I just want to know that is there really any difference between these 2 codes? If yes, then what is it? (I'm a novice who just started with programming )