repl.it
@Case_Buttitta/

1st Number after the decimal point

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""
instructions from your teacher:
Statement

Given a positive real number, print its first digit to the right of the decimal point.


Example input

1.79


Example output

7
"""



# Read a float:
a = float(input("Enter a floating number:")) # Get the input from user as a float number
#import math #using the math module function
#frac=math.modf(a) # Using "modf(x)" function we are getting the fraction and integer part as a tuple of fraction part in index 0 and integer part in index1.
#frac1=str(frac[0]) # As our o\p needs to produce the decimal alone so we are converting the fraction tuple alone in to a string 
print("1st digit after the decimal point is:",int(str(a).split(".")[1][0])) # As our o\p needs to print the value after the decimal point, we are printing the 2nd index position of the fractional string


Fetching token
?