I need the 2 digits before the . for example if the input 15.14 i want 14 and the input always be with 2 digits after & befor . | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I need the 2 digits before the . for example if the input 15.14 i want 14 and the input always be with 2 digits after & befor .

Help

11th Nov 2020, 4:21 PM
Panda🐼🐼🐼
Panda🐼🐼🐼 - avatar
3 Answers
+ 3
num = (input() or '15.14').split('.') print(f'.{num[1]}')
11th Nov 2020, 5:29 PM
Rik Wittkopp
Rik Wittkopp - avatar
+ 3
Panda🐼🐼🐼 It's for positive decimal numbers only.I've written this in java. Scanner sc=new Scanner(System.in); double a=sc.nextDouble(); if(a>=10.00&&a<=99.99) {double b=a-Math.floor(a); b=b*100; System.out.print(b); } else {System.out.print("Enter valid input"); }
11th Nov 2020, 6:40 PM
Coder##***
Coder##*** - avatar
0
I need vey sample way
11th Nov 2020, 4:23 PM
Panda🐼🐼🐼
Panda🐼🐼🐼 - avatar