Code Challenge 3
Code Challenge:
Conduct this experiment. Run the following program to see what happens. Note your observations so that you can revisit them when you learn about data types.
a = input("Enter any number: ")
b = input("Enter any number: ")
print(a+b)
Clue: You will find the answer very surprising... a and b are not added but joined or concatenated. This is because by default, an input is always treated as non-numeric in Python even if it contains digits. You will learn all about numeric and non-numeric datatypes in the next module.
Conduct this experiment. Run the following program to see what happens. Note your observations so that you can revisit them when you learn about data types.
a = input("Enter any number: ")
b = input("Enter any number: ")
print(a+b)
Clue: You will find the answer very surprising... a and b are not added but joined or concatenated. This is because by default, an input is always treated as non-numeric in Python even if it contains digits. You will learn all about numeric and non-numeric datatypes in the next module.
Comments
Post a Comment