Open utterances-bot opened 1 year ago
arr = [4,1,2,3]
print(arr.sort())
Benefits: Saving Money Little to no risk Testing Cons: Not 100% accurate as opposed to real life
One aspect of one of the social media platforms I go on is that they use machine learning to determine what posts are popular, which topics I enjoy looking at, and what is most likely to succeed in terms of a user spending time on said post.
Problem 1: arr = [0,12,1,31] min_num = -1000 arr = [4, 2, 1, 3]
n = len(arr) for i in range(n): for j in range(0, n - i - 1): if arr[j] > arr[j + 1]: arr[j], arr[j + 1] = arr[j + 1], arr[j]
print("Sorted Array:", arr)
Problem 2
Pros: Cheaper Easy to repeat Less risk
Cons: Less accurate than experiment Make assumptions by nature
Problem 3 Youtube uses sorting algorithms to sort videos from most view to least viewed, latest to oldest, and oldest to latest
arr = [69, 420, 999, 37]
arr.sort()
print(arr)
https://sris126.github.io/student//2023/10/27/SimulationsHW_IPYNB_2_.html
list = [5,3,8,7] print(list.sort())
Benefits: Efficient, saves money, less risky Negatives: Not completely accurate(since it's an assumption)
A social media platform that I frequently use is Tiktok. Tiktok has a "for you page", which is an aspect of an algorithm used to improve their feature and usability. The "for you page" presents the user with a bunch of short videos that they discover based on their personal preferences(algorithm detects watch time, and what videos they liked.)
Question #1 def sort_numbers(num1, num2, num3, num4) numbers = [num1, num2, num3, num4] numbers.sort() return numbers num1 = float(input("Enter the first number: ")) num2 = float(input("Enter the second number: ")) num3 = float(input("Enter the third number: ")) num4 = float(input("Enter the fourth number: ")) sorted_numbers = sort_numbers(num1, num2, num3, num4) print("Sorted numbers from lowest to highest:", sorted_numbers)
Question #2
Benefits: Repeatable,Cost Effective, Risk Free
Problems: Limits on accuracy
Question #3
Content Personalization: Algorithms analyze user behavior, such as the type of content they interact with, the accounts they follow, and the time they spend on different posts. Based on this data, the algorithm tailors the content users see on their feeds. Engagement Prediction: Algorithms predict how likely a user is to engage with a particular post, such as liking, sharing, or commenting.
Question 1: import random
def startGame():
print("Welcome to the sorter, choose your fields:")
userSizeSelection = input("Size of array: ")
try:
if(int(userSizeSelection) > 0):
userSizeSelection = int(userSizeSelection)
except:
print("\nInvaild Size\n")
startGame()
userNumRangeSelection = input("Max range of numbers: ")
try:
if(int(userNumRangeSelection) > 0):
userNumRangeSelection = int(userNumRangeSelection)
except:
print("\nInvaild Number range\n")
startGame()
userNumQuestions = input("Number of Questions: ")
try:
if(int(userNumQuestions) > 0):
userNumQuestions = int(userNumQuestions)
except:
print("\nInvaild Number of Questions\n")
startGame()
# userSizeSelection = 5
# userNumRangeSelection = 20
# userNumQuestions = 3
answer = genRandomNums(userSizeSelection, userNumRangeSelection)
insertAnswer = random.randint(0, userNumQuestions - 1)
questions = []
maxOfQuestions = userNumQuestions - 1
print("Which one of these have the same values as the one below:")
print("Match these values: " + str(sorted(answer)))
# Answer Guide
# print("Should be inserted at", (insertAnswer + 1))
for x in range(0, maxOfQuestions + 1):
if(insertAnswer == x):
print("\t" + str(x + 1) + ".) " + str(answer))
continue
possiableQuest = genRandomNums(userSizeSelection, userNumRangeSelection)
if(sorted(possiableQuest) == sorted(answer)):
maxOfQuestions += 1
else:
questions.append(possiableQuest)
print("\t" + str(x + 1) + ".) " + str(possiableQuest))
print("Which question is it at?")
userAnswer = input("Answer: ")
try:
if(int(userAnswer) == insertAnswer + 1):
print("Correct")
else:
print("Incorrect")
except:
print("\nInvaild Format\n")
startGame()
def genRandomNums(length, maximum):
nums = []
randomNums = []
for a in range(0, maximum):
randomNums.append(a)
# Appends all possiable nums
for x in range(0, length):
randNum = random.randint(0, (len(randomNums) - 1))
nums.append(randomNums[randNum])
randomNums.remove(randomNums[randNum])
# Get's a random num, removes it from list
return nums
startGame()
Benefits; Reusable, Less Wasteful, Quicker, Downside; lacks accuracy
Youtube uses an algorithm to have me engaged on their platform for as long as possible
Question 1: def sort_numbers(a, b, c, d): numbers = [a, b, c, d] numbers.sort() return numbers
sorted_numbers = sort_numbers(4, 2, 7, 1) print(sorted_numbers)
Question 2: Benefits
Question3: Instagram employs algorithms for its feed as well, showing users content based on their interactions, interests, and relationships. The Explore page also uses algorithms to suggest content tailored to users' preferences.
Algorithm for Sorting 4 Numbers:
python Copy code def sort_numbers(num1, num2, num3, num4): numbers = [num1, num2, num3, num4] numbers.sort() return numbers
num1 = 4 num2 = 1 num3 = 3 num4 = 2 sorted_nums = sort_numbers(num1, num2, num3, num4) print(sorted_nums) # Output: [1, 2, 3, 4] Benefits of Using a Simulation:
Safety: Simulations help you practice without risks.
Saving Money: They're cheaper than real tests or experiments.
Learning: Simulations help you practice and learn new skills.
Negative of Using a Simulation: One downside is that simulations might not be exactly like the real world, so results can sometimes be wrong.
Social Media Algorithm: Social media platforms like Facebook and Instagram use algorithms to show you posts and videos you'll like based on what you've liked and watched before. This makes your experience better and keeps you coming back for more.
CB 3.16-3.17 Simulations | CompSci Blogs
Student Lesson by Aidan, Rayyan, Nathan, and Daniel
https://rayyandarugar.github.io/student/2023/10/15/python-3x16-3x17-simulations_IPYNB2.html