Python Forum
Dictionary with ranges that have a float step value
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dictionary with ranges that have a float step value
#3
import pprint

group1 = []
group2 = []
group3 = []

for value in range(200, 251, 1):
    group1.append(round(value*0.0001, 4))
    if value >= 210:
        group2.append(round(value*0.001, 3))
        group3.append(round(value*0.01, 2))


rcd_curr = {'SOUR:SAF:RCDC': {0.025: tuple(
    group1), 0.25: tuple(group2), 2.5: tuple(group3)}}

pprint.pprint(rcd_curr)
Output:
{'SOUR:SAF:RCDC': {0.025: (0.02, 0.0201, 0.0202, 0.0203, 0.0204, 0.0205, 0.0206, 0.0207, 0.0208, 0.0209, 0.021, 0.0211, 0.0212, 0.0213, 0.0214, 0.0215, 0.0216, 0.0217, 0.0218, 0.0219, 0.022, 0.0221, 0.0222, 0.0223, 0.0224, 0.0225, 0.0226, 0.0227, 0.0228, 0.0229, 0.023, 0.0231, 0.0232, 0.0233, 0.0234, 0.0235, 0.0236, 0.0237, 0.0238, 0.0239, 0.024, 0.0241, 0.0242, 0.0243, 0.0244, 0.0245, 0.0246, 0.0247, 0.0248, 0.0249, 0.025), 0.25: (0.21, 0.211, 0.212, 0.213, 0.214, 0.215, 0.216, 0.217, 0.218, 0.219, 0.22, 0.221, 0.222, 0.223, 0.224, 0.225, 0.226, 0.227, 0.228, 0.229, 0.23, 0.231, 0.232, 0.233, 0.234, 0.235, 0.236, 0.237, 0.238, 0.239, 0.24, 0.241, 0.242, 0.243, 0.244, 0.245, 0.246, 0.247, 0.248, 0.249, 0.25), 2.5: (2.1, 2.11, 2.12, 2.13, 2.14, 2.15, 2.16, 2.17, 2.18, 2.19, 2.2, 2.21, 2.22, 2.23, 2.24, 2.25, 2.26, 2.27, 2.28, 2.29, 2.3, 2.31, 2.32, 2.33, 2.34, 2.35, 2.36, 2.37, 2.38, 2.39, 2.4, 2.41, 2.42, 2.43, 2.44, 2.45, 2.46, 2.47, 2.48, 2.49, 2.5)}}
Reply


Messages In This Thread
RE: Dictionary with range - by menator01 - Apr-21-2021, 07:58 PM
RE: Dictionary with range - by Yoriz - Apr-21-2021, 09:04 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  python calculate float plus float is incorrect? sirocawa 6 653 Apr-16-2024, 01:45 PM
Last Post: DeaD_EyE
  [SOLVED] [loop] Exclude ranges in… range? Winfried 2 1,728 May-14-2023, 04:29 PM
Last Post: Winfried
  Delete all Excel named ranges (local and global scope) pfdjhfuys 2 2,216 Mar-24-2023, 01:32 PM
Last Post: pfdjhfuys
  Two operations in two ranges salwa17 3 2,314 Jun-22-2020, 04:15 PM
Last Post: perfringo
  Comaparing Float Values of Dictionary Against A Float Value & Pick Matching Key firebird 2 3,569 Jul-25-2019, 11:32 PM
Last Post: scidam
  iterating a list of ranges Skaperen 1 2,127 May-22-2019, 07:44 AM
Last Post: Gribouillis
  Subnet Mask Ranges ab52 0 1,890 Mar-11-2019, 10:39 AM
Last Post: ab52
  joined ranges Skaperen 4 3,336 Apr-03-2018, 07:14 PM
Last Post: Gribouillis
  Step -1 Upandon 2 3,144 Feb-27-2018, 06:02 AM
Last Post: Upandon
  a dictionary of ranges Skaperen 10 6,432 Dec-02-2017, 11:29 PM
Last Post: Windspar

Forum Jump:

User Panel Messages

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