[Solved] how to add just the values in key s1 [closed]

If you want to add all the values of s1, you need to iterate over the values() of dictionary students. students={ 1: {“pup1”: “001”, “s1”: 10, “s2”: 20}, 2: {“pup2”: “124”, “s1”: 20, “s2”: 30}, 3: {“pup3”: “125”, “s1”: 30, “s2”: 40}} sum1 = 0 for data in students.values(): sum1 += data[‘s1’] avg = sum1 … Read more

[Solved] list of random codes like this : (XXXXX-XXXXX-XXXXX) on python

from random import choice from string import ascii_uppercase, digits CHAR_SET = ascii_uppercase + digits def get_integer(msg): while True: try: return int(input(msg)) except ValueError: pass def get_random_code(chunks=3, delim=’-‘): def get_random_str(length=5): return ”.join(choice(CHAR_SET) for _ in range(length)) return delim.join(get_random_str() for _ in range(chunks)) if __name__ == ‘__main__’: total_combos = get_integer(‘Enter # of combos to generate: ‘) for … Read more

[Solved] How to write a function that accepts a number as an argument and prints each number from 1 up to that maximum and boxed by square brackets? [closed]

How to write a function that accepts a number as an argument and prints each number from 1 up to that maximum and boxed by square brackets? [closed] solved How to write a function that accepts a number as an argument and prints each number from 1 up to that maximum and boxed by square … Read more

[Solved] I tried BUT for some reason my data sorting is not aligned with student names and i am getting wrong grades opposite to wrong names [closed]

The problem is that when you sort the GPAs, they’re no longer associated with the name ordering – you can simply skip doing so and the list indicies will stay correct or bring them into some collection (the instructions actually specify a tuple) # starting values scores_GPA = [3.85, 4.89, 2.89, 1.02, 3.8, 3.7, 2.9, … Read more

[Solved] Math brackets in python? [closed]

You don’t need “math” brackets — just use nested parentheses. Humans use [] in writing out complex math expressions to make them more readable to other humans, but this isn’t necessary. They don’t mean anything different than regular parentheses. So, when writing code, just stick to the parentheses. solved Math brackets in python? [closed]