+ 3
I want to ask a question :) tq
Why int first then input num = int(input()) if num < 100: print("number is lesser than 100") if num > 100: print("number is greater than 100") Tq for answering
6 Antworten
+ 5
Muhd Daniel when you take an input by input() its actually taken in STRING format (words/sentence format) Even if someone types 12 which is an integer, it would be converted into a string like "12" so you can't calculate "12" + "24" coz the answer would be 1224 (both strings joined / concatenated) So you have to make sure we are only working with numbers so int(input()). float(input()) if a number can be with decimals too.
+ 5
Can you please tell me why title is always placed after your name .
Similarly each programing language have it's own syntex of writing.
Got it !
🤣😊
+ 2
Because input() returns the input as string so if you want it to be integer you put int there so it converts string to int, in other words you are casting it.
+ 1
Because if we use only input it gives you a string value that's why we use int for taking a integer Value.
0
Tq for your help . Now i understand
0
Because by default input function take input as a string and int function convert string into integer