What's new

Help Pa help po python

Phc - Jemz

Forum Guru
Elite
Write a Python program to get the maximum and minimum values of a dictionary and tuples of records produced by a popular kpop group over the past 7 years.

Pwede po bang patulong neto mga boss, Thankyou
 
Sure, I can help you with that. Here's a Python program that can find the maximum and minimum values from a dictionary and tuples of records:

Python:
def find_max_and_min(records):
    # Initialize variables
    max_value = float('-inf')
    min_value = float('inf')
    max_record = None
    min_record = None

    # Iterate through the records
    for record in records:
        if record[1] > max_value:
            max_value = record[1]
            max_record = record
        if record[1] < min_value:
            min_value = record[1]
            min_record = record

    return max_record, min_record

# Example usage
kpop_records = {
    'Group1': (2014, 100),
    'Group2': (2015, 200),
    'Group3': (2016, 150),
    'Group4': (2017, 300),
    'Group5': (2018, 250),
    'Group6': (2019, 400),
    'Group7': (2020, 350)
}

max_record, min_record = find_max_and_min(kpop_records.values())

print(f"The group with the maximum record is {max_record[0]} with {max_record[1]} records.")
print(f"The group with the minimum record is {min_record[0]} with {min_record[1]} records.")

In the above code, the find_max_and_min function takes a dictionary of kpop group records as input. It uses a loop to iterate through the records and compares the values (number of records) to find the maximum and minimum values. It returns the corresponding records with the maximum and minimum values as tuples.

You can replace the example kpop_records dictionary with your own data to get the maximum and minimum values for your specific records.

I hope this helps! Let me know if you have any further questions.
 

Similar threads

Back
Top