165k views
1 vote
Write a program that accepts a number as input, and prints just the decimal portion. Your program should also work if a negative number is input by the user

User Gws
by
6.3k points

2 Answers

3 votes

Answer:

To just print the decimal, use code (in python)

Step-by-step explanation:

number = float(input("Enter a number "))

print(number - int(number))

This code should cause the system to print just the decimals at the end of the number.

User Rachid Loukili
by
6.7k points
2 votes

In python:

number = float(input("Enter a number "))

print(round(number - int(number), 2))

User Teroi
by
5.7k points