RayyanDarugar / student

MIT License
0 stars 0 forks source link

CB 3.16-3.17 Simulations | CompSci Blogs #4

Open utterances-bot opened 1 year ago

utterances-bot commented 1 year ago

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

spooketti commented 1 year ago

Problem 1

arr = [4,1,2,3]
print(arr.sort())

Problem 2

Benefits: Saving Money Little to no risk Testing Cons: Not 100% accurate as opposed to real life

Problem 3

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.

SOoctosnake commented 1 year ago

Problem 1: arr = [0,12,1,31] min_num = -1000 arr = [4, 2, 1, 3]

Bubble Sort Algorithm

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 the sorted array

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

SriS126 commented 1 year ago

Question 1

creates the array, inputted random values

arr = [69, 420, 999, 37]

sorts the array

arr.sort()

prints the sorted array

print(arr)

Question 2

Benefits: less riskier, less costly, repeatable

Negatives: Makes guesses based on other answers, unoriginal, could be less accurate

Question 3

Tiktok uses an algorithm where they display the most liked videos when you first log in, and then use what you liked or favorited to display future videos, grabbing your attention more

https://sris126.github.io/student//2023/10/27/SimulationsHW_IPYNB_2_.html

AnvayYadav commented 1 year ago

Question 1

list = [5,3,8,7] print(list.sort())

Question 2

Benefits: Efficient, saves money, less risky Negatives: Not completely accurate(since it's an assumption)

Question 3

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.)

SrinivasNampalli commented 1 year ago

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.

nitinsandiego commented 1 year ago

https://nitinsandiego.github.io/student//2023/10/27/3.16-and-3.17_IPYNB_2_.html

ShakeSphereStuff commented 1 year ago

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()

Question 2:

Benefits; Reusable, Less Wasteful, Quicker, Downside; lacks accuracy

Question 3:

Youtube uses an algorithm to have me engaged on their platform for as long as possible

Sreejarai123 commented 1 year ago

Question 1: def sort_numbers(a, b, c, d): numbers = [a, b, c, d] numbers.sort() return numbers

Example usage:

sorted_numbers = sort_numbers(4, 2, 7, 1) print(sorted_numbers)

Question 2: Benefits

  1. cost-Effective
  2. Risk-Free Testing
  3. Time Efficiency Negatives: lacks accuracy, can oversimplify or lead to assumptions

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.

sharonkodali commented 1 year ago

https://sharonkodali.github.io/sharonk//2023/11/01/simulations_IPYNB_2_.html

tarunja1ks commented 1 year ago

https://tarunja1ks.github.io/student//2023/11/05/simulationshw_IPYNB_2_.html

alaraipek commented 1 year ago

https://alaraipek.github.io/student//2023/10/30/simulations_IPYNB_2_.html

monke7769 commented 1 year ago

https://monke7769.github.io/copy1//316317

alishahussain commented 1 year ago

https://alishahussain.github.io/student2//2023/11/04/simulations_IPYNB_2_.html

ChrisP121 commented 1 year ago

Algorithm for Sorting 4 Numbers:

python Copy code def sort_numbers(num1, num2, num3, num4): numbers = [num1, num2, num3, num4] numbers.sort() return numbers

Example usage:

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.