Programe is:
#
# Dynamic precision results printing
#
a =17
i = 0
answer = 'y'
while answer == 'y' or answer =='Y':
alfa = input('decimal point is:')
FORMAT = " ' Result is:, '%." + alfa + "f'"
print('format is:', FORMAT)
print(FORMAT %a)
answer = input(' to continue type y or Y: ')
i = i +1
print(' Final running!', i, 'problems')
#
# Dynamic precision results printing
#
a =17
i = 0
answer = 'y'
while answer == 'y' or answer =='Y':
alfa = input('decimal point is:')
FORMAT = " ' Result is:, '%." + alfa + "f'"
print('format is:', FORMAT)
print(FORMAT %a)
answer = input(' to continue type y or Y: ')
i = i +1
print(' Final running!', i, 'problems')
Results are:
Python 3.10.2 (v3.10.2:a58ebcc701, Jan 13 2022, 14:50:16) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license()" for more information.
======== RESTART: /Users/ionivan/Documents/Dynamic precisionPrinting.py ========
decimal point is:1
format is: ' Result is:, '%.1f'
' Result is:, '17.0'
to continue type y or Y: y
decimal point is:2
format is: ' Result is:, '%.2f'
' Result is:, '17.00'
to continue type y or Y: y
decimal point is:3
format is: ' Result is:, '%.3f'
' Result is:, '17.000'
to continue type y or Y: y
decimal point is:10
format is: ' Result is:, '%.10f'
' Result is:, '17.0000000000'
to continue type y or Y: n
Final running! 4 problems
(April 04, 2022)
Comments
Post a Comment