+ 2

I am not getting correct output....

run my code and enter a decimal number ..then see... There is a problem... My code is not getting correct output.... https://code.sololearn.com/c3p2zeVOBHJX/?ref=app

6th Jan 2022, 5:19 PM
𝑺𝑯𝑼𝑩𝑯𝑨𝑴 𝑹𝑨𝑱
𝑺𝑯𝑼𝑩𝑯𝑨𝑴 𝑹𝑨𝑱 - avatar
4 Respostas
+ 3
Shubham Raj When you take input then it is considered as string so if you enter 1.5 then it would be string but 1.5 contains decimal so you need to cast input with float and if you cast with int, you will get error. print this and see. print (type(a)) If you cast input with float then definitely type of input would be float so no need to check type after converting in float.
6th Jan 2022, 7:02 PM
A͢J
A͢J - avatar
+ 1
A͢J Yeh! I understand..... Can I use only string in input ..???. I mean if i will use var = input('enter number') And then i can convert into string to float or integer using this int() or float() Does this is correct ??
7th Jan 2022, 1:44 AM
𝑺𝑯𝑼𝑩𝑯𝑨𝑴 𝑹𝑨𝑱
𝑺𝑯𝑼𝑩𝑯𝑨𝑴 𝑹𝑨𝑱 - avatar
+ 1
Shubham Raj Some languages bydefault gives input in string. It is a default nature of input. We have to convert according to data types. To convert in int use int() function, to convert in float use float () function
7th Jan 2022, 2:54 AM
A͢J
A͢J - avatar
+ 1
Yeh !! A͢J I know these things... But I am new here 😅 so sometime it is difficult for me .... Var input ('number') Output = string Var int(input ('number')) If input = integer.. Output= integer If input = float Output = error Error if input is a float .. Var float(input ('number')) Output = float No error If input = interge Output = int.0 If input = float Output = float Am I correct??? yeh we can convert string into integer and float .. for float = float() for integer= int()
7th Jan 2022, 3:12 AM
𝑺𝑯𝑼𝑩𝑯𝑨𝑴 𝑹𝑨𝑱
𝑺𝑯𝑼𝑩𝑯𝑨𝑴 𝑹𝑨𝑱 - avatar