InfoDb = []
# InfoDB is a data structure with expected Keys and Values
# Append to List a Dictionary of key/values related to a person and cars
InfoDb.append({
"FirstName": "John",
"LastName": "Mortensen",
"DOB": "October 21",
"Residence": "San Diego",
"Email": "jmortensen@powayusd.com",
"Owns_Cars": ["2015-Fusion", "2011-Ranger", "2003-Excursion", "1997-F350", "1969-Cadillac"]
})
# Append to List a 2nd Dictionary of key/values
InfoDb.append({
"FirstName": "Sunny",
"LastName": "Naidu",
"DOB": "August 2",
"Residence": "Temecula",
"Email": "snaidu@powayusd.com",
"Owns_Cars": ["4Runner"]
})
InfoDb.append({
"FirstName": "Advay",
"LastName": "Shindikar",
"DOB": "December 16",
"Residence": "San Diego",
"Email": "advay1216@gmail.com",
"Owns_Cars": ["Porsche 911"]
})
# Print the data structure
print(InfoDb)
x = len(InfoDb)
print(x)
x = len(InfoDb)
print(x)
i = 0
def print_data(d_rec):
print(d_rec["FirstName"], d_rec["LastName"]) # using comma puts space between values
print("\t", "Residence:", d_rec["Residence"]) # \t is a tab indent
print("\t", "Birth Day:", d_rec["DOB"])
print("\t", "Cars: ", end="") # end="" make sure no return occurs
print(", ".join(d_rec["Owns_Cars"])) # join allows printing a string list with separator
print()
for i in range (x):
record = InfoDb[i]
print_data(record)
i += 1
QuizDb = []
QuizDb.append({
"Q1": "Who won the 2021-2022 Premier League Title?",
"A1": "Manchester City",
"Q2": "Which Premier League team has won the most titles?",
"A2": "Manchester United",
"Q3": "Who is the all time leading scorer in the Premier League?",
"A3": "Alan Shearer",
"Q4": "Who is the most successful Premier League Manager?",
"A4": "Sir Alex Ferguson",
"Q5": "How many teams play in the Premier League?",
"A5": "20",
"Q6": "How many teams are relegated each year?",
"A6": "3",
"Q7": "When was the premier league officially founded?",
"A7": "1992"
})
def quiz():
f = 1
score = 0
while f <= 7:
answer = input(QuizDb [0]["Q"+str(f)])
if answer == QuizDb[0]["A"+str(f)]:
print ("correct")
score += 1
else:
print("incorrect")
f +=1
print("You Recieved", 100*(score/7), "%")
quiz()