From 5a6bae4a4685dffb79755f2aea228cbb18c2b46b Mon Sep 17 00:00:00 2001 From: Mark Spiller Date: Wed, 29 Oct 2025 19:11:03 -0700 Subject: [PATCH] Add Files :) --- main.py | 239 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ mongo.py | 10 +++ 2 files changed, 249 insertions(+) create mode 100644 main.py create mode 100644 mongo.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..41308c7 --- /dev/null +++ b/main.py @@ -0,0 +1,239 @@ +''' +L1 = [1, 5, 6, 9, 129, 12, 17, 18, 92] +L2 = [5, 2, 77, 129, 4, 6, 2, 18] +L3 = [] +for item in L1 and L2: + L3.append(item) + +print(L3) + + +in_list = [5, 2, 3, 1, 4, 6, 8, 7] +total = 0 +for item in in_list: + total = total + 1 +print(total) + + + +for i in range(10): + if i == 3: + continue + if i == 7: + break + print(i) + + + +for x in {'winston', 'Lool'}: + print(f"Hello {x}") + +import math +x = 0 +while x <= 1: + print("Hello world") + + +my_list = [] +my_list.insert(0, 'cat') +my_list.insert(1, 'cow') +my_list.insert(2, 'dog') +my_list.insert(3, 'horse') +my_list.insert(4, 'pig') +print(my_list) + +import random +import math +import string +x = int(input("Please input a value: ")) +if x < 0: + print("You broke the program and the program will shut down") +if x >= 10 and x % 2 == 0: + print(f"You have overflooded the program {math.inf}") +elif x >=10 and x % 2 ==1: + print(f"ERROR!") +if x >= 0 and x <= 10: + x = math.factorial(x) + if x <= 100: + print(x) + elif x > 100: + x = x**2 + print(x) + y = input("Does this number seem correct? Y/n ") + if y == "Y": + random_letters = ''.join(random.choice(string.ascii_letters) for i in range(25)) + print(f"The computer doesn't like you anymore {random_letters}") + if y == "n": + print("Nice catch cheer :)") + + + +money = float(input("How much do you have? ")) +if money >= 20: + print(f"You should buy a Jumbo Baby Yoda Plush! You wil have {money-20} dollars remaining!") +elif money <20 and money >=7.2: + print(f"You should buy a beyblade! YOu will have {money-7.2} dollars remaining!") +elif money <7.2 and money >=0.5: + print(f"You shoudl buy sticky hands! You will have {money-0.5} dollars remaining!") +else: + print("You broke!") + + + + + +a = int(input("please enter your first test score: ")) +b = int(input("please enter your second test score: ")) +c = int(input("please enter your third test score: ")) +sum = (a+b+c)/3 + +if sum >= 90: + print("You got an A!") +elif sum <90 and sum >=80: + print("You got a B boo") +elif sum <80 and sum >=70: + print("You got a C failure") +elif sum <70 and sum >=60: + print("You got a D terrible") +elif sum <60 and sum >=50: + print("F - Grounded") + + + + +import math +x = int(input("please enter a number: ")) +if x == 1: + print("This is 1! This is neither prime nor composite! ") +elif math.sqrt(x) == 2: + print(f"This is 4") +else: + print("Whatever") + + + +team_number = input("Please enter a team number: ") +print(f"You have entered the team number {team_number}") +user_decision = input("Would you like to continue? Y/n ") +if user_decision == "Y": + user_location = input("Please enter your location:") + print(f"Team {team_number} was founded in {user_location} and has been a powerhouse team ever since.") +elif user_decision == "n": + team_number = input("Please reenter your team number: ") + user_location = input("Please enter your location: ") + print(f"Team {team_number} was founded in {user_location} and has been a powerhouse team ever since.") +else: + print("Error 404") + +if team_number != str(1678): + print("1678 is the best!") +else: + print("Good choice! ") +''' +# a = 0 +# for item in data: +# if item['team_num'] == 429: +# a +=1 +# print(f"6168 has played {a} matches") +# b = 0 +# for item in data: +# if item['team_num'] == 2464: +# b+=1 +# print(f"2464 has played {b} matches") +# c = 0 +# for item in data: +# if item['team_num'] == 4499: +# c +=1 +# print(f"4499 has played {c} matches") +# d = 0 +# for item in data: +# if item['team_num'] == 6068: +# d +=1 +# print(f"6068 has played {d} matches") +# e = 0 +# for item in data: +# if item['team_num'] == 6168: +# e +=1 +# print(f"6168 has played {e} matches") +# f = 0 +# for item in data: +# if item['team_num'] == 7650: +# f +=1 +# print(f"7650 has played {f} matches") + +# team_data_organized_by_team = {} +# for team_row in data: +# team_id = team_row['team_num'] +# if team_id not in team_data_organized_by_team: +# team_data_organized_by_team[team_id] = [] +# team_data_organized_by_team[team_id].append(team_row) +# for team_num, team_data in team_data_organized_by_team.items(): +# final_team_data = {'team_num': team_num, } + +import math +import pymongo +import json +client = pymongo.MongoClient("localhost", 27017) +db = client.winston +tims = db.tims +team_collection=db["team_collection"] +with open("example_tim_data.json") as f: + data = json.load(f) + #print(data) +tims.insert_many(data) + +teams = [] + +for item in data: + if item['team_num'] not in teams: + teams.append(item['team_num']) + +def maximum(team_list_data): + max_score = 0 + for item in team_list_data: + if item["num_balls"] > max_score: + max_score += item["num_balls"] - max_score + return(max_score) + +def minimum(team_list_data): + min_score = math.inf + for item in team_list_data: + if item["num_balls"] < min_score: + min_score -= (min_score - item["num_balls"]) + +def average(team_list_data): + matches_played = 0 + total_scored = 0 + for item in team_list_data: + total_scored += item["num_balls"] + matches_played = matches_played + 1 + return(total_scored/matches_played) + +def climb_percentage(team_list_data): + matches_played = 0 + climbs = 0 + for item in team_list_data: + matches_played += 1 + if item["climbed"]== True: + climbs += 1 + return(climbs/matches_played) + +# final_result = {1234: {'maximum': team_max}} +# for team in teams: +# team_data = list(tims.find({"team_num": team})) +# team_max = maximum(team_data) +# team_min = minimum(team_data) +# team_average = average(team_data) +# team_climb_percentage = climb_percentage(team_data) +# print(f"team_num: {team}. max balls scored: {team_max} min balls scored: {team_min} average score: {team_average} How much of the time could they succesfully climb: {team_climb_percentage}") + +final_result = {} +for team in teams: + team_data = list(tims.find({"team_num": team})) + final_result[team] = {} + final_result[team]['team_max'] = maximum(team_data) + final_result[team]['team_min'] = minimum(team_data) + final_result[team]['team_average'] = average(team_data) + final_result[team]['team_climb_percentage'] = climb_percentage(team_data) + +print(final_result[2464]['team_average']) diff --git a/mongo.py b/mongo.py new file mode 100644 index 0000000..a490fcb --- /dev/null +++ b/mongo.py @@ -0,0 +1,10 @@ +import pymongo +import json +client = pymongo.MongoClient("localhost", 27017) +db = client.winston +tims = db.tims +with open("example_tim_data.json") as f: + data = json.load(f) +tims.insert_many(data) +collection = tims.find() +print(collection) \ No newline at end of file