Big Teams Data Structures including List, Dictionaries, 2D arrays and Iteration (Big Idea 3)
- To complete my CPT project, I intend to repurpose some of the code from my previous group project. During the last trimester, I was responsible for developing the backend code, where I designed a personality testing function that updated a separate database, a user profile that collected and encrypted user information for future access, and a sign-in/log-in feature. I plan to utilize the user profile components and incorporate database storage to a simple game like Snake. Essentially, I will create a game that allows players to store their scores in a user database and profiles. Since our previous group project was not personalized, we decided to pursue separate CPT projects, while still collaborating on a group project.
import random
def spinnernum ():
spin = int(input("how many choices?"))
random_number = random.randint(1, spin)
return random_number
numbers = []
def simulation ():
numbers.append(spinnernum())
for i in range(3):
simulation()
print(numbers)
This is a simple simulation where you can see the list getting filled with random numbers
- It takes the user input and uses the random library to input the numbers into the list
- Here you can see how the list works
my_dict = {}
while True:
key = input("Enter a key (or 'stop' to exit): ")
if key == 'stop':
break
value = input("Enter a value: ")
my_dict[key] = value
print("Dictionary contents:")
for key, value in my_dict.items():
print(key, "->", value)
- this is a simulation of a dictionary applying values to keys
- This can be used to highlight the functionality of a dictionary and how quick it can be to access values