Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
List calculations
#1
Sorry for populating the forum. However, I need some advice.

My below data is stored in the lists.
I would like to do calculations on the base of the order. For example: T1=Maths[0]+English[1]+History[2]+Acade[3]+Sport[0]
This calculation should be done for T2, T3 and T4.

I can do with lots of if-elif but I would like to know if there is a better way.

Output:
Maths [6, 7, 8, 5] English [9, 9, 8, 7] History [6, 6, 7, 8] Acade [9, 9, 8, 7] Sport [6, 6, 7, 8] ---------------------------------------- T1 T2 T3 T4 order for Maths ['A', 'B', 'C', 'D'] order for English ['B', 'C', 'D', 'A'] order for History ['C', 'D', 'A', 'B'] order for Academic ['D', 'C', 'B', 'A'] order for Sports ['A', 'B', 'C', 'D']
Reply
#2
Something like this?
alist = [[f'{a}{b}' for b in range(4)] for a in 'ABCDE']
for x in alist:
    print(x)

blist = []
count = len(alist[0])
for x in range(count):
    blist.append([alist[y][(x+y)%count] for y in range(len(alist))])

for x in blist:
    print(x)
What I am calling alist would be [Maths, English, History, Acade, Sport]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question Parameterized math calculations? babaliaris 7 16,932 Jun-01-2022, 10:19 AM
Last Post: Gribouillis
  Python, how to manage multiple data in list or dictionary with calculations and FIFO Mikeardy 8 2,623 Dec-31-2021, 07:47 AM
Last Post: Mikeardy
Photo Filtering data and precision during calculations Scientifix 0 1,788 Mar-30-2021, 01:00 PM
Last Post: Scientifix
  Automation in calculations interdisciplinary 5 2,712 Dec-10-2020, 11:22 PM
Last Post: deanhystad
  Latitude&Longitude Calculations gdimit 3 3,815 Jan-30-2018, 07:47 AM
Last Post: buran

Forum Jump:

User Panel Messages

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