ive ben asked to make a program where the user inputs a floating number eg.(2.5)
and the program displays the 2 alone
and the .5 alone
ive ben trying for a while but gone nowhere

Recommended Answers

All 3 Replies

In your Python help file index look under divmod()

divmod( x, y)

Divides two numbers and returns the integer part of the result.

i see but what i need is ... ill show u and example

print "Enter The Floating Number"
F = input ()
(The user enter lets say 2.3 , then the program should display the 2 as the integer alone and the 3 as the decimal alone)

Okay here is a hint ...

float_number = 2.35
pre_point, post_point = divmod(float_number, 1)

print pre_point    # 2.0
print post_point   # 0.35
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.