Spaces:
Runtime error
Runtime error
# Define a dictionary called celscilist | |
celscilist = { | |
'Anil Seth': { 'info': { 'views': 14187265 , 'link': "youtubelink", 'student': "studentname" } }, | |
'Andrew Huberman 2': { 'info': { 'views': 620004 , 'link': "youtubelink", 'student': "studentname" } }, | |
'Donald Hoffman': { 'info': { 'views': 2504274 , 'link': "youtubelink", 'student': "studentname" } }, | |
'Doug Hofstadter': { 'info': { 'views': 75493 , 'link': "youtubelink", 'student': "studentname" } }, | |
'Howard Gardner': { 'info': { 'views': 1508453 , 'link': "youtubelink", 'student': "studentname" } }, | |
'Janelle Shane': { 'info': { 'views': 2755716 , 'link': "youtubelink", 'student': "studentname" } }, | |
'Daniel Kahneman': { 'info': { 'views': 1274170 , 'link': "youtubelink", 'student': "studentname" } }, | |
'Elizabeth Loftus': { 'info': { 'views': 2190333 , 'link': "youtubelink", 'student': "studentname" } }, | |
'Elizabeth Loftus 2': { 'info': { 'views': 2975 , 'link': "youtubelink", 'student': "studentname" } }, | |
'Patricia Churchland': { 'info': { 'views': 8026 , 'link': "youtubelink", 'student': "studentname" } }, | |
'Bret Weinstein': { 'info': { 'views': 41610 , 'link': "youtubelink", 'student': "studentname" } }, | |
'Andrew Huberman': { 'info': { 'views': 55561 , 'link': "youtubelink", 'student': "studentname" } }, | |
'Tom Scott': { 'info': { 'views': 2555516 , 'link': "youtubelink", 'student': "studentname" } }, | |
'Melanie Mitchell': { 'info': { 'views': 44875 , 'link': "youtubelink", 'student': "studentname" } }, | |
'Jordan Peterson': { 'info': { 'views': 236000 , 'link': "youtubelink", 'student': "studentname" } }, | |
'Timnit Gebru': { 'info': { 'views': 79338 , 'link': "youtubelink", 'student': "studentname" } }, | |
'Amy Cuddy': { 'info': { 'views': 23700189 , 'link': "youtubelink", 'student': "studentname" } }, | |
'Mihaly Csikszentmihalyi': { 'info': { 'views': 952791 , 'link': "youtubelink", 'student': "studentname" } }, | |
'Martha Nussbaum': { 'info': { 'views': 41046 , 'link': "youtubelink", 'student': "studentname" } }, | |
'Noam Chomsky': { 'info': { 'views': 26042 , 'link': "youtubelink", 'student': "studentname" } }, | |
'Russell A Barkley': { 'info': { 'views': 786116 , 'link': "youtubelink", 'student': "studentname" } }, | |
'Slavoj Žižek': { 'info': { 'views': 153187 , 'link': "youtubelink", 'student': "studentname" } }, | |
'Nathaniel Drew': { 'info': { 'views': 126828 , 'link': "youtubelink", 'student': "studentname" } }, | |
'Lara Boyd': { 'info': { 'views': 39097670 , 'link': "youtubelink", 'student': "studentname" } }, | |
'Yuval Noah Harari': { 'info': { 'views': 439139 , 'link': "youtubelink", 'student': "studentname" } }, | |
'Jordan Peterson 2': { 'info': { 'views': 672531 , 'link': "youtubelink", 'student': "studentname" } }, | |
'Yuval Noah Harari 2': { 'info': { 'views': 1859772 , 'link': "youtubelink", 'student': "studentname" } }, | |
'Joscha Bach': { 'info': { 'views': 528348 , 'link': "youtubelink", 'student': "studentname" } }, | |
'Poppy Crum': { 'info': { 'views': 133328 , 'link': "youtubelink", 'student': "studentname" } }, | |
'Ryan Holiday': { 'info': { 'views': 34846 , 'link': "youtubelink", 'student': "studentname" } }, | |
'Marvin Chun': { 'info': { 'views': 76604 , 'link': "youtubelink", 'student': "studentname" } }, | |
'Jim Davies': { 'info': { 'views': 27628 , 'link': "youtubelink", 'student': "studentname" } }, | |
} | |
# Extract 'views' values into a list | |
views_list = [item['info']['views'] for item in celscilist.values()] | |
# Calculate the sum of 'views' values | |
def calculate_average(views_list): | |
sum = 0 | |
for view in views_list: | |
sum += view | |
return sum / len(views_list) | |
# Define a class called Celsci | |
class Celsci: | |
def iscelsci(x): | |
y = "Not Above Average: " | |
if x > calculate_average(views_list): | |
y = "Above Average: " | |
return y | |
def iscelscinow(x): | |
y = "Not Above Average: " | |
if x > calculate_average(views_list): | |
y = "Above Average: " | |
return y | |
# Define a function called checkcelsci | |
def checkcelsci(x): | |
result = Celsci.iscelsci(celscilist[x]['info']['views']) | |
return result | |
# Find the maximum value in views_list | |
max_views = max(views_list) | |
# Define a function to find the key by views value | |
def find_key_by_views(obj, views_value): | |
for key, value in obj.items(): | |
if value['info']['views'] == views_value: | |
return key | |
# Call the function with data and max_views as arguments | |
no1 = find_key_by_views(celscilist, max_views) | |
def celsciresult(celsciname): | |
# Print the results | |
print(celscilist[celsciname]['info']['views'], checkcelsci(celsciname), int(calculate_average(views_list)), no1, max_views) | |
# Define a function called print_celscilist | |
def print_celscilist(celscilist): | |
# Loop through each key and value in celscilist | |
for key, value in celscilist.items(): | |
# Print the key and the views value | |
print(key, value['info']['views'], checkcelsci(key), int(calculate_average(views_list)), no1, max_views) | |
# Call the function with celscilist as an argument | |
#print_celscilist(celscilist) |