MADE WITH CANVA PRO
What a busy week it was! Looking at antiabuse, training newbies, and doing management stuff. My brain said, bye bye see you later. I was doing simple math:
If payment is in 4 currencies, we need to divide it among a team of 5 members. At the same time, one member gets 5% more than the rest. Also, I had to calculate 25% of all 4, invest it into the employees' growth fund, and calculate the division from the 75%.
It looks hard but it was simple math. I am good with percentages and mental maths. Remember I just mentioned, "5 members and 1 get 5% more"? The answer was simple to the real-world problem that I need to solve and sleep. Since my brain left the upper apartment and my body was tired, I was enabled to calculate (19*4)+24 = 100 aka 19%+19%+19%+19%+24%= 100%.
I needed to finish my work and sleep so I went to PIZZA discord, the home of engagement! I left a trivia "If pizza slices are divided among 5 people while one person gets 5% more than the rest, what will each get?".
SlothlyD#7500 was quickly replied 19 for 4 and 24 for one. He further said, Wait did you tricked me to do your homework? I said no I am just tired and had to solve this basic maths and explained everything.
In the last Community hangout of HiveLearners, one of the members from the management was asking me questions about coding. Classes, Variables, OOP (Object Oriented Program), and much more. In parallel, I was solving the same equation with 6 members to divide the pizza slices (LOL). I realized The question changes each week as a real-world problem for me and I am a coder (I was teaching basic concepts, LOL), Why not I just code it?
Note: Here Attempt means every time I run the code with adding more logic to code.
Code Version 1:
num_tokens = input("type number of tokens you want:")
dict = {}
for i in range(int(num_tokens)):
token_name = input ("What is the token number "+str(i+1)+":")
amount_token = input("The amount of the token number "+str(i+1)+":")
dict[token_name]=int(amount_token)
print (dict)
Output:
Here I just stored the data. So what it only did was naming the currencies and storing the values.
Code Version 2:
num_tokens = input("type number of tokens you want:")
dict = {}
for i in range(int(num_tokens)):
token_name = input ("What is the token number "+str(i+1)+":")
amount_token = input("The amount of the token number "+str(i+1)+":")
dict[token_name]=int(amount_token)
for token in dict:
percentage = dict[token] *0.25
print ("25% of "+token+": "+str(percentage))
Output:
Here in addition to storing the data, I calculated 25% of the currencies because we need to invest 25% in the employee growth fund.
Code Version 3:
num_tokens = input("type number of tokens you want:")
dict = {}
for i in range(int(num_tokens)):
token_name = input ("What is the token number "+str(i+1)+":")
amount_token = input("The amount of the token number "+str(i+1)+":")
dict[token_name]=int(amount_token)
num_people = input("type the number of people that you want to share the rest of 75%:")
for token in dict:
percentage = dict[token] *0.25
print ("25% of "+token+": "+str(percentage))
remaining = dict[token] - percentage
each_member_receives = remaining/int(num_people)
print ("Each member will receive "+str(each_member_receives)+" of "+" token")
Output:
Here I added the logic of dividing between members.
Code Version 4:
num_tokens = input("type number of tokens you want:")
dict = {}
for i in range(int(num_tokens)):
token_name = input ("What is the token number "+str(i+1)+":")
amount_token = input("The amount of the token number "+str(i+1)+":")
dict[token_name]=int(amount_token)
num_people = input("type the number of people that you want to share the rest of 75%:")
for token in dict:
percentage = dict[token] 0.25
print ("25% of "+token+": "+str(percentage))
remaining = dict[token] - percentage
percentage_foreach_member = 0.95/int(num_people)
each_member_receives = remaining percentage_foreach_member
manager_receives = each_member_receives + 0.05 remaining
print ("The manager receives " + str((percentage_foreach_member+0.05)100)+"% of "+token+": "+str(manager_receives))
print ("Each other member will receive "+str(percentage_foreach_member*100)+"%: "+str(each_member_receives)+" of "+" token\n")
Output:
Here I added the logic that one person gets 5% more.
Conclusion:
I personally needed this special calculation and now on weekly bases, it will save time. I will use my own code weekly is a wonderful feeling.
Thanks,
Mahirabdullah, Rantree, and Slothlyd for being a part of this small journey. Now we will sail to the next adventure with a different story and crew! See you around Hive! DLMMQB, Signing off.