Python Forum
Error in Python 3.6 and how to limit decimal places
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error in Python 3.6 and how to limit decimal places
#7
(Mar-17-2017, 10:54 PM)snippsat Wrote: Add f.
..... snip .....

snippsat,

Adding f produces perfect output.  For other beginners, here's the code:
for myvalue in range(2,11):
    Radiobutton(rightFrame, text=f'{myvalue*.1:.1f}', font=(None, 14), variable=var, value=myvalue).pack()
.
.
Using your other suggestion, I like the following code better since it's easier to understand and also produces perfect output:
for myvalue in range(2,11):
    Radiobutton(rightFrame, text=myvalue*Decimal('.1'), font=(None, 14), variable=var, value=myvalue).pack()
Thanks for your help,
Raptor88
Reply


Messages In This Thread
RE: Error in Python 3.6 and how to limit decimal places - by Raptor88 - Mar-18-2017, 05:02 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python Struct Question, decimal 10, \n and \x0a. 3python 2 684 Aug-11-2023, 09:29 AM
Last Post: 3python
  Can I Limit Value used by python pajd 9 2,211 Feb-10-2022, 09:54 PM
Last Post: pajd
  Calculate the Euler Number with more decimal places Pedroski55 10 4,567 Oct-31-2021, 04:45 AM
Last Post: Pedroski55
  How to use a variable in Python (2.x) to define decimal part? MDRI 4 2,360 May-07-2021, 12:39 AM
Last Post: MDRI
  Not rounding to desired decimal places? pprod 2 2,588 Mar-05-2021, 11:11 AM
Last Post: pprod
  Decimal Rounding error project_science 4 2,796 Jan-06-2021, 03:14 PM
Last Post: project_science
  Can I format decimal places by column with a dictionary? Mark17 2 2,591 Dec-28-2020, 10:13 PM
Last Post: Mark17
  Time Limit Exceeded error loves 5 3,182 Dec-03-2020, 07:15 AM
Last Post: Sofia_Grace
  python decimal scale precision massimo_m 5 5,474 Aug-22-2019, 11:47 AM
Last Post: perfringo
  testing for Decimal w/o importing decimal every time Skaperen 7 4,505 May-06-2019, 10:23 PM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020